كود :
Public Sub UpdateStore()
For i As Integer = 0 To Guna2DataGridView1.Rows.Count - 1
Dim cmd1 As New OleDbCommand("select * from tbl_itembaseinfo where itemid =@itemid ", Con)
cmd1.Parameters.Clear()
cmd1.Parameters.AddWithValue("@itemid ", OleDbType.Integer).Value = Guna2DataGridView1.Rows(i).Cells(0).Value
Dim dt As New DataTable
Dim adp As New OleDbDataAdapter(cmd1)
adp.Fill(dt)
If dt.Rows.Count > 0 Then
Dim Cmd2 As New oledbCommand
With Cmd2
.Connection = Con
.CommandType = CommandType.Text
.CommandText = "Update tbl_itembaseinfo Set itemqty = Qty + " & Guna2DataGridView1.Rows(i).Cells(3).Value & " Where itemid = @itemid "
.Parameters.Clear()
.Parameters.AddWithValue("@itemid ", OleDbType.Integer).Value = Guna2DataGridView1.Rows(i).Cells(0).Value
End With
If Con.State = 1 Then Con.Close()
Con.Open()
Cmd2.ExecuteNonQuery()
Con.Close()
Cmd2 = Nothing
End If
Next
MsgBox("تم تعديل الكميات في المستودع بنجاح", MsgBoxStyle.Information, "تعديل")
End Sub
