ive got a table: code, stocksretail, stocksws and numexpected
for example code: 0001, stocksretail : 24, stocksws: 1, numexpected :24 (numexpected = 1wholesale that contains 24pcs in retail)
code: 0002, stocksretail : 24, stocksws: 1, numexpected :24
my problem is when i buy the two items above, the stocksretail should now become 0 [(but it didnt happen, it becomes -24)],and stocksws=0(ive got a code in this stocksws and its working) .
What i really want is when the stocksws is decreasing, the stocksretail should decrease too depending on numexpected
Sub wsrt()
For a = 0 To LVCart.Items.Count - 1
sql = "select * from ItemProduct WHERE CODE = '" & LVCart.Items(a).Text & ""
Dim cmd = New OleDb.OleDbCommand(sql, conn)
acsdr = cmd.ExecuteReader()
While acsdr.Read()
Dim STOCKSWSRt As Integer = acsdr("numexpected")
sql = "UPDATE ItemProduct SET " & _
"stocksretail = stocksretail - ?" & _
"WHERE CODE = ?"
cmd = New OleDbCommand(sql.ToString, conn)
cmd.Parameters.AddWithValue("@stocksretail", STOCKSWSRt)
cmd.Parameters.AddWithValue("@CODE", LVCart.Items(a).Text)
cmd.ExecuteNonQuery()
End While
Next
acsdr.Close()
cmd.Dispose()
End Sub
sorry if my code is kinda messy but atleast i really try this one, please help me.im stuck in this code.