Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pid As String = ComboBox1.SelectedItem
myConnection = New SqlConnection(Module1.connectionString)
myConnection.Open()
newq.Text = Val(TextBox2.Text) - Val(TextBox1.Text)
Dim majortable As SqlCommand = New SqlCommand("Update Product_Details Set Quantity ='" & newq.Text & "' WHERE P_ID='" & pid & " '", myConnection)
majortable.ExecuteNonQuery()
MessageBox.Show("Changes had done suceesfully. !", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sqlcmd = New SqlCommand("SELECT P_Id,P_Selling_Price FROM Product_Details WHERE P_Id='" & pid & "' ", myConnection)
' sqlcmd = New SqlCommand("SELECT P_Id,P_Selling_Price FROM Product_Details ", myConnection)
Dim dr As SqlDataReader = sqlcmd.ExecuteReader
Dim n As Integer = 0
Dim tot As Integer
' For n = 0 To dr.Read()
'n = 0
While dr.Read()
DGV1.Rows.Add()
DGV1.Rows(n).Cells(0).Value = dr.GetString(dr.GetOrdinal("P_Id"))
DGV1.Rows(n).Cells(1).Value = dr("P_Selling_Price").ToString
DGV1.Rows(n).Cells(2).Value = TextBox1.Text
DGV1.Rows(n).Cells(3).Value = Val(DGV1.Rows(n).Cells(2).Value) * Val(DGV1.Rows(n).Cells(1).Value)
'Next
'DGV1.Rows.Add()
n = n + 1
End While
If dr.HasRows Then
'ok
MessageBox.Show("Succesfully updated !!", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
Else
MessageBox.Show("Data doesn't exits !!", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)
End If
sqlcmd.Cancel()
dr.Close()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
myConnection.Close()
'Product_Details1(pid)
'Product_Details1()
refreshComponents()
End Sub
Dili1234 -2 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.