Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using MS Visual Studio Express 2017 for Desktop and C#.

I am currently developing an automatic clock in / clock out system (WITH ALWAYS ON-BARCODE SCANNER) for the production floor of the company I'm working at..

Basically when someone goes in, they have to scan their ID (barcode) and my current system will record the time and does the same when the same person goes out..

But the problem now is, currently I'm using 2 Application Forms (1 for IN and 1 for OUT) which means our security guard would have to manually trigger the form change. (This eliminates the fact that it has to be automatic)..

I'm hoping to get help with the system to automatically detect the 2nd scan of a person to be an OUT scan.

Example : Person A scan ID1001.. And lets say he scans the second time, the system would automatically detect that ID1001 is a 2nd scan and it will update the database in the 'OUT' field

What I have tried:

private void textBox3_TextChanged(object sender, EventArgs e)
 {
     SqlCommand com;
     for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
     {
         if (dataGridView1.Rows[i].Cells["tag"].Value.ToString() == textBox3.Text)
         {
             textBox2.Text = dataGridView1.Rows[i].Cells["emp"].Value.ToString();
             textBox4.Text = dataGridView1.Rows[i].Cells["name"].Value.ToString();
             textBox5.Text = dataGridView1.Rows[i].Cells["dep"].Value.ToString();
             textBox7.Text = DateTime.Now.ToString("hh:mm");
             textBox6.Text = DateTime.Now.ToShortDateString();

             if (!string.IsNullOrEmpty(textBox5.Text))
             {
                 con.Open();
                 com = new SqlCommand("insert into log(tag,emp,name,intime,tarikh,dep) values ('" + textBox3.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + textBox7.Text + "','" + textBox6.Text + "','" + textBox5.Text + "')", con);
                 com.ExecuteNonQuery();
                 con.Close();
             }
         }
     }


     BindGridView2();

 }
Posted
Updated 16-Dec-20 19:41pm

The way it should work is: the employee scans, then confirms: Is it in or out?

Or types an employee number and scans, etc.

In other cases, you "checked in / out" your time card; you didn't carry it around.

Or you had a counter you plugged in: your responsibility.

In other words, you don't have employees running around, not knowing if they're checking in or out and not having control over the process. Passing off barcodes, etc.

This is stuff people get fired over. The objective is not speed.
 
Share this answer
 
Quote:
I'm hoping to get help with the system to automatically detect the 2nd scan of a person to be an OUT scan.

You already have a solution, but not automatic. You have to device a way to deduce if scan is in or out.
Solution can be user doing input as it scan, or deducing in/put with even/odd passage. But it also depend on actual conditions of working like plant running 7/24 or not and employee working less than 12h per day.
Solution also depend on scans being accurate or not, you may need a procedure to recover inconsistent scans.
All this depend on exact details on how the plant operates. We can't do it for you.
C#
com = new SqlCommand("insert into log(tag,emp,name,intime,tarikh,dep) values ('" + textBox3.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + textBox7.Text + "','" + textBox6.Text + "','" + textBox5.Text + "')", con);

Not a solution to your question, but another problem you have.
Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability named "SQL injection", it is dangerous for your database and error prone.
A single quote in a name and your program crash. If a user input a name like "Brian O'Conner" can crash your app, it is an SQL injection vulnerability, and the crash is the least of the problems, a malicious user input and it is promoted to SQL commands with all credentials.
SQL injection - Wikipedia[^]
SQL Injection[^]
SQL Injection Attacks by Example[^]
PHP: SQL Injection - Manual[^]
How can I explain SQL injection without technical jargon? - Information Security Stack Exchange[^]
 
Share this answer
 
I do not see why this is a complicated software problem:

1) it's binary: employee is either in or out

2) dependency on behavior of a security guard, or, employee behavior ? there's a real potential issue: what if the guard lets someone exit without checking out, then, later, re-enter without checking in ? this is a very common form of fraud in businesses. typical solutions may involve rfid tags, and/or, locked gates/turnstiles.

3) in terms of the database, a boolean field can hold the current in/out status.
 
Share this answer
 

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