Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim KeyAscii As Integer
- 'Public CustomerID As String
- Dim LogAd As Integer = 0
- Function Checkbox_false()
- chbAdmin.Checked = False
- End Function
- 'If txtUser.Text = "AdHughes" And txtPass.Text = "A1b2C3" Then
- ' 'txtUser.Text = "Admin"
- ' 'txtPass.Text = "Password"
- ' 'MsgBox(txtUser.Text) 'showing the value in the text box under admin
- ' 'MsgBox(txtPass.Text)
- ' LogAd = 1
- ' CustomerID = txtUser.Text
- ' Database_cus()
- ' Database_cus1()
- ' 'LogAd = 0
- ' 'Form2.Show()
- ' 'Me.Hide()
- 'Else
- ' txtUser.Text = ""
- ' txtPass.Text = ""
- 'End If
- Function Login_check()
- 'Do Until txtUser.Text = "" And txtPass.Text = ""
- If txtUser.Text <> "" And txtPass.Text = "" Then 'checking if the password is missing by seeing if the value is = nothing
- MsgBox("Your details are incorrect!",
- MsgBoxStyle.Exclamation)
- ElseIf txtUser.Text = "" And txtPass.Text <> "" Then 'checking if the username is missing by seeing if the value is = nothing
- MsgBox("You are missing a Username",
- MsgBoxStyle.Exclamation)
- 'Return False
- ElseIf txtUser.Text = "" And txtPass.Text = "" Then
- MsgBox("You are missing all details",
- MsgBoxStyle.Exclamation)
- End If
- 'Loop
- End Function
- Function Database_cus() 'Database check 1
- If LogAd = 0 Then
- If txtUser.Text = "AdHughes" Then
- txtUser.Text = "" 'When the program starts all of the data is reset and the fields are cleared_
- txtPass.Text = "" 'this is more so nessasary when the user logs out of the system so that_
- chbAdmin.Checked = False 'all data is cleared for security
- End If
- End If
- Dim con As New OleDb.OleDbConnection
- Dim dbProvider As String
- Dim dbSource As String
- Dim ds As New DataSet
- Dim da As OleDb.OleDbDataAdapter
- Dim sql As String
- Dim recordCount As Integer
- Dim userID As String
- Dim password As String
- userID = txtUser.Text
- password = txtPass.Text
- 'User = txtUser.Text 'makes the username disapear when enter is clicked
- dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
- ' dbSource = "Data Source = E:\PrototypeofProduct\Prototype of Product\bin\Debug\LoginDatabase.mdb" 'creating a link to the database tables to check the username and password records
- ' dbSource = "Data Source = .\LoginDatabase.mdb" 'creating a link to the database tables to check the username and password records
- con.ConnectionString = dbProvider & PublicVariables.ConnString
- con.Open()
- sql = "SELECT * FROM CustomerID WHERE CustomerID = '" & userID & "' AND CustomerPassword = '" & password & "'" 'using the database to then select the necessary fields to read_
- da = New OleDb.OleDbDataAdapter(sql, con) ' from to check the username to password
- da.Fill(ds, "CustomerID")
- recordCount = ds.Tables("CustomerID").Rows.Count
- Login_check() 'calling a previous function
- If recordCount = 0 Then
- con.Close()
- Return False
- Else
- con.Close()
- Return True
- End If
- If CustomerID = 0 Then
- 'MsgBox("memes")
- End If
- End Function
- Function Database_cus1() 'Database check 2
- ' If LogAd = 0 Then
- ' If txtUser.Text = "Admin" Then
- ' txtUser.Text = "" 'When the program starts all of the data is reset and the fields are cleared_
- ' txtPass.Text = "" 'this is more so nessasary when the user logs out of the system so that_
- ' chbAdmin.Checked = False 'all data is cleared for security
- ' End If
- ' End If
- ' Dim con As New OleDb.OleDbConnection
- ' Dim dbProvider As String
- ' Dim dbSource As String
- ' Dim ds As New DataSet
- ' Dim da As OleDb.OleDbDataAdapter
- ' Dim sql As String
- ' Dim recordCount As Integer
- ' Dim userID As String
- ' Dim password As String
- ' userID = txtUser.Text
- ' password = txtPass.Text
- ' 'User = txtUser.Text 'makes the username disapear when enter is clicked
- ' dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
- ' dbSource = "Data Source = E:\PrototypeofProduct\Prototype of Product\bin\Debug\LoginDatabase.mdb" 'creating a link to the database tables to check the username and password records
- ' con.ConnectionString = dbProvider & dbSource
- ' con.Open()
- ' sql = "SELECT * FROM EmailID WHERE EmployeeID = '" & userID & "' AND Employee_Pass = '" & password & "'" 'using the database to then select the necessary fields to read_
- ' da = New OleDb.OleDbDataAdapter(sql, con) ' from to check the username to password
- ' da.Fill(ds, "CustomerID")
- ' recordCount = ds.Tables("CustomerID").Rows.Count
- ' Login_check() 'calling a previous function
- ' If recordCount = 0 Then
- ' con.Close()
- ' Return False
- ' Else
- ' con.Close()
- ' Return True
- ' End If
- End Function
- Public Sub Button1_Click(sender As Object, e As EventArgs) Handles btnLog.Click
- MsgBox("Login details are incorrect!")
- If txtUser.Text = "AdHughes" And txtPass.Text = "A1b2C3" Then
- Login_check()
- 'txtUser.Text = "Admin"
- 'txtPass.Text = "Password"
- 'MsgBox(txtUser.Text) 'showing the value in the text box under admin
- 'MsgBox(txtPass.Text)
- LogAd = 1
- CustomerID = txtUser.Text
- Database_cus()
- 'LogAd = 0
- 'Form2.Show()
- 'Me.Hide()
- 'Else
- ' txtUser.Text = ""
- ' txtPass.Text = ""
- End If
- Login_check()
- If Database_cus() = True Then 'using a function to make the code shorter and reusable via recalling it
- 'Login_check()
- CustomerID = txtUser.Text 'v-- design aspect that allows me to check that the system has read the entered detail correctly
- 'MsgBox(CustomerID) 'checking that the value has been entered into the variable
- txtPass.Clear() 'need to clear the text boxes to make sure that no data over rides the current user
- txtUser.Clear()
- Me.Hide() 'closing the 'login' form_ 'note; This system was bad due to it just hiding the old form so now__
- Checkbox_false()
- Form2.Show() 'to then open the second form 'it is closed to allow for more efficient running of the program
- 'Me.Close()
- ElseIf Logad = 1 Then 'making use of the variable in two instances to ensure that the program doesnt just open the second form on activation of the first use of the variable_
- 'ElseIf Database_cus1() = True Then
- CustomerID = txtUser.Text 'v-- design aspect that allows me to check that the system has read the entered detail correctly
- 'MsgBox(CustomerID) 'checking that the value has been entered into the variable
- txtPass.Clear() 'need to clear the text boxes to make sure that no data over rides the current user
- txtUser.Clear()
- Me.Hide() 'closing the 'login' form_ 'note; This system was bad due to it just hiding the old form so now__
- Checkbox_false()
- Form2.Show() 'to then open the second form 'it is closed to allow for more efficient running of the program
- 'Me.Close()
- 'If txtUser.Text = "Admin" And txtPass.Text = "Password" Then 'the 'login' button must be pressed to load the next form, before the activation of the 'admin' check box loaded_
- ' Me.Hide() 'the Next form automatically
- ' Form2.Show()
- 'End If
- End If
- End Sub
- Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnClose1.Click
- Dim message = MsgBox("Are you sure?", MsgBoxStyle.YesNo)
- If message = MsgBoxResult.Yes = True Then
- Me.Close()
- End If
- End Sub
- Private Sub EnterClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
- If e.KeyCode.Equals(Keys.Enter) Then
- End If
- End Sub
- Private Sub txtPass_KeyPress(KeyCode As Integer, Shift As Integer) 'my attempt at trying to make the enter key being pressed click a certain button to allow for a faster login attempt
- 'If KeyAscii = 13 Then
- ' btnLog.Focus()
- 'End If
- End Sub
- Private Sub txtPass_KeyDown(sender As Object, e As KeyEventArgs) Handles txtPass.KeyDown '//
- If e.KeyCode = Keys.Enter Then
- Database_cus()
- 'Database_cus1()
- End If
- End Sub
- Private Sub txtUser_KeyDown(sender As Object, e As KeyEventArgs) Handles txtUser.KeyDown '//
- If e.KeyCode = Keys.Enter Then
- Database_cus()
- 'Database_cus1()
- End If
- End Sub
- Private Sub chbAdmin_CheckedChanged(sender As Object, e As EventArgs) Handles chbAdmin.CheckedChanged
- 'If chbAdmin.Checked = True Then
- ' txtUser.Text = "Admin"
- ' txtPass.Text = "Password"
- ' 'MsgBox(txtUser.Text) 'showing the value in the text box under admin
- ' 'MsgBox(txtPass.Text)
- ' LogAd = 1
- ' CustomerID = txtUser.Text
- ' Database_cus()
- ' Database_cus1()
- ' 'LogAd = 0
- ' 'Form2.Show()
- ' 'Me.Hide()
- 'Else
- ' txtUser.Text = ""
- ' txtPass.Text = ""
- 'End If
- If chbAdmin.Checked = True Then
- txtUser.Text = "AdHughes"
- txtPass.Text = "A1b2C3"
- Else
- txtUser.Text = ""
- txtPass.Text = ""
- End If
- End Sub
- Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
- If CheckBox1.Checked = True Then
- txtUser.Text = "Jhughes"
- txtPass.Text = "12345"
- Else
- txtUser.Text = ""
- txtPass.Text = ""
- End If
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'chbAdmin.Checked = False
- CheckBox1.Hide()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement