Ex. I selected an item where its stocks is 30 and I input 5 as its quantity, then when I deleted it in the quotation, the value of the updated quantity in the Pricelist became 5..
Here is my code in the ADD button:
Private Sub addBtn_Buttonclicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addBtn.Buttonclicked
add = "Added"
minus = "Sold"
StocksTextBox.Text = Val(StocksTextBox.Text) - Val(QuantityTextBox.Text)
If StocksTextBox.Text <= 0 Then
MessageBox.Show("Item '" & DescriptionTextBox.Text & "' Stocks will be Empty ", "Invalid Input ", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf StocksTextBox.Text <= 9 Then
MessageBox.Show("Item '" & DescriptionTextBox.Text & "' Stocks is Low ", "Item Information ", MessageBoxButtons.OK, MessageBoxIcon.Information)
gdpcccon = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\GDPCC\gdpcc.mdb")
Dim cmd As New OleDbCommand
Dim strUpdate As String = "update priceTable set [Stocks] = '" & StocksTextBox.Text & "' where ID = " & IDTextBox.Text
gdpcccon.Open()
cmd = New OleDbCommand(strUpdate, gdpcccon)
cmd.ExecuteNonQuery()
gdpcccon.Close()
datagridshow()
AddItemToListView()
QuantityTextBox.Text = ""
QuantityTextBox.Enabled = True
Me.PriceTableBindingSource.CancelEdit()
Else
gdpcccon = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\GDPCC\gdpcc.mdb")
Dim cmd As New OleDbCommand
Dim strUpdate As String = "update priceTable set Status = '" & minus & "', [Quantity] = '" & QuantityTextBox.Text & "', [Stocks] = '" & StocksTextBox.Text & "' where ID = " & IDTextBox.Text
gdpcccon.Open()
cmd = New OleDbCommand(strUpdate, gdpcccon)
cmd.ExecuteNonQuery()
MessageBox.Show("Item '" & DescriptionTextBox.Text & "' was Added ", "Item Information ", MessageBoxButtons.OK, MessageBoxIcon.Information)
gdpcccon.Close()
datagridshow()
AddItemToListView()
QuantityTextBox.Enabled = True
QuantityTextBox.Text = ""
DescriptionTextBox.Text = ""
CodeTextBox.Text = ""
Regular_ColorTextBox.Text = ""
Wood_FinishTextBox.Text = ""
RadioButton2.Checked = False
RadioButton1.Checked = False
Me.PriceTableBindingSource.CancelEdit()
End If
End Sub
Here is the code for the Delete item:
Private Sub btnDelete_Buttonclicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Buttonclicked
Me.PriceTableTableAdapter.FillByID(Me.GdpccDataSet.priceTable, IDTextBox2.Text)
TextBox9.Text = IDTextBox2.Text
If ListView1.SelectedItems.Count > 0 AndAlso MessageBox.Show("Do you want to delete this item?", "Confirm", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
StocksTextBox1.Text = Val(TextBox7.Text) + Val(StocksTextBox1.Text)
gdpcccon = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\GDPCC\gdpcc.mdb")
Dim cmd As New OleDbCommand
Dim strUpdate As String = "update priceTable set [Stocks] = '" & StocksTextBox1.Text & "' where ID = " & TextBox6.Text
gdpcccon.Open()
cmd = New OleDbCommand(strUpdate, gdpcccon)
cmd.ExecuteNonQuery()
MessageBox.Show("Item '" & DescriptionTextBox1.Text & "' Stocks, Updated Successfully ", " ", MessageBoxButtons.OK, MessageBoxIcon.Information)
gdpcccon.Close()
datagridshow()
ListView1.SelectedItems(0).Remove()
Else
IDTextBox2.Text = TextBox8.Text
MessageBox.Show("Please Select Data to Delete")
End If
End Sub
Some screenshots:




New Topic/Question
Reply



MultiQuote


|