Private Sub Butcas_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Butcas.Click
Dim result As Boolean
If TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Then
MessageBox.Show("กรุณาใส่ข้อมูลให้ครบ", "ผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf MessageBox.Show("คุณต้องการบันทึกใช่หรือไม่ ?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = MsgBoxResult.Yes Then
Dim Check As Boolean = False
Dim i As Integer
For i = 0 To DataGridView1.RowCount = 0
If TextBox1.Text = DataGridView1.Rows.Item(i).Cells(0).Value.ToString Then
Check = True
MsgBox("รหัสสินค้า : " & TextBox1.Text & " มีอยู่ในระบบอยู่แล้ว")
Else
Dim S1 As New OleDbDataAdapter("insert into Customer(C_ID,FName,SName,Age,Address,Postcode,Telephone,Email,Regis)values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "')", conn)
Dim S2 As New DataTable
S1.Fill(S2)
DataGridView1.DataSource = S2
ds.Tables("database.mdb").Clear()
Showee()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
txtSearch.Text = ""
End If
Exit For
Next
Else
result = True
End If
End Sub