After the update I tried to recall "loaddata" but the result in the datagridview does not match if I close the debug form and then re-debug the form then the result of the new datagridview view is appropriate. Is there something wrong with the code.
Thanks
Private BindingSource1 As BindingSource = Nothing
Private ResultList As IEnumerable(Of ProductOut) = Nothing
Private Sub loaddata()
Using conn = New OleDbConnection(connectionString)
conn.Open()
resultList = conn.Query(Of ProductOut)("SELECT p.ProductId, p.ProductName,p.Price,p.Qty,s.QtyStock FROM ProductOut p INNER JOIN StockProduct s ON s.ProductId = p.ProductId").ToList()
conn.Close()
End Using
bindingSource1 = New BindingSource With {.DataSource = New BindingList(Of ProductOut)(CType(resultList, IList(Of ProductOut)))}
DataGridView1.DataSource = bindingSource1
End Sub
Private Sub BtnUpdate_Click(sender As Object, e As EventArgs) Handles BtnUpdate.Click
' Change quantity here.
Dim product = GetProduct()
ElseIf product IsNot Nothing Then
' Update product's quantity.
product.Qty += CInt(NumericUpDownQTY.Value)
DataGridView1.Refresh()
conn.Open()
Try
Dim count2 As Integer = conn.Execute("UPDATE StockProduct INNER JOIN ProductOut On (StockProduct.ProductId = ProductOut.ProductId) Set StockProduct.QtyStock = (StockProduct.QtyStock-(@Param1-ProductOut.Qty)), StockProduct.QtyOut = (StockProduct.QtyOut+(@Param2-ProductOut.Qty)) WHERE ProductOut.Productid = @PARAM3;",
New With {
Key .param1 = product.Qty,
Key .param2 = product.Qty,
Key .param3 = product.ProductId})
Dim count As Integer = conn.Execute("UPDATE ProductOut SET
Qty = @param1
WHERE ProductId = @param2",
New With {
Key .param1 = product.Qty,
Key .param2 = product.ProductId})
MessageBox.Show("successfully")
loaddata()
Catch ex As Exception
MessageBox.Show(ex.Message, "POS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End If
End Using
End Sub
before update Capture1

AFTER UPDATE Capture2
