Hey i have build a POS system so when i call for an article from database and put that article in recipt GRID i want that article to be substractet (minused) from the database as much as how many times i have added to the recipt GRID. im using this code to call for an article from database.
Code:
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Try
' step 01: create the table adapter
Dim TA As New dbb1DataSetTableAdapters.ItemsTableAdapter
Dim TB = TA.GetDataByBarcode(TextBox2.Text)
Dim R As MAT_2._0.dbb1DataSet.ItemsRow = TB.Rows(0)
TextBox3.Text = R.Artikull
TextBox4.Text = R.Shites
Button1.Tag = R
Button1.Enabled = True
Catch ex As Exception
' display error message
MsgBox(ex.Message, MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
End Try
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' get the details of the item
Dim R As MAT_2._0.dbb1DataSet.ItemsRow = Button1.Tag
' next search for the barcode in the datagridview
Dim I As Integer
Dim ItemLoc As Integer = -1
For I = 0 To DataGridView1.Rows.Count - 1
If R.Barcode = DataGridView1.Rows(I).Cells("Column1").Value Then
' item found
ItemLoc = I
Exit For
End If
Next
If ItemLoc = -1 Then
DataGridView1.Rows.Add(R.Barcode, R.Artikull, R.Shites, 1, R.Shites, R.Bleres, R.Tax, R.TaxID, R.Unit, ((R.Shites * 100) / DTAX), (((R.Shites * 100) / DTAX) * DDV) / 100)
Else
end if