Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NATHAN RICHARDS CODE- NOT ALL ANNOTATED- MASKING FOR PASSWORDS AND SUBMISSION SYSTEM STILL NEEDS TO BE IMPLEMENTED
- Public Class Form1
- Private Sub MaskedTextBox1_MaskInputRejected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs)
- End Sub
- Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'this puts the logo into the picturebox at runtime
- Dim IMGlogo As Image = Image.FromFile("carps.png")
- Pboxlogo.Image = IMGlogo
- 'creates label at reference point 52,177, then displays it after creating it in runtime
- Dim lblwelcome As New Label
- Dim Labelfont As New Font("Arial", 12)
- lblwelcome.AutoSize = True
- lblwelcome.Font = Labelfont
- lblwelcome.Text = ("Welcome " & Environment.UserName & ", please select an option")
- lblwelcome.Location = New Point(52, 177)
- Me.Controls.Add(lblwelcome)
- End Sub
- Private Sub BTNClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNClose.Click
- Me.Close()
- FormOT.Close()
- End Sub
- Private Sub BTNOpenform_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNOpenform.Click
- EmployeeLogin.Show()
- Me.Close()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- ManagerLogon.Show()
- Me.Close()
- End Sub
- End Class
- Imports System.IO
- Imports System.Data.OleDb
- Public Class EmployeeLogin
- Private Sub EmployeeLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- BTNLoginTry.Enabled = False
- End Sub
- Private Sub TXTUsername_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TXTUsername.TextChanged
- If TXTPass.Text = "" Or TXTUsername.Text = "" Then
- BTNLoginTry.Enabled = False
- Else
- BTNLoginTry.Enabled = True
- End If
- End Sub
- Private Sub TXTPass_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TXTPass.TextChanged
- If TXTPass.Text = "" Or TXTUsername.Text = "" Then
- BTNLoginTry.Enabled = False
- Else
- BTNLoginTry.Enabled = True
- End If
- End Sub
- Private Sub BTNLoginTry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNLoginTry.Click
- Dim PasswordAttempt As String = TXTPass.Text
- 'Dim sr As New StreamReader("PassTest.txt")
- 'Dim actualpass As String = sr.ReadToEnd
- Const constring As String = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = Passwords.accdb"
- Dim con As New OleDbConnection(constring)
- Dim cmd As New OleDbCommand
- con.Open()
- If correctID(constring) = True Then
- MsgBox("Logged in as " & TXTUsername.Text)
- FormOT.Show()
- FormOT.employee = True
- FormOT.Manager = False
- Me.Close()
- End If
- 'If PasswordAttempt = actualpass Then
- ' MsgBox("Confirmed")
- ' FormOT.Show()
- ' FormOT.employee = True
- ' Me.Close()
- 'Else
- ' MsgBox("denied")
- 'End If
- 'sr.Close()
- End Sub
- Private Sub BTNCancellogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCancellogon.Click
- Form1.Show()
- Me.Close()
- End Sub
- Function correctID(ByVal constring As String) As Boolean
- Dim cmmdGetInfoStr As String = "SELECT Username, Password, Manager " &
- "FROM Passwords " &
- "WHERE Username = '" & TXTUsername.Text & "' " &
- "AND Password = '" & TXTPass.Text & "'"
- Dim conn As New OleDbConnection(constring)
- Dim cmmdGetInfo As New OleDbCommand
- cmmdGetInfo.Connection = conn
- cmmdGetInfo.CommandText = cmmdGetInfoStr
- conn.Open()
- Dim reader As OleDbDataReader = cmmdGetInfo.ExecuteReader()
- Dim username As String = ""
- Dim password As String = ""
- Dim manager As Boolean = False
- Do While reader.Read
- username = reader("username")
- password = reader("password")
- manager = reader("manager")
- Loop
- If username = TXTUsername.Text And password = TXTPass.Text And manager = False Then
- Return True
- ElseIf manager = True Then
- MsgBox("please use the administrator logon page to log in with this account")
- Return False
- Else
- MsgBox("incorrect credentials")
- Return False
- End If
- reader.Close()
- conn.Close()
- End Function
- Private Sub LBLLogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LBLLogon.Click
- End Sub
- End Class
- Imports System.IO
- Imports System.Data.OleDb
- Public Class ManagerLogon
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCancellogon.Click
- Form1.Show()
- Me.Close()
- End Sub
- Private Sub ManagerLogon_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- BTNLoginTry.Enabled = False
- TXTUsername.Text = Environment.UserName
- End Sub
- Private Sub BTNLoginTry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNLoginTry.Click
- 'Dim PasswordAttempt As String = TXTPass.Text
- 'Dim sr As New StreamReader("PassTest.txt")
- 'Dim actualpass As String = sr.ReadToEnd
- Const constring As String = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = Passwords.accdb"
- Dim con As New OleDbConnection(constring)
- Dim cmd As New OleDbCommand
- con.Open()
- If correctID(constring) = True Then
- MsgBox("Logged in as " & TXTUsername.Text)
- FormOT.Show()
- FormOT.employee = False
- FormOT.Manager = True
- Me.Close()
- End If
- 'If PasswordAttempt = actualpass Then
- ' MsgBox("Confirmed")
- ' FormOT.Show()
- ' FormOT.Manager = True
- ' Me.Close()
- 'Else
- ' MsgBox("denied")
- 'End If
- 'sr.Close()
- End Sub
- Private Sub TXTPass_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TXTPass.TextChanged
- If TXTPass.Text = "" Or TXTUsername.Text = "" Then
- BTNLoginTry.Enabled = False
- Else
- BTNLoginTry.Enabled = True
- End If
- End Sub
- Private Sub TXTUsername_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TXTUsername.TextChanged
- If TXTPass.Text = "" Or TXTUsername.Text = "" Then
- BTNLoginTry.Enabled = False
- Else
- BTNLoginTry.Enabled = True
- End If
- End Sub
- Private Sub LBLPasstry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LBLPasstry.Click
- End Sub
- Private Sub LBLLogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LBLLogon.Click
- End Sub
- Function correctID(ByVal constring As String) As Boolean
- Dim cmmdGetInfoStr As String = "SELECT Username, Password, Manager " &
- "FROM Passwords " &
- "WHERE Username = '" & TXTUsername.Text & "' " &
- "AND Password = '" & TXTPass.Text & "'"
- Dim conn As New OleDbConnection(constring)
- Dim cmmdGetInfo As New OleDbCommand
- cmmdGetInfo.Connection = conn
- cmmdGetInfo.CommandText = cmmdGetInfoStr
- conn.Open()
- Dim reader As OleDbDataReader = cmmdGetInfo.ExecuteReader()
- Dim username As String = ""
- Dim password As String = ""
- Dim manager As Boolean = False
- Do While reader.Read
- username = reader("username")
- password = reader("password")
- manager = reader("manager")
- Loop
- If username = TXTUsername.Text And password = TXTPass.Text And manager = True Then
- Return True
- ElseIf manager = False Then
- MsgBox("please use the employee login page to log in with this account, as it does not have Manager rights")
- Return False
- Else
- MsgBox("incorrect credentials")
- Return False
- End If
- reader.Close()
- conn.Close()
- End Function
- End Class
- Imports System.Data.OleDb
- Public Class FormOT
- Public employee As Boolean = False
- Public Manager As Boolean = False
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Me.Close()
- Form1.Close()
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNreturn.Click
- Form1.Show()
- Me.Close()
- End Sub
- Private Sub BTNClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNClear.Click
- Dateselect.Text = ("")
- Dateselect2.Text = ("")
- CMBPayrate.ResetText()
- End Sub
- Private Sub FormOT_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'Me.OvertimeTempTableTableAdapter.Fill(Me.OTDBDataSet.OvertimeTempTable)
- Dim sql As String = "SELECT * FROM OverTimeTempTable"
- Const constring As String = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = OTDB.accdb"
- Dim con As New OleDbConnection(constring)
- Dim cmd As New OleDbCommand
- If Manager = True Then
- LBLWelcomeOT.Text = "Logged in as Manager"
- Else
- LBLWelcomeOT.Text = "Logged in as Employee"
- End If
- Dim adapter As New OleDbDataAdapter(sql, con)
- ' Gets the records from the table and fills the adapter with those.
- Dim dt As New DataTable("OvertTimeTempTable")
- adapter.Fill(dt)
- ' Assigns the DataSource on the DataGridView
- DGVOT.DataSource = dt
- Dim adapter1 As New OleDbDataAdapter(sql, con)
- Dim cmd1 As New OleDbCommand(sql, con)
- con.Open()
- Dim myreader As OleDbDataReader = cmd1.ExecuteReader
- myreader.Read()
- con.Close()
- End Sub
- Private Sub LBLWelcomeOT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LBLWelcomeOT.Click
- End Sub
- Private Sub DGVOT_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DGVOT.CellContentClick
- End Sub
- Private Sub BTNSubmit_Click(sender As Object, e As EventArgs) Handles BTNSubmit.Click
- Const constring As String = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = OTDB.accdb"
- Dim con As New OleDbConnection(constring)
- Dim cmd As New OleDbCommand
- con.Open()
- Dim starttime As DateTime
- Dim endtime As DateTime
- Dim totalhours As Integer = DateDiff("H", starttime, endtime, )
- cmd.CommandText = "INSERT INTO OvertimeTempTable (ID Number, Hourly Pay, Payrate, Total Hours) VALUES (0000001,£5.68," & CMBPayrate.Text & "," & totalhours & ")"
- MsgBox("done")
- DGVOT.Update()
- End Sub
- Private Sub BTNBypass_Click(sender As Object, e As EventArgs) Handles BTNBypass.Click
- Const constring As String = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = OTDB.accdb"
- Dim con As New OleDbConnection(constring)
- Dim cmd As New OleDbCommand
- con.Open()
- End Sub
- Private Sub MaskedTextBox1_MaskInputRejected(ByVal sender As Object, ByVal e As MaskInputRejectedEventArgs) Handles TXTEndTime.MaskInputRejected
- MsgBox("that's not a valid character, please enter a time HH:MM")
- End Sub
- Private Sub MaskedTextBox2_MaskInputRejected(ByVal sender As Object, ByVal e As MaskInputRejectedEventArgs) Handles TXTEndTime.MaskInputRejected
- MsgBox("that's not a valid character, please enter a time HH:MM")
- End Sub
- Private Sub Dateselect_ValueChanged(sender As Object, e As EventArgs) Handles Dateselect.ValueChanged
- Dim diff As Integer
- diff = DateDiff("d", Dateselect, Dateselect2, )
- If diff > 0 Then
- MsgBox("the Start date is after the end date, please correct this")
- BTNSubmit.Enabled = False
- BTNBypass.Enabled = False
- Dateselect.ResetText()
- Else
- End If
- End Sub
- Private Sub Dateselect2_ValueChanged(sender As Object, e As EventArgs) Handles Dateselect2.ValueChanged
- Dim diff As Integer
- diff = DateDiff("d", Dateselect, Dateselect2, )
- If diff > 0 Then
- MsgBox("the end date is before the start date, please correct this")
- BTNSubmit.Enabled = False
- BTNBypass.Enabled = False
- Dateselect2.ResetText()
- Else
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement