Click here to Skip to main content
15,937,779 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
We have a thesis and it is a payroll system with bar code attendance monitoring. I don't know where to start when it comes to recording the time in and time out of each employee. Can someone please help me with the codes for the time in and time out? Our adviser wants us to use one textbox only for both time in and time out.

need help asap

What I have tried:

As of now, i have two textboxes and they are recording the timein and timeout just fine. But just like what i said, input should be recorded in one textbox only. And it should be entered automatically without buttons. And the time that is being recorded to the database is from a Label, I know there is a better way, but i just don't know how to incorporate it. below is my current code(using buttons).
<pre lang="vb">
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        conn()
        Dim Reader As MySqlDataReader
        Mysqlconn.Open()
        Try

            Dim query As String
            query = "insert into db_payroll.tbltimein (code, timein, date) values ('" & TextBox1.Text & "', '" & Label5.Text & "', '" & Label6.Text & "') "
            Command = New MySqlCommand(query, Mysqlconn)
            Reader = Command.ExecuteReader

            TextBox1.Text = ""

            btn_Refresh.PerformClick()
            Mysqlconn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)

        Finally
            Mysqlconn.Dispose()
        End Try
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        conn()
        Dim Reader As MySqlDataReader
        Mysqlconn.Open()
        Try

            Dim query As String
            query = "insert into db_payroll.tbltimeout (code, timeout, date) values ('" & TextBox1.Text & "', '" & Label5.Text & "', '" & Label6.Text & "') "
            Command = New MySqlCommand(query, Mysqlconn)
            Reader = Command.ExecuteReader

            TextBox1.Text = ""

            btn_refreshout.PerformClick()
            Mysqlconn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)

        Finally
            Mysqlconn.Dispose()
        End Try
    End Sub
Posted
Updated 25-Mar-18 19:56pm
v3
Comments
Patrice T 25-Mar-18 21:43pm    
Do you have night shifts ?
How long is the daily work time ?
Member 13746082 25-Mar-18 21:49pm    
no night shifts, just the regular hours of work for the day, 8am-5pm

1 solution

Quote:
no night shifts, just the regular hours of work for the day, 8am-5pm

So what is the problem ?
In database, you have a list of times.
For a given day, you have an even number of times.
Times at odd positions are time-in, times at even positions are time-out.
What else do you need?
Quote:
my problem is how to use one textbox only for both time in and time out

Get employee id and time and record to database.
repeat as needed
When record times, you need employee id, date and time, nothing else.
For a given day if you are given 8am and 5pm do you have a problem to know which one is time in and which one is time out ?
Quote:
yes, how will you know if it's timein or timeout. what i'd like to happen is to have a restriction, the first scan would be timein and second scan will already be the timeout

If you really have problems dealing with this situation, you will have hard times with this job because this kind of thing happen continuously.
 
Share this answer
 
v4
Comments
Member 13746082 25-Mar-18 22:53pm    
my problem is how to use one textbox only for both time in and time out
Member 13746082 25-Mar-18 23:36pm    
yes, how will you know if it's timein or timeout. what i'd like to happen is to have a restriction, the first scan would be timein and second scan will already be the timeout
Patrice T 25-Mar-18 23:43pm    
take time of a day, sort in chronological order
first can only be in and second can only be out, no other possibility
Member 13746082 25-Mar-18 23:53pm    
do you have any easier suggestions? and can you help me with the codes?
Patrice T 26-Mar-18 0:02am    
if you are given 2 times, can't you deduce which 1 is in and which 1 is out?
your program will do the same by applying the same technique.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900