Home > OS >  Record the entry and exit of employees
Record the entry and exit of employees

Time:12-06

My friends, I am doing the personnel management project and I had a problem enter image description herecontrolling the entry and exit of personnel. I register the entry and exit of personnel through the personnel ID, but I do not know what mechanism I should design to register the exit. Control the entry and exit of the system in SQL Server. And the code I wrote is to store employee logins. It should be noted that the model I use is the repository generic and unit of Work model.

 private void btnSave_Click(object sender, EventArgs e)
    {
        var id = int.Parse(txtIDPersonnel.Text);          

        using (UnitOfWork db = new UnitOfWork())
        {
            ArrivalsAndDepartures save = new ArrivalsAndDepartures();
           
            save.IDPersonnel = id;
            save.ArrivalTime = DateTime.Now;
            db.GenericArrivalsAndDepartures.Insert(save);                                                         
            db.Save();              
            
        }
    }

CodePudding user response:

In every one of these systems I've worked on the exit time has been nullable (able to be left blank). When we are registering an arrival, we leave the exit time blank. This can be used for queries like "how many employees have a filled-in entry time and a blank exit time?", and these are hence the employees who are at work right now. By recording the time of entry we can also minus it off the current time and see how many hours they have been at work.

Later when the employee comes and clicks the "sign out" button and gives their ID, you can search the table for records for that ID where the entry time is set and the exit time is blank; that is the record you need to update with the current time as the exit time. You also have the option then to detect that the employee didn't sign in when they entered and correct it (perhaps ask them what time they arrived?) so you should always only ever have one record with a blank exit time. Having more than one blank exit time per employee is also an error that you can detect/when they next sign in you can check if they still have an open record because they forgot to sign out last time

At the end of the week/month the sign in/out times can be used for calculating hours present and potentially the pay owed. It's probably important to have the "correcting sign in and sign out" times being supervisor-only to prevent incorrect information being registered by employees

  • Related