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 intNumRows1 As Integer
Dim intNumRows2 As Integer
Dim intNumRows3 As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtusername.Text & "' AND Password = '" & Me.txtpassword.Text & "' "
objCmd = New MySqlCommand(strSQL, objConn)
intNumRows1 = objCmd.ExecuteScalar()
strNUM = "SELECT COUNT(*) FROM book WHERE book_no = '" & Me.lblnum.Text & "'"
objCmd = New MySqlCommand(strNUM, objConn)
intNumRows2 = objCmd.ExecuteScalar()
strDATE = "SELECT COUNT(*) FROM book WHERE book_date = '" & Date.Today
objCmd = New MySqlCommand(strDATE, objConn)
intNumRows3 = objCmd.ExecuteScalar()
If intNumRows1 > 0 Then
If intNumRows2 > 0 Then
If intNumRows3 > 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