Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim conn As ADODB.Connection
- Dim admin As ADODB.Recordset
- Dim adm As String
- Private Sub Command2_Click()
- Dim adm As String
- Dim myrecord As ADODB.Recordset
- Set myrecord = New ADODB.Recordset
- admin.CursorLocation = adUseServer
- adm = "select * from employees where username = '" & Text1.Text & "' and password = '" & Text2.Text & "'"
- admin.Open adm, conn
- If admin.EOF = False Then
- admin.MoveFirst
- adm = "select * from records where EmpID = " & admin!EmpID & " and TimeIn is not null and TimeOut is null limit 1"
- myrecord.Open adm, conn
- If myrecord.EOF = False Then
- conn.Execute "update records set TimeOut = now() where EmpID = " & admin!EmpID
- MsgBox admin!F_name & ", you have logged out."
- Else
- MsgBox admin!F_name & ", you are not yet logged in."
- End If
- myrecord.Close
- Else
- MsgBox "Unauthorized Personnel!"
- End If
- admin.Close
- End Sub
- Private Sub Form_Load()
- connserver
- End Sub
- Private Sub connserver()
- Set conn = New ADODB.Connection
- conn.Open "Driver={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=alps;USER=root;PASSWORD=;OPTION=3"
- Set admin = New ADODB.Recordset
- End Sub
- Private Sub Command1_Click()
- Dim adm As String
- Dim myrecord As ADODB.Recordset
- Set myrecord = New ADODB.Recordset
- admin.CursorLocation = adUseServer
- adm = "select * from employees where username = '" & Text1.Text & "' and password = '" & Text2.Text & "'"
- admin.Open adm, conn
- If admin.EOF = False Then
- admin.MoveFirst
- adm = "select * from records where EmpID = " & admin!EmpID & " and TimeIn is not null and TimeOut is null limit 1"
- myrecord.Open adm, conn
- If myrecord.EOF = False Then
- MsgBox admin!F_name & ", you are already logged in."
- Else
- conn.Execute "insert into records (EmpID, TimeIn) values (" & admin!EmpID & ", now())"
- MsgBox admin!F_name & ", you have been logged in."
- End If
- myrecord.Close
- Else
- MsgBox "Unauthorized Personnel!"
- End If
- admin.Close
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement