Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub cmdadd_Click()
- frmcreate.Show
- cmdsavelogin.Visible = True
- cmdgenp.Visible = True
- cmdgenu.Visible = True
- txtusername.Visible = True
- txtpassword.Visible = True
- lbluser.Visible = True
- lblpass.Visible = True
- If cmdstafflogin.Visible = True Then
- cmdstafflogin.Visible = False
- End If
- End Sub
- Private Sub cmdbrowse_Click()
- Unload Me
- frmgamecentral.Show
- 'this takes you to the next form and unloads the current form
- End Sub
- Private Sub cmdcustomer_Click()
- 'the following causes certain buttons and textboxes to appear.
- lbluser.Visible = True
- txtusername.Visible = True
- lblpass.Visible = True
- txtpassword.Visible = True
- cmdlogin.Visible = True
- If cmdsavelogin.Visible = True Then
- cmdsavelogin.Visible = False
- End If
- If cmdgenp.Visible = True Then
- cmdgenp.Visible = False
- End If
- If cmdgenu.Visible = True Then
- cmdgenu.Visible = False
- End If
- frmcreate.Hide
- frmcreate.txtlast.Text = ""
- frmcreate.txtname.Text = ""
- frmcreate.txtstreet.Text = ""
- 'certain command buttons are undesirable and the following invisible if they are visible
- If cmdstafflogin.Visible = True Then
- cmdstafflogin.Visible = False
- End If
- End Sub
- Private Sub cmdgenp_Click()
- txtpassword.PasswordChar = ""
- Randomize
- txtpassword = Int(Rnd * 10000)
- 'the code above generates a random number between 0 and 10000 which is used as a password
- End Sub
- Private Sub cmdgenu_Click()
- first = frmcreate.txtname.Text
- last = frmcreate.txtlast.Text
- street = frmcreate.txtstreet.Text
- txtusername.Text = Mid(first, 1, 1) & Mid(last, 1, 3) & Mid(street, 1, 3)
- MsgBox ("please write your username down for future reference.")
- End Sub
- Private Sub cmdleave_Click()
- Unload Me
- frmlogin.Show
- End Sub
- Private Sub cmdlogin2_Click()
- 'login code
- aSQL = " SELECT username, password FROM acc WHERE username = '" & txtusername.Text & "'" & " And password = '" & txtpassword.Text & "'" & ""
- 'selects username and password that mathes in the database to whats written in corresponding textboxes
- With accs
- .Open aSQL, connect
- If .EOF Then
- MsgBox ("Username or Password Incorrect")
- GoTo Redo
- End If
- End With
- If formrelation = 1 Then
- frmlogin.Hide
- loginname = txtusername.Text
- Unload Me
- frmgameform.Show
- ElseIf formrelation = 2 Then
- frmlogin.Hide
- loginname = txtusername.Text
- Unload Me
- frmbasket.Show
- End If
- Redo:
- accs.Close
- Set accs = Nothing
- End Sub
- Private Sub cmdsavelogin_Click()
- If txtusername.Text = "" Or txtpassword.Text = "" Then
- MsgBox ("Boxes are empty")
- ElseIf Not (txtusername.Text = "") And Not (txtpassword.Text = "") Then
- With customers
- .ActiveConnection = connect
- .LockType = adLockOptimistic
- .CursorType = adOpenKeyset
- .Open bSQL
- customers.AddNew
- 'this resets the record set
- .Fields("CustomerID").Value = txtusername.Text
- .Fields("Firstname").Value = frmcreate.txtname.Text
- .Fields("Surname").Value = frmcreate.txtlast.Text
- .Fields("Address").Value = frmcreate.txtstreet.Text
- 'this saves all details in the textboxes into the corresponding fields in the database
- MsgBox ("Customer details saved")
- End With
- customers.Update
- '----------------------------------------------------------------------------------------------
- With accs
- .ActiveConnection = connect
- .LockType = adLockOptimistic
- .CursorType = adOpenKeyset
- .Open aSQL
- accs.AddNew
- 'this resets the record set
- .Fields("username").Value = txtusername.Text
- .Fields("password").Value = txtpassword.Text
- .Fields("CustomerID").Value = txtusername.Text
- 'this saves all details in the textboxes into the corresponding fields in the database
- MsgBox ("Customer details saved")
- End With
- 'all boxes except txtNewID are cleared as it is needed for saving in the next form
- accs.Update
- '----------------------------------------------------------------------------------------------
- loginname = txtusername.Text
- Unload Me
- frmgamecentral.Show
- End If
- Set customers = Nothing
- Set accs = Nothing
- End Sub
- Private Sub cmdlogin_Click()
- 'login code
- aSQL = " SELECT username, password FROM acc WHERE username = '" & txtusername.Text & "'" & " And password = '" & txtpassword.Text & "'" & ""
- 'selects username and password that mathes in the database to whats written in corresponding textboxes
- With accs
- .Open aSQL, connect
- If .EOF Then
- MsgBox ("Username or Password Incorrect")
- GoTo Redo
- End If
- End With
- frmgamecentral.Show
- frmlogin.Hide
- loginname = txtusername.Text
- Unload Me
- Redo:
- accs.Close
- Set accs = Nothing
- End Sub
- Private Sub cmdsavelogin2_Click()
- If txtusername.Text = "" Or txtpassword.Text = "" Then
- MsgBox ("Boxes are empty")
- ElseIf Not (txtusername.Text = "") And Not (txtpassword.Text = "") Then
- With customers
- .ActiveConnection = connect
- .LockType = adLockOptimistic
- .CursorType = adOpenKeyset
- .Open bSQL
- customers.AddNew
- 'this resets the record set
- .Fields("CustomerID").Value = txtusername.Text
- .Fields("Firstname").Value = frmcreate.txtname.Text
- .Fields("Surname").Value = frmcreate.txtlast.Text
- .Fields("Address").Value = frmcreate.txtstreet.Text
- 'this saves all details in the textboxes into the corresponding fields in the database
- MsgBox ("Customer details saved")
- End With
- customers.Update
- '----------------------------------------------------------------------------------------------
- With accs
- .ActiveConnection = connect
- .LockType = adLockOptimistic
- .CursorType = adOpenKeyset
- .Open aSQL
- accs.AddNew
- 'this resets the record set
- .Fields("username").Value = txtusername.Text
- .Fields("password").Value = txtpassword.Text
- .Fields("CustomerID").Value = txtusername.Text
- 'this saves all details in the textboxes into the corresponding fields in the database
- MsgBox ("Customer details saved")
- End With
- accs.Update
- '----------------------------------------------------------------------------------------------
- loginname = txtusername.Text
- Unload Me
- End If
- Set customers = Nothing
- Set accs = Nothing
- End Sub
- End Sub
- Private Sub cmdstafflogin_Click()
- 'login code
- stSQL = " SELECT Username, Password FROM [Staff acc] WHERE Username = '" & txtusername.Text & "'" & " And Password = '" & txtpassword.Text & "'" & ""
- 'selects username and password that mathes in the database to whats written in corresponding textboxes
- With staccs
- .Open stSQL, connect
- If .EOF Then 'if the search doesnt match up then a meesage box appears and the procedure skips to the end
- MsgBox ("Username or Password Incorrect")
- GoTo Redo
- End If
- End With
- Unload Me
- frmstaffhome.Show
- frmcreate.Hide
- Redo:
- staccs.Close
- Set staccs = Nothing
- End Sub
- Private Sub cmdStaff_Click()
- 'the following causes certain buttons and textboxes to appear.
- lbluser.Visible = True
- txtusername.Visible = True
- lblpass.Visible = True
- txtpassword.Visible = True
- cmdstafflogin.Visible = True
- 'certain command buttons are undesirable and the following invisible if they are visible
- If cmdsavelogin.Visible = True Then
- cmdsavelogin.Visible = False
- End If
- If cmdgenu.Visible = True Then
- cmdgenu.Visible = False
- End If
- If cmdgenp.Visible = True Then
- cmdgenp.Visible = False
- End If
- If cmdlogin.Visible = True Then
- cmdlogin.Visible = False
- End If
- frmcreate.Hide
- End Sub
- Private Sub Form_Load()
- 'these hide certain command buttons to avoid confusion
- lbluser.Visible = False
- txtusername.Visible = False
- cmdgenu.Visible = False
- lblpass.Visible = False
- txtpassword.Visible = False
- cmdgenp.Visible = False
- cmdsavelogin.Visible = False
- cmdlogin.Visible = False
- cmdstafflogin.Visible = False
- cmdlogin2.Visible = False
- cmdsavelogin2.Visible = False
- cmdleave.Visible = False
- '--------------------------------------------------------------------------------
- 'database connection
- 'this code is used to retrieve information from tables in the database
- Set connect = New ADODB.Connection
- DBsePath = App.Path & "\gamedb.mdb"
- connect.ConnectionString = "provider = microsoft.jet.OLEDB.4.0;data source=" & DBsePath
- connect.Open
- bSQL = "SELECT * FROM customer"
- aSQL = "SELECT * FROM acc"
- stSQL = "SELECT * FROM Staff acc"
- End Sub
Add Comment
Please, Sign In to add comment