Advertisement
Guest User

Untitled

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