Exemple #1
0
        private EmployeeAttendanceSummaryModel PrepareAttendanceSummeryModel(EmployeeAttendanceSummary attendanceSummary)
        {
            EmployeeAttendanceSummaryModel attendanceSummaryModel = new EmployeeAttendanceSummaryModel();

            attendanceSummaryModel.Year         = attendanceSummary.Year;
            attendanceSummaryModel.Month        = attendanceSummary.Month;
            attendanceSummaryModel.EmployeeId   = attendanceSummary.EmployeeId;
            attendanceSummaryModel.EmployeeName = attendanceSummary.Employee != null ? attendanceSummary.Employee.FullName : "";

            attendanceSummaryModel.SchoolId   = attendanceSummary.SchoolId;
            attendanceSummaryModel.SchoolName = attendanceSummary.School != null ? attendanceSummary.School.Name : "";

            int tp = 0;
            int ta = 0;
            int tl = 0;

            attendanceSummaryModel.D1  = SumupAttendanceSummeryField(attendanceSummary.D1, attendanceSummary.Year, attendanceSummary.Month, 1, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D2  = SumupAttendanceSummeryField(attendanceSummary.D2, attendanceSummary.Year, attendanceSummary.Month, 2, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D3  = SumupAttendanceSummeryField(attendanceSummary.D3, attendanceSummary.Year, attendanceSummary.Month, 3, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D4  = SumupAttendanceSummeryField(attendanceSummary.D4, attendanceSummary.Year, attendanceSummary.Month, 4, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D5  = SumupAttendanceSummeryField(attendanceSummary.D5, attendanceSummary.Year, attendanceSummary.Month, 5, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D6  = SumupAttendanceSummeryField(attendanceSummary.D6, attendanceSummary.Year, attendanceSummary.Month, 6, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D7  = SumupAttendanceSummeryField(attendanceSummary.D7, attendanceSummary.Year, attendanceSummary.Month, 7, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D8  = SumupAttendanceSummeryField(attendanceSummary.D8, attendanceSummary.Year, attendanceSummary.Month, 8, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D9  = SumupAttendanceSummeryField(attendanceSummary.D9, attendanceSummary.Year, attendanceSummary.Month, 9, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D10 = SumupAttendanceSummeryField(attendanceSummary.D10, attendanceSummary.Year, attendanceSummary.Month, 10, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D11 = SumupAttendanceSummeryField(attendanceSummary.D11, attendanceSummary.Year, attendanceSummary.Month, 11, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D12 = SumupAttendanceSummeryField(attendanceSummary.D12, attendanceSummary.Year, attendanceSummary.Month, 12, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D13 = SumupAttendanceSummeryField(attendanceSummary.D13, attendanceSummary.Year, attendanceSummary.Month, 13, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D14 = SumupAttendanceSummeryField(attendanceSummary.D14, attendanceSummary.Year, attendanceSummary.Month, 14, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D15 = SumupAttendanceSummeryField(attendanceSummary.D15, attendanceSummary.Year, attendanceSummary.Month, 15, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D16 = SumupAttendanceSummeryField(attendanceSummary.D16, attendanceSummary.Year, attendanceSummary.Month, 16, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D17 = SumupAttendanceSummeryField(attendanceSummary.D17, attendanceSummary.Year, attendanceSummary.Month, 17, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D18 = SumupAttendanceSummeryField(attendanceSummary.D18, attendanceSummary.Year, attendanceSummary.Month, 18, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D19 = SumupAttendanceSummeryField(attendanceSummary.D19, attendanceSummary.Year, attendanceSummary.Month, 19, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D20 = SumupAttendanceSummeryField(attendanceSummary.D20, attendanceSummary.Year, attendanceSummary.Month, 20, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D21 = SumupAttendanceSummeryField(attendanceSummary.D21, attendanceSummary.Year, attendanceSummary.Month, 21, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D22 = SumupAttendanceSummeryField(attendanceSummary.D22, attendanceSummary.Year, attendanceSummary.Month, 22, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D23 = SumupAttendanceSummeryField(attendanceSummary.D23, attendanceSummary.Year, attendanceSummary.Month, 23, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D24 = SumupAttendanceSummeryField(attendanceSummary.D24, attendanceSummary.Year, attendanceSummary.Month, 24, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D25 = SumupAttendanceSummeryField(attendanceSummary.D25, attendanceSummary.Year, attendanceSummary.Month, 25, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D26 = SumupAttendanceSummeryField(attendanceSummary.D26, attendanceSummary.Year, attendanceSummary.Month, 26, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D27 = SumupAttendanceSummeryField(attendanceSummary.D27, attendanceSummary.Year, attendanceSummary.Month, 27, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D28 = SumupAttendanceSummeryField(attendanceSummary.D28, attendanceSummary.Year, attendanceSummary.Month, 28, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D29 = SumupAttendanceSummeryField(attendanceSummary.D29, attendanceSummary.Year, attendanceSummary.Month, 29, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D30 = SumupAttendanceSummeryField(attendanceSummary.D30, attendanceSummary.Year, attendanceSummary.Month, 30, ref tp, ref ta, ref tl);
            attendanceSummaryModel.D31 = SumupAttendanceSummeryField(attendanceSummary.D31, attendanceSummary.Year, attendanceSummary.Month, 31, ref tp, ref ta, ref tl);

            attendanceSummaryModel.TP = tp;
            attendanceSummaryModel.TA = ta;
            attendanceSummaryModel.TL = tl;
            attendanceSummaryModel.PP = Math.Round(ta != 0 ? (float)100 * tp / (tp + ta) : 100.00, 2);

            return(attendanceSummaryModel);
        }
Exemple #2
0
        public bool UpdateEmployeeAttendanceSummary(EmployeeAttendanceSummary employeeAttendanceSummary)
        {
            bool isSuccess = true;

            try
            {
                employeeAttendanceSummaryRepository.Update(employeeAttendanceSummary);
                this.SaveRecord();
                ServiceUtil <EmployeeAttendanceSummary> .WriteActionLog(employeeAttendanceSummary.Id, ENUMOperation.UPDATE, employeeAttendanceSummary);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in updating EmployeeAttendanceSummary", ex);
            }
            return(isSuccess);
        }
Exemple #3
0
        public bool InsertEmployeeAttendanceSummary(int empId, int year, int month, int day, string flag)
        {
            bool isSuccess = false;

            if (!CheckIsExist(empId, year, month))
            {
                var attendanceSummary = new EmployeeAttendanceSummary();
                attendanceSummary.EmployeeId = empId;
                attendanceSummary.Year       = year;
                attendanceSummary.Month      = (short)month;
                switch (day)
                {
                case 1:
                    attendanceSummary.D1 = flag;
                    break;

                case 2:
                    attendanceSummary.D2 = flag;
                    break;

                case 3:
                    attendanceSummary.D3 = flag;
                    break;

                case 4:
                    attendanceSummary.D4 = flag;
                    break;

                case 5:
                    attendanceSummary.D5 = flag;
                    break;

                case 6:
                    attendanceSummary.D6 = flag;
                    break;

                case 7:
                    attendanceSummary.D7 = flag;
                    break;

                case 8:
                    attendanceSummary.D8 = flag;
                    break;

                case 9:
                    attendanceSummary.D9 = flag;
                    break;

                case 10:
                    attendanceSummary.D10 = flag;
                    break;

                case 11:
                    attendanceSummary.D11 = flag;
                    break;

                case 12:
                    attendanceSummary.D12 = flag;
                    break;

                case 13:
                    attendanceSummary.D13 = flag;
                    break;

                case 14:
                    attendanceSummary.D14 = flag;
                    break;

                case 15:
                    attendanceSummary.D15 = flag;
                    break;

                case 16:
                    attendanceSummary.D16 = flag;
                    break;

                case 17:
                    attendanceSummary.D17 = flag;
                    break;

                case 18:
                    attendanceSummary.D18 = flag;
                    break;

                case 19:
                    attendanceSummary.D19 = flag;
                    break;

                case 20:
                    attendanceSummary.D20 = flag;
                    break;

                case 21:
                    attendanceSummary.D21 = flag;
                    break;

                case 22:
                    attendanceSummary.D22 = flag;
                    break;

                case 23:
                    attendanceSummary.D23 = flag;
                    break;

                case 24:
                    attendanceSummary.D24 = flag;
                    break;

                case 25:
                    attendanceSummary.D25 = flag;
                    break;

                case 26:
                    attendanceSummary.D26 = flag;
                    break;

                case 27:
                    attendanceSummary.D27 = flag;
                    break;

                case 28:
                    attendanceSummary.D28 = flag;
                    break;

                case 29:
                    attendanceSummary.D29 = flag;
                    break;

                case 30:
                    attendanceSummary.D30 = flag;
                    break;

                case 31:
                    attendanceSummary.D31 = flag;
                    break;
                }

                isSuccess = CreateEmployeeAttendanceSummary(attendanceSummary);
            }
            else
            {
                var summary = GetEmployeeAttendanceSummary(empId, year, month);
                if (summary != null)
                {
                    switch (day)
                    {
                    case 1:
                        summary.D1 = flag;
                        break;

                    case 2:
                        summary.D2 = flag;
                        break;

                    case 3:
                        summary.D3 = flag;
                        break;

                    case 4:
                        summary.D4 = flag;
                        break;

                    case 5:
                        summary.D5 = flag;
                        break;

                    case 6:
                        summary.D6 = flag;
                        break;

                    case 7:
                        summary.D7 = flag;
                        break;

                    case 8:
                        summary.D8 = flag;
                        break;

                    case 9:
                        summary.D9 = flag;
                        break;

                    case 10:
                        summary.D10 = flag;
                        break;

                    case 11:
                        summary.D11 = flag;
                        break;

                    case 12:
                        summary.D12 = flag;
                        break;

                    case 13:
                        summary.D13 = flag;
                        break;

                    case 14:
                        summary.D14 = flag;
                        break;

                    case 15:
                        summary.D15 = flag;
                        break;

                    case 16:
                        summary.D16 = flag;
                        break;

                    case 17:
                        summary.D17 = flag;
                        break;

                    case 18:
                        summary.D18 = flag;
                        break;

                    case 19:
                        summary.D19 = flag;
                        break;

                    case 20:
                        summary.D20 = flag;
                        break;

                    case 21:
                        summary.D21 = flag;
                        break;

                    case 22:
                        summary.D22 = flag;
                        break;

                    case 23:
                        summary.D23 = flag;
                        break;

                    case 24:
                        summary.D24 = flag;
                        break;

                    case 25:
                        summary.D25 = flag;
                        break;

                    case 26:
                        summary.D26 = flag;
                        break;

                    case 27:
                        summary.D27 = flag;
                        break;

                    case 28:
                        summary.D28 = flag;
                        break;

                    case 29:
                        summary.D29 = flag;
                        break;

                    case 30:
                        summary.D30 = flag;
                        break;

                    case 31:
                        summary.D31 = flag;
                        break;
                    }

                    isSuccess = UpdateEmployeeAttendanceSummary(summary);
                }
            }

            return(isSuccess);
        }
Exemple #4
0
        public bool InsertEmployeeAttendanceSummary(int empId, DateTime?fromDate, DateTime?toDate, string flag)
        {
            bool isSuccess = false;

            if (fromDate == null || toDate == null)
            {
                return(false);
            }
            for (DateTime date = fromDate.Value.Date; date <= toDate.Value.Date; date = date.AddDays(1))
            {
                if (!CheckIsExist(empId, date.Year, date.Month))
                {
                    var attendanceSummary = new EmployeeAttendanceSummary();
                    attendanceSummary.EmployeeId = empId;
                    attendanceSummary.Year       = date.Year;
                    attendanceSummary.Month      = (short)date.Month;
                    switch (date.Day)
                    {
                    case 1:
                        attendanceSummary.D1 = flag;
                        break;

                    case 2:
                        attendanceSummary.D2 = flag;
                        break;

                    case 3:
                        attendanceSummary.D3 = flag;
                        break;

                    case 4:
                        attendanceSummary.D4 = flag;
                        break;

                    case 5:
                        attendanceSummary.D5 = flag;
                        break;

                    case 6:
                        attendanceSummary.D6 = flag;
                        break;

                    case 7:
                        attendanceSummary.D7 = flag;
                        break;

                    case 8:
                        attendanceSummary.D8 = flag;
                        break;

                    case 9:
                        attendanceSummary.D9 = flag;
                        break;

                    case 10:
                        attendanceSummary.D10 = flag;
                        break;

                    case 11:
                        attendanceSummary.D11 = flag;
                        break;

                    case 12:
                        attendanceSummary.D12 = flag;
                        break;

                    case 13:
                        attendanceSummary.D13 = flag;
                        break;

                    case 14:
                        attendanceSummary.D14 = flag;
                        break;

                    case 15:
                        attendanceSummary.D15 = flag;
                        break;

                    case 16:
                        attendanceSummary.D16 = flag;
                        break;

                    case 17:
                        attendanceSummary.D17 = flag;
                        break;

                    case 18:
                        attendanceSummary.D18 = flag;
                        break;

                    case 19:
                        attendanceSummary.D19 = flag;
                        break;

                    case 20:
                        attendanceSummary.D20 = flag;
                        break;

                    case 21:
                        attendanceSummary.D21 = flag;
                        break;

                    case 22:
                        attendanceSummary.D22 = flag;
                        break;

                    case 23:
                        attendanceSummary.D23 = flag;
                        break;

                    case 24:
                        attendanceSummary.D24 = flag;
                        break;

                    case 25:
                        attendanceSummary.D25 = flag;
                        break;

                    case 26:
                        attendanceSummary.D26 = flag;
                        break;

                    case 27:
                        attendanceSummary.D27 = flag;
                        break;

                    case 28:
                        attendanceSummary.D28 = flag;
                        break;

                    case 29:
                        attendanceSummary.D29 = flag;
                        break;

                    case 30:
                        attendanceSummary.D30 = flag;
                        break;

                    case 31:
                        attendanceSummary.D31 = flag;
                        break;
                    }

                    isSuccess = CreateEmployeeAttendanceSummary(attendanceSummary);
                }
                else
                {
                    var summary = GetEmployeeAttendanceSummary(empId, date.Year, date.Month);
                    if (summary != null)
                    {
                        switch (date.Day)
                        {
                        case 1:
                            summary.D1 = flag;
                            break;

                        case 2:
                            summary.D2 = flag;
                            break;

                        case 3:
                            summary.D3 = flag;
                            break;

                        case 4:
                            summary.D4 = flag;
                            break;

                        case 5:
                            summary.D5 = flag;
                            break;

                        case 6:
                            summary.D6 = flag;
                            break;

                        case 7:
                            summary.D7 = flag;
                            break;

                        case 8:
                            summary.D8 = flag;
                            break;

                        case 9:
                            summary.D9 = flag;
                            break;

                        case 10:
                            summary.D10 = flag;
                            break;

                        case 11:
                            summary.D11 = flag;
                            break;

                        case 12:
                            summary.D12 = flag;
                            break;

                        case 13:
                            summary.D13 = flag;
                            break;

                        case 14:
                            summary.D14 = flag;
                            break;

                        case 15:
                            summary.D15 = flag;
                            break;

                        case 16:
                            summary.D16 = flag;
                            break;

                        case 17:
                            summary.D17 = flag;
                            break;

                        case 18:
                            summary.D18 = flag;
                            break;

                        case 19:
                            summary.D19 = flag;
                            break;

                        case 20:
                            summary.D20 = flag;
                            break;

                        case 21:
                            summary.D21 = flag;
                            break;

                        case 22:
                            summary.D22 = flag;
                            break;

                        case 23:
                            summary.D23 = flag;
                            break;

                        case 24:
                            summary.D24 = flag;
                            break;

                        case 25:
                            summary.D25 = flag;
                            break;

                        case 26:
                            summary.D26 = flag;
                            break;

                        case 27:
                            summary.D27 = flag;
                            break;

                        case 28:
                            summary.D28 = flag;
                            break;

                        case 29:
                            summary.D29 = flag;
                            break;

                        case 30:
                            summary.D30 = flag;
                            break;

                        case 31:
                            summary.D31 = flag;
                            break;
                        }

                        isSuccess = UpdateEmployeeAttendanceSummary(summary);
                    }
                }
            }
            return(isSuccess);
        }
Exemple #5
0
        private int CountDateAttendance(EmployeeAttendanceSummary attendanceSummary, int today, string flag)
        {
            switch (today)
            {
            case 1:
                return(attendanceSummary.D1 == flag ? 1 : 0);

            case 2:
                return(attendanceSummary.D2 == flag ? 1 : 0);

            case 3:
                return(attendanceSummary.D3 == flag ? 1 : 0);

            case 4:
                return(attendanceSummary.D4 == flag ? 1 : 0);

            case 5:
                return(attendanceSummary.D5 == flag ? 1 : 0);

            case 6:
                return(attendanceSummary.D6 == flag ? 1 : 0);

            case 7:
                return(attendanceSummary.D7 == flag ? 1 : 0);

            case 8:
                return(attendanceSummary.D8 == flag ? 1 : 0);

            case 9:
                return(attendanceSummary.D9 == flag ? 1 : 0);

            case 10:
                return(attendanceSummary.D10 == flag ? 1 : 0);

            case 11:
                return(attendanceSummary.D11 == flag ? 1 : 0);

            case 12:
                return(attendanceSummary.D12 == flag ? 1 : 0);

            case 13:
                return(attendanceSummary.D13 == flag ? 1 : 0);

            case 14:
                return(attendanceSummary.D14 == flag ? 1 : 0);

            case 15:
                return(attendanceSummary.D15 == flag ? 1 : 0);

            case 16:
                return(attendanceSummary.D16 == flag ? 1 : 0);

            case 17:
                return(attendanceSummary.D17 == flag ? 1 : 0);

            case 18:
                return(attendanceSummary.D18 == flag ? 1 : 0);

            case 19:
                return(attendanceSummary.D19 == flag ? 1 : 0);

            case 20:
                return(attendanceSummary.D20 == flag ? 1 : 0);

            case 21:
                return(attendanceSummary.D21 == flag ? 1 : 0);

            case 22:
                return(attendanceSummary.D22 == flag ? 1 : 0);

            case 23:
                return(attendanceSummary.D23 == flag ? 1 : 0);

            case 24:
                return(attendanceSummary.D24 == flag ? 1 : 0);

            case 25:
                return(attendanceSummary.D25 == flag ? 1 : 0);

            case 26:
                return(attendanceSummary.D26 == flag ? 1 : 0);

            case 27:
                return(attendanceSummary.D27 == flag ? 1 : 0);

            case 28:
                return(attendanceSummary.D28 == flag ? 1 : 0);

            case 29:
                return(attendanceSummary.D29 == flag ? 1 : 0);

            case 30:
                return(attendanceSummary.D30 == flag ? 1 : 0);

            case 31:
                return(attendanceSummary.D31 == flag ? 1 : 0);

            default:
                return(0);
            }
        }