Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
updateproduct()
End Sub
Sub updateproduct()
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim am As String = "select * from at_product where pd_id = '" & TextBox6.Text & "'"
Dim com As New SqlCommand(am, con)
Dim dr As SqlDataReader = com.ExecuteReader
Dim amount As Integer = 0
If dr.HasRows = True Then
dr.Read()
amount = CInt(dr.Item(4))
dr.Close()
MsgBox("ข้อมูลตรงกัน")
Dim update As String = "update at_product set pd_amount ='" & CInt(TextBox8.Text) - amount & "'"
Dim com1 As New SqlCommand
With com1
.CommandType = CommandType.Text
.CommandText = update
.Connection = con
.ExecuteNonQuery()
MessageBox.Show("ทำการขายเรียบร้อย", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
End With
Else
dr.Close()
MsgBox("ไม่ตรง")
End If
con.Close()
End Sub