Advertisement
Guest User

Untitled

a guest
May 12th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. Dim conn As ADODB.Connection
  2. Dim admin As ADODB.Recordset
  3. Dim adm As String
  4.  
  5. Private Sub Command2_Click()
  6. Dim adm As String
  7. Dim myrecord As ADODB.Recordset
  8. Set myrecord = New ADODB.Recordset
  9.  
  10. admin.CursorLocation = adUseServer
  11. adm = "select * from employees where username = '" & Text1.Text & "' and password = '" & Text2.Text & "'"
  12. admin.Open adm, conn
  13.  
  14. If admin.EOF = False Then
  15. admin.MoveFirst
  16. adm = "select * from records where EmpID = " & admin!EmpID & " and TimeIn is not null and TimeOut is null limit 1"
  17. myrecord.Open adm, conn
  18. If myrecord.EOF = False Then
  19. conn.Execute "update records set TimeOut = now() where EmpID = " & admin!EmpID
  20. MsgBox admin!F_name & ", you have logged out."
  21. Else
  22. MsgBox admin!F_name & ", you are not yet logged in."
  23. End If
  24. myrecord.Close
  25. Else
  26. MsgBox "Unauthorized Personnel!"
  27. End If
  28. admin.Close
  29. End Sub
  30.  
  31. Private Sub Form_Load()
  32. connserver
  33. End Sub
  34. Private Sub connserver()
  35. Set conn = New ADODB.Connection
  36. conn.Open "Driver={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=alps;USER=root;PASSWORD=;OPTION=3"
  37. Set admin = New ADODB.Recordset
  38. End Sub
  39. Private Sub Command1_Click()
  40. Dim adm As String
  41. Dim myrecord As ADODB.Recordset
  42. Set myrecord = New ADODB.Recordset
  43.  
  44. admin.CursorLocation = adUseServer
  45. adm = "select * from employees where username = '" & Text1.Text & "' and password = '" & Text2.Text & "'"
  46. admin.Open adm, conn
  47.  
  48. If admin.EOF = False Then
  49. admin.MoveFirst
  50. adm = "select * from records where EmpID = " & admin!EmpID & " and TimeIn is not null and TimeOut is null limit 1"
  51. myrecord.Open adm, conn
  52. If myrecord.EOF = False Then
  53. MsgBox admin!F_name & ", you are already logged in."
  54. Else
  55. conn.Execute "insert into records (EmpID, TimeIn) values (" & admin!EmpID & ", now())"
  56. MsgBox admin!F_name & ", you have been logged in."
  57. End If
  58. myrecord.Close
  59. Else
  60. MsgBox "Unauthorized Personnel!"
  61. End If
  62. admin.Close
  63. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement