01.
Private
Sub
save_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
save.Click
02.
Dim
sav
As
MsgBoxResult
03.
Dim
sqladd
As
String
04.
Dim
cm
As
New
SqlCommand
05.
Conn =
New
SqlConnection(
"Data Source=TOSHIBA-PC\SQLEXPRESS;Initial Catalog=rfid2;Integrated Security=True"
)
06.
Conn.Open()
07.
If
TextBox1.Text =
""
Or
TextBox2.Text =
""
Or
TextBox3.Text =
""
Then
08.
MessageBox.Show(
"คุณยังกรอกข้อมูลไม่ครบถ้วน"
)
09.
Exit
Sub
10.
End
If
11.
sav = MessageBox.Show(
"คุณต้องการบันทึกข้อมูลหรือไม่?"
,
"rfid"
, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
12.
If
sav = MsgBoxResult.Yes
Then
13.
sqladd =
"INSERT INTO rfidtable(CardSN,Firstname,Surname)"
14.
sqladd &=
"VALUES ( ' "
& TextBox1.Text &
" ',' "
& TextBox2.Text &
" ',' "
& TextBox3.Text &
" ') "
15.
With
cm
16.
.CommandType = CommandType.Text
17.
.CommandText = sqladd
18.
.Connection = Conn
19.
.ExecuteNonQuery()
20.
End
With
21.
End
If
22.
MessageBox.Show(
"บันทึกข้อมูลเรียบร้อย"
,
"rfid"
, MessageBoxButtons.OK, MessageBoxIcon.Information)
23.
TextBox1.Clear()
24.
TextBox2.Clear()
25.
TextBox3.Clear()
26.
End
Sub