I am creating an POS screen which uses inventory and I need to reduce the inventory item picked by 1 each time the user clicks the datagridview.
When the user clicks on the datagridview aka dgproducts I want the quantity of dgProducts.SelectedRows(i).Cells(3).Value)which is the quantity field in the access database to be reduced by one. The table is products.
The user should be able to click on the product + of the row, and it should reduce the quantity of that item by one each time it's clicked.
Then when an item is deleted from the list manually by clicking on the item in the list and then delete button... it has to go back into inventory and update the table.***
------------------------------------------------------------------------
So I am at this point, which is not going to work for obvious reasons.
How do I deduct 1 which is in the txtquantity box from the cell 3 and have it update? would it be something like dgProducts.SelectedRows(i).Cells(3).Value= Val(txtquantity.Text)-dgProducts.SelectedRows(i).Cells(3).Value ?
Not sure of the syntax but does this seem logical or is there another way to do this.
myqry = "Update Products Set "
myqry = myqry + " Quantity = '" & dgProducts.SelectedRows(i).Cells(3).Value & "',"
myqry = myqry + " WHERE "
myqry = myqry + " Quantity = " & Val(txtquantity.Text)
mycmd = New OleDbCommand(myqry, conn)
mycmd.ExecuteNonQuery()
I get index is out of range error for the code above anyway ( which is really strange because it ie quantity field is cell 3, not 2 , not 4 ...tested it out on a textbox and it's 3)