Imports MySql.Data.MySqlClient
Imports System.Data
Public Class frmLogin
frmlogin.lblnum.Text = txtnumber.Text
'เข้าสู่ระบบ
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim objConn As New MySqlConnection
Dim objCmd As New MySqlCommand
Dim strConnString, strSQL, strNUMANDDATE, strTIMETOLOCK As String
Dim i As Integer
i = TimeOfDay.Hour
If i Mod 2 = 0 Then
strTIMETOLOCK = i
Else
strTIMETOLOCK = i - 1
End If
strConnString = "Server=localhost;User Id=root; Password=1234; Database=reservations; Pooling=false"
objConn.ConnectionString = strConnString
objConn.Open()
Dim checkid As Integer
strSQL = "SELECT COUNT(*) FROM member WHERE Username = '" & Me.txtUsername.Text & "' AND password = '" & Me.txtPassword.Text &
"' AND member_id = '" & Me.txtmemberid.Text & "'"
objCmd = New MySqlCommand(strSQL, objConn)
checkid = objCmd.ExecuteScalar()
Dim checkcomanddate As Integer
strNUMANDDATE = "SELECT COUNT(*) FROM book WHERE book_no = '" & Me.lblnum.Text & "' AND book_date = '" & Format(Now, "yyyy-mm-dd") &
"' AND member_id = '" & Me.txtmemberid.Text & "'"
objCmd = New MySqlCommand(strNUMANDDATE, objConn)
checkcomanddate = objCmd.ExecuteScalar()
objConn.Close()
objConn = Nothing
If checkid > 0 Then
If checkcomanddate > 0 Then
tmlockwindow1.Start()
tmmessage1.Start()
tmtimeshow.Start()
Me.Hide()
Else
MessageBox.Show("คุณไม่ได้จองเครื่องคอมพิวเตอร์ในเวลาดังกล่าว")
End If
Else
MessageBox.Show("รหัสผ่านหรือรหัสประจำตัวไม่ถูกต้อง ")
End If
End Sub
'ปุ่มปิด
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
If MessageBox.Show("คุณต้องการออกจากโปรแกรมใช่หรือไม่ ?", "", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
End Class