Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BinL1.Click
With Conn
Conn = New OleDb.OleDbConnection(strConnection)
Conn.Open()
End With
sqlSave = "INSERT INTO ST([ID],[Room],[Timein],[Date])"
sqlSave &= "VALUES('" & TextBoxID.Text & "','" & LI1.Text & "','" & dtpIn.Text & "','" & DateTimePicker.Text & "')"
With com
.CommandText = sqlSave
.CommandType = CommandType.Text
.Connection = Conn
.ExecuteNonQuery()
End With
If MsgBox("ป้อนข้อมูลเรียบร้อยแล้ว" & n1.ToString, MsgBoxStyle.Question + MsgBoxStyle.OkOnly) = MsgBoxResult.Yes Then
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BotL1.Click
With Conn
Conn = New OleDb.OleDbConnection(strConnection)
Conn.Open()
End With
sqlSave = "INSERT INTO ST([ID],[Room],[Timeout],[Date])"
sqlSave &= "VALUES('" & TextBoxID.Text & "','" & LO1.Text & "','" & dtpOut.Text & "','" & DateTimePicker.Text & "')"
With com
.CommandText = sqlSave
.CommandType = CommandType.Text
.Connection = Conn
.ExecuteNonQuery()
End With
If MsgBox("ป้อนข้อมูลเรียบร้อยแล้ว", MsgBoxStyle.Question + MsgBoxStyle.OkOnly) = MsgBoxResult.Yes Then
End If
End Sub
คุณก็ตรวจสอบ database ก่อนซิครับว่า มีการ login logout user id นี้หรือเปล่า เช่น ตรวจสอบว่า user "admin" logout หรือยัง
SELECT [ID],[Room],[Timein],MAX([Timeout]),[Date]) FROM ST WHERE [ID] = 'admin' AND [DATE] = 'วันนี้'