Пример #1
0
        private async void TapGestureRecognizer_Tapped_3(object sender, EventArgs e)
        {
            try
            {
                const int _animationTime = 20;
                await ViewAttendance.ScaleTo(1.2, _animationTime);

                await ViewAttendance.ScaleTo(1, _animationTime);

                await Navigation.PushAsync(new AttendancePage());
            }
            catch { }
        }
Пример #2
0
        private void metroButton7_Click(object sender, EventArgs e)
        {
            if (ActiveMdiChild != null)
            {
                ActiveMdiChild.Close();
            }
            ViewAttendance newMDIChild = new ViewAttendance();

            // Set the Parent Form of the Child window.
            newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();
            newMDIChild.Dock = DockStyle.Fill;
        }
Пример #3
0
        private void PopulateGrid(List <Employee> employees)
        {
            DateTime From = dateTimePicker1.Value;
            int      id   = Convert.ToInt32(comboBox4.SelectedValue);
            List <Emp_CheckInOut> emp_CheckInOuts = db.Emp_CheckInOuts.Where(a => a.CHECKTIME.Day == From.Day && a.CHECKTIME.Year == From.Year && a.CHECKTIME.Month == From.Month && a.IsAbsent != true && a.IsManual != true).ToList();

            List <ViewAttendance> viewAttendances = new List <ViewAttendance>();


            //Employee Count
            if (employees.Count > 0)
            {
                foreach (Employee emp in employees)
                {
                    ViewAttendance VW = new ViewAttendance();
                    VW.EmpFullName = emp.EmpFullName;
                    VW.Emp_Id      = emp.Emp_Id;
                    //Manual Check
                    List <Emp_CheckInOut> Emp_CheckInOutManual = db.Emp_CheckInOuts.Where(a => a.CHECKTIME.Day == From.Day && a.CHECKTIME.Year == From.Year && a.CHECKTIME.Month == From.Month && a.IsManual == true && a.IsAbsent == false && a.UserId == emp.Emp_Id).ToList();
                    List <Emp_CheckInOut> Emp_CheckInOutAbsent = db.Emp_CheckInOuts.Where(a => a.CHECKTIME.Day == From.Day && a.CHECKTIME.Year == From.Year && a.CHECKTIME.Month == From.Month && a.IsAbsent == true && a.UserId == emp.Emp_Id).ToList();

                    var Holiday  = db.Holidays.FirstOrDefault(a => a.DepartmentId == emp.Section.DepartmentId && a.From <= From && a.To >= From);
                    var LeaveDay = db.Leaves.FirstOrDefault(a => a.EmployeeId == emp.Id && a.From >= From && a.To <= From);

                    if (Emp_CheckInOutManual.Count > 0)
                    {
                        VW.Status = "Manual!";
                        var duty_Rosterformanual = db.Duty_Rosters.FirstOrDefault(a => a.Date == From && a.EmployeeId == emp.Id);
                        // Default Assign
                        if (duty_Rosterformanual == null)
                        {
                            List <DL.Duty_Roster> duty_Rosters = db.Duty_Rosters.Where(a => a.EmployeeId == emp.Id && a.Date < From).ToList();
                            if (duty_Rosters.Count > 0)
                            {
                                DateTime date = duty_Rosters.Max(a => a.Date);
                                duty_Rosterformanual = duty_Rosters.FirstOrDefault(a => a.Date == date);
                            }
                        }

                        if (duty_Rosterformanual != null)
                        {
                            VW.From = duty_Rosterformanual.Shift.From;
                            DateTime dateTime = DateTime.Now.Date + duty_Rosterformanual.Shift.To;
                            if (Emp_CheckInOutManual[0].OT > 2)
                            {
                                dateTime = dateTime.AddHours(2);
                            }
                            else
                            {
                                dateTime = dateTime.AddHours(Emp_CheckInOutManual[0].OT);
                            }

                            VW.To = dateTime.TimeOfDay;
                        }
                    }
                    else if (From.DayOfWeek.ToString() == "Friday")
                    {
                        VW.Status = "Weekend";
                    }
                    else if (Holiday != null)
                    {
                        VW.Status = "Holiday";
                    }

                    else if (LeaveDay != null)
                    {
                        VW.Status = "Leave";
                    }
                    else if (Emp_CheckInOutAbsent.Count > 0)
                    {
                        VW.Status = "Absent";
                    }
                    else
                    {
                        //EMployee CheckInOuts
                        if (emp_CheckInOuts != null)
                        {
                            var duty_Roster = db.Duty_Rosters.FirstOrDefault(a => a.Date == From && a.EmployeeId == emp.Id);
                            // Default Assign
                            if (duty_Roster == null)
                            {
                                List <DL.Duty_Roster> duty_Rosters = db.Duty_Rosters.Where(a => a.EmployeeId == emp.Id).ToList();
                                if (duty_Rosters.Count > 0)
                                {
                                    DateTime date = duty_Rosters.Max(a => a.Date);
                                    duty_Roster = duty_Rosters.FirstOrDefault(a => a.Date == date);
                                }
                            }

                            var salarySetting = db.SalarySettings.FirstOrDefault();
                            // Is Duty Roster Has
                            if (duty_Roster != null)
                            {
                                VW.Shift = duty_Roster.Shift.Name;
                                List <Emp_CheckInOut> empindividual = emp_CheckInOuts.Where(a => a.UserId == emp.Emp_Id).ToList();
                                //Employee Wise Check in out
                                if (empindividual.Count > 0)
                                {
                                    //For C Shift
                                    if (duty_Roster.Shift.IsDayToNight == true)
                                    {
                                        DateTime In  = From.Date + duty_Roster.Shift.From;
                                        DateTime Out = From.Date + duty_Roster.Shift.To;

                                        Out = Out.AddDays(1);

                                        DateTime OutCheck = Out.AddHours(2);
                                        DateTime InCheck  = In.AddHours(-2);


                                        List <Emp_CheckInOut> emp_CheckInOuts2 = db.Emp_CheckInOuts.Where(a => a.CHECKTIME.Day >= From.Day && a.CHECKTIME.Year == From.Year && a.CHECKTIME.Month == From.Month && a.CHECKTIME.Day <= From.Day + 1 && a.IsManual != true && a.IsAbsent == false).ToList();
                                        List <Emp_CheckInOut> empindividual2   = emp_CheckInOuts2.Where(a => a.UserId == emp.Emp_Id).ToList();

                                        List <Emp_CheckInOut> empIndividualforshift = empindividual2.Where(a => a.CHECKTIME >= InCheck && a.CHECKTIME <= OutCheck).ToList();

                                        //Shiftwise CheckinOut
                                        if (empIndividualforshift.Count > 0)
                                        {
                                            DateTime Min = (from d in empIndividualforshift select d.CHECKTIME).Min();
                                            DateTime Max = (from d in empIndividualforshift select d.CHECKTIME).Max();

                                            VW.From = Min.TimeOfDay;
                                            TimeSpan To = Max.TimeOfDay;
                                            //Calculation for Complience
                                            TimeSpan timeSpan = To - Out.TimeOfDay;

                                            if (timeSpan.Hours > 2)
                                            {
                                                DateTime dateTime = Out.AddHours(2);
                                                VW.To = dateTime.TimeOfDay;
                                            }
                                            else
                                            {
                                                VW.To = To;
                                            }


                                            //Status Calculation
                                            DateTime InForStatus  = In.AddMinutes(salarySetting.Time);
                                            DateTime OutForStatus = Out.AddMinutes(-1 * salarySetting.Time);
                                            if (Min == Max)
                                            {
                                                VW.Status = "Invalid";
                                            }
                                            else if (Min <= InForStatus && Max >= OutForStatus)
                                            {
                                                VW.Status = "Present";
                                            }
                                            else if (Min > InForStatus && Max >= OutForStatus)
                                            {
                                                VW.Status = "Late";
                                            }

                                            else if (Min <= InForStatus && Max < OutForStatus)
                                            {
                                                VW.Status = "Early Leave";
                                            }

                                            else if (Min > InForStatus && Max < OutForStatus)
                                            {
                                                VW.Status = "Early Leave+ Late";
                                            }
                                        }
                                        else
                                        {
                                            VW.Status = "Absent";
                                        }
                                    }
                                    else
                                    {
                                        DateTime In  = From.Date + duty_Roster.Shift.From;
                                        DateTime Out = From.Date + duty_Roster.Shift.To;


                                        DateTime OutCheck = Out.AddHours(2);
                                        DateTime InCheck  = In.AddHours(-2);

                                        List <Emp_CheckInOut> empIndividualforshift = empindividual.Where(a => a.CHECKTIME >= InCheck && a.CHECKTIME <= OutCheck).ToList();
                                        //Shift Wise Check In Out
                                        if (empIndividualforshift.Count > 0)
                                        {
                                            DateTime Min = (from d in empIndividualforshift select d.CHECKTIME).Min();
                                            DateTime Max = (from d in empIndividualforshift select d.CHECKTIME).Max();

                                            VW.From = Min.TimeOfDay;
                                            VW.To   = Max.TimeOfDay;

                                            //Status Calculation
                                            DateTime InForStatus  = In.AddMinutes(salarySetting.Time);
                                            DateTime OutForStatus = Out.AddMinutes(-1 * salarySetting.Time);
                                            if (Min == Max)
                                            {
                                                VW.Status = "Invalid";
                                            }
                                            else if (Min <= InForStatus && Max >= OutForStatus)
                                            {
                                                VW.Status = "Present";
                                            }
                                            else if (Min > InForStatus && Max >= OutForStatus)
                                            {
                                                VW.Status = "Late";
                                            }

                                            else if (Min <= InForStatus && Max < OutForStatus)
                                            {
                                                VW.Status = "Early Leave";
                                            }

                                            else if (Min > InForStatus && Max < OutForStatus)
                                            {
                                                VW.Status = "Early Leave+ Late";
                                            }
                                        }
                                        else
                                        {
                                            VW.Status = "Absent";
                                        }
                                    }
                                }
                                else
                                {
                                    VW.Status = "Absent";
                                }
                            }
                            else
                            {
                                VW.Status = "Duty Roster Not Assign";
                            }
                        }
                        else
                        {
                            VW.Status = "Absent";
                        }
                    }

                    viewAttendances.Add(VW);
                }
            }
            viewAttendanceDataGridView.DataSource = viewAttendances.ToList();
        }