Private Sub Btnupdate_Click() Handles Btnupdate.Click
If TextID.Text = "" Or IsDataComplete() = False Then
Exit Sub
End If
Dim s As String
If Not (PictureBox1.Image Is Nothing) Then
s = ",Picture = @pic"
Else
s = ""
End If
sql = "UPDATE Employee SET Emp_Name = @name,Emp_Las = @last,Emp_Age = @age,Emp_Num = @num,Emp_Add = @add & s"
sql = "WHERE Emp_ID = @id"
command.Parameters.Clear()
command.CommandText = sql
command.Parameters.AddWithValue("@name", Textname.Text)
command.Parameters.AddWithValue("@last", Textlats.Text)
command.Parameters.AddWithValue("@age", Textage.Text)
command.Parameters.AddWithValue("@num", Textnum.Text)
command.Parameters.AddWithValue("@add", Textadd.Text)
command.Parameters.AddWithValue("@id", TextID.Text)
If Not (PictureBox1.Image Is Nothing) Then
Dim byteArr() As Byte = ReadImage()
command.Parameters.AddWithValue("pic", byteArr)
End If
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("บันทึกการเปลี่ยนแปลงแล้ว")
UpdateBinding()
Else
MessageBox.Show("เกิดข้อผิดพลาด")
End If
End Sub
PL ----> BLL ----> DAL
...
Btnupdate.Click() Parameter(ByVal Button As Button) Parameter(Byval Button As Button)
If txtSexCode = "" Then Insert/Update/Delete from tableSEX
... Insert into tableXXX (fucTime, Price) Values ( 3, 1,500 x 3)
End If