Private Sub bttlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttlogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL, strNUM, strDATE As String
strConnString = "Server=localhost;User Id=root; Password=1234; Database=library; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open()
Dim checkid As Integer
Dim checkcom As Integer
Dim checkdate As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtusername.Text & "' AND Password = '" & Me.txtpassword.Text & "'"
objCmd = New MySqlCommand(strSQL, objConn)
checkid = objCmd.ExecuteScalar()
strNUM = "SELECT COUNT(*) FROM book WHERE book_no = '" & Me.lblnum.Text & "'"
objCmd = New MySqlCommand(strNUM, objConn)
checkcom = objCmd.ExecuteScalar()
strDATE = "SELECT COUNT(*) FROM book WHERE book_date = '" & Format(Now, "yyyy-MM-dd") & "'"
objCmd = New MySqlCommand(strDATE, objConn)
checkdate = objCmd.ExecuteScalar()
If checkdate > 0 Then
If checkcom > 0 Then
If checkid > 0 Then
Me.Hide()
Else
MessageBox.Show(" ชื่อผู้ใช้งาน หรือ รหัสผ่านไม่ถูกต้อง ")
End If
Else
MessageBox.Show(" คุณไม่ได้ทำการจองคอมพิวเตอร์เครื่องนี้ ")
End If
Else
MessageBox.Show(" คุณไม่ได้จองเครื่องคอมพิวเตอร์ในช่วงเวลาดังกล่าว ")
End If
objConn.Close()
objConn = Nothing
End Sub
End Class