Advertisement
Guest User

Untitled

a guest
May 15th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 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. Text1.Text = ""
  29. Text2.Text = ""
  30. admin.Close
  31. End Sub
  32.  
  33. Private Sub Command4_Click()
  34. Unload Me
  35. End Sub
  36.  
  37. Private Sub Form_Load()
  38. connserver
  39. End Sub
  40. Private Sub connserver()
  41. Set conn = New ADODB.Connection
  42. conn.Open "Driver={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=alps;USER=root;PASSWORD=;OPTION=3"
  43. Set admin = New ADODB.Recordset
  44. End Sub
  45. Private Sub Command1_Click()
  46. Dim adm As String
  47. Dim myrecord As ADODB.Recordset
  48. Set myrecord = New ADODB.Recordset
  49.  
  50. admin.CursorLocation = adUseServer
  51. adm = "select * from employees where username = '" & Text1.Text & "' and password = '" & Text2.Text & "'"
  52. admin.Open adm, conn
  53.  
  54. If admin.EOF = False Then
  55. admin.MoveFirst
  56. adm = "select * from records where EmpID = " & admin!EmpID & " and TimeIn is not null and TimeOut is null limit 1"
  57. myrecord.Open adm, conn
  58. If myrecord.EOF = False Then
  59. MsgBox admin!F_name & ", you are already logged in."
  60. Else
  61. conn.Execute "insert into records (EmpID, TimeIn) values (" & admin!EmpID & ", now())"
  62. MsgBox admin!F_name & ", you have been logged in."
  63. End If
  64. myrecord.Close
  65. Else
  66. MsgBox "Unauthorized Personnel!"
  67. End If
  68. Text1.Text = ""
  69. Text2.Text = ""
  70. admin.Close
  71. End Sub
  72.  
  73.  
  74. EmpID
  75. username
  76. timein
  77. timeout
  78. totaltime
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement