Example #1
0
        public List <Employee> employeeWithShortAttendence(DateTime startDate, DateTime endDate)
        {
            int days      = Convert.ToInt32((endDate.Date - startDate.Date).Days);
            int totaldays = days;

            for (int i = 0; i < days; i++)
            {
                if (startDate.DayOfWeek == DayOfWeek.Saturday || startDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    startDate  = startDate.AddDays(1);
                    totaldays -= 1;
                }
                else
                {
                    startDate = startDate.AddDays(1);
                }
            }
            int workingHours = totaldays * 8;

            List <Employee> list     = new List <Employee>();
            Employee        employee = new Employee();

            SqlDataAdapter cmd2 = new SqlDataAdapter("Select * from AttendenceRecord", DataBaseConnection.getInstance().getConnection());
            SqlDataAdapter cmd1 = new SqlDataAdapter("Select EmployeeId from EmployeeData", DataBaseConnection.getInstance().getConnection());

            DataTable table1 = new DataTable();

            cmd1.Fill(table1);

            DataTable table2 = new DataTable();

            cmd2.Fill(table2);

            int count = 0;

            for (int j = 0; j < DataBaseConnection.getInstance().CountRows("EmployeeData"); j++)
            {
                for (int k = 0; k < DataBaseConnection.getInstance().CountRows("AttendenceRecord"); k++)
                {
                    string id = "Emp-" + table2.Rows[k][table2.Columns.Count - 4].ToString();
                    if (table1.Rows[j].ToString() == id)
                    {
                        DateTime attDate = DateTime.Parse(table2.Rows[k][table2.Columns.Count - 1].ToString());
                        if (attDate >= startDate.Date && attDate <= endDate.Date)
                        {
                            DateTime logInTime  = DateTime.Parse(table2.Rows[k][table2.Columns.Count - 3].ToString());
                            DateTime logOutTime = DateTime.Parse(table2.Rows[k][table2.Columns.Count - 2].ToString());
                            int      hours      = (logOutTime - logInTime).Hours;
                            count += hours;
                        }
                    }
                }
                if (count < workingHours && count > 0)
                {
                    employee.EmployeeId = table1.Rows[j].ToString();
                    list.Add(employee);
                }
            }

            return(list);
        }
 /// <summary>
 /// On load it shows the number of employee added
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PayrollSysetem_Load(object sender, EventArgs e)
 {
     lblMarkAttendence.Text  = countEmpAtt().ToString() + " Employees have Marked";
     lblMarkAtt2.Text        = "Attendence Today";
     lblManageEmployees.Text = DataBaseConnection.getInstance().CountRows("EmployeeData") + " Employees have been Added";
 }
Example #3
0
        /// <summary>
        /// this function contain the lists of employees
        /// </summary>
        /// <returns>return the table which contain the data</returns>
        public DataTable ListOfEmployee()
        {
            DataTable table = DataBaseConnection.getInstance().ShowData("EmployeeData");

            return(table);
        }
 public PayrollSysetem()
 {
     //Connection string which connect to the database
     DataBaseConnection.getInstance().ConnectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\UsmanPC\Documents\EmployeeDB.mdf;Integrated Security=True;Connect Timeout=30";
     InitializeComponent();
 }