I'm finishing up a project for school and am having an issue. The application I've created uses an access database and a VB application. A user clocks in and clocks out with their email address. When you clock in and clock out each "time punch" is an individual record in the same table.
So this is the ER diagram of the time punch table
Attachment 93687
Now my problem comes on the reporting side. Currently this is what my reports look like.
Attachment 93689
The Punch_Type_Table field is a 1 or 2, 1 is a clock in and 2 is a clock out.
Now what I want to be able to do is calculate the total number of hours worked by the individual. So in this example Row 2 - Row 1 = Hours Worked, Row 4 - Row 3 = Hours worked, and the sum of all these "new records" would give me the total hours worked. My main issue however is figuring out how to calculate the time difference between a clock out punch and the previous clock in punch.
Any ideas or any clarification needed.
Here is my current code on the reports page.
So this is the ER diagram of the time punch table
Attachment 93687
Now my problem comes on the reporting side. Currently this is what my reports look like.
Attachment 93689
The Punch_Type_Table field is a 1 or 2, 1 is a clock in and 2 is a clock out.
Now what I want to be able to do is calculate the total number of hours worked by the individual. So in this example Row 2 - Row 1 = Hours Worked, Row 4 - Row 3 = Hours worked, and the sum of all these "new records" would give me the total hours worked. My main issue however is figuring out how to calculate the time difference between a clock out punch and the previous clock in punch.
Any ideas or any clarification needed.
Here is my current code on the reports page.
Code:
Public Class Administration
Private Sub UpdateEditEmployeeInformationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateEditEmployeeInformationToolStripMenuItem.Click
Dim empRecord As New Add_Employee
Add_Employee.Show()
End Sub
Private Sub LogOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogOutToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If DateTimePicker1.Value.Date <= DateTimePicker2.Value.Date Then
Else
MessageBox.Show("Please Select an End Date greater than the Start Date")
End If
If ComboBox1.SelectedIndex = 0 Then
MessageBox.Show("Please Select a Report")
End If
If ComboBox1.SelectedIndex = 1 Then
Dim LastPeriod As Date
LastPeriod = #1/6/2012#
Do Until LastPeriod > Today
LastPeriod = DateAdd(DateInterval.Day, 14, LastPeriod)
Loop
DateTimePicker2.Value = LastPeriod
DateTimePicker1.Value = DateAdd(DateInterval.Day, -13, DateTimePicker2.Value)
Dim BeginDate As Date = DateTimePicker1.Value
Dim EndDate As Date = DateTimePicker2.Value
Dim empID As String = ComboBox2.SelectedValue
Me.Time_Punch_TableTableAdapter.LastPayPeriod(Me.Database1DataSet.Time_Punch_Table, empID, BeginDate, EndDate)
If DataGridView1.RowCount = 1 Then
MessageBox.Show("No Records Found.")
End If
End If
If ComboBox1.SelectedIndex = 2 Then
Dim BeginDate As Date = DateTimePicker1.Value
Dim EndDate As Date = DateTimePicker2.Value
Dim empID As String = ComboBox2.SelectedValue
Me.Time_Punch_TableTableAdapter.TotalHoursWorked(Me.Database1DataSet.Time_Punch_Table, empID, BeginDate, EndDate)
If DataGridView1.RowCount = 1 Then
MessageBox.Show("No Records Found.")
End If
End If
If ComboBox1.SelectedIndex = 3 Then
Dim empID As String = ComboBox2.SelectedValue
Me.Time_Punch_TableTableAdapter.TimePunchErrors(Me.Database1DataSet.Time_Punch_Table, empID)
If DataGridView1.RowCount = 1 Then
MessageBox.Show("No Records Found.")
End If
End If
End Sub
Private Sub Administration_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Database1DataSet.Time_Punch_Table' table. You can move, or remove it, as needed.
Me.Time_Punch_TableTableAdapter.Fill(Me.Database1DataSet.Time_Punch_Table)
'TODO: This line of code loads data into the 'Database1DataSet.Change_Log_Table' table. You can move, or remove it, as needed.
Me.Change_Log_TableTableAdapter.Fill(Me.Database1DataSet.Change_Log_Table)
'TODO: This line of code loads data into the 'Database1DataSet.Employee' table. You can move, or remove it, as needed.
Me.EmployeeTableAdapter.Fill(Me.Database1DataSet.Employee)
'TODO: This line of code loads data into the 'Database1DataSet.Time_Punch_Table' table. You can move, or remove it, as needed.
Me.Time_Punch_TableTableAdapter.Fill(Me.Database1DataSet.Time_Punch_Table)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ComboBox1.SelectedIndex = 0
ComboBox2.SelectedIndex = 0
DateTimePicker1.Value = Today
DateTimePicker2.Value = Today
Me.Time_Punch_TableTableAdapter.Fill2(Me.Database1DataSet.Time_Punch_Table)
End Sub
Private Sub HelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HelpToolStripMenuItem.Click
Dim dir = IO.Directory.GetCurrentDirectory()
Process.Start(IO.Path.Combine(Application.StartupPath, dir & "\Employee_Time_Clock_User_Manual.pdf"))
End Sub
End Class