Beispiel #1
0
    protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        string holidayDescription = string.Empty;

        if (DateTime.Compare(e.TimeSlot.Start.Date, DateTime.Now.Date) == 0)
        {
            e.TimeSlot.CssClass = "RadSchedulerToday";
        }
        else if (e.TimeSlot.Start.Date.DayOfWeek == DayOfWeek.Sunday)
        {
            e.TimeSlot.CssClass = "RadSchedulerHoliday";
        }
        else if (EPublicHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date))
        {
            e.TimeSlot.CssClass = "RadSchedulerHoliday";
            //Label holidayLabel = new Label();
            //holidayLabel.Text = holidayDescription;
            //holidayLabel.ForeColor = System.Drawing.Color.Red;
            ////holidayLabel.CssClass = "FloatRight";
            ////e.TimeSlot.Control.Controls.AddAt(1, holidayLabel);
            //e.TimeSlot.Control.Controls[0].Controls.AddAt(1, holidayLabel);
        }
        else if (EStatutoryHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date))
        {
            e.TimeSlot.CssClass = "RadSchedulerHoliday";
            //Label holidayLabel = new Label();
            //holidayLabel.Text = holidayDescription;
            //holidayLabel.ForeColor = System.Drawing.Color.Red;
            ////holidayLabel.CssClass = "FloatRight";
            ////e.TimeSlot.Control.Controls.AddAt(1, holidayLabel);
            //e.TimeSlot.Control.Controls[0].Controls.AddAt(1, holidayLabel);
        }
    }
Beispiel #2
0
 protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
 {
     if (DateTime.Compare(e.TimeSlot.Start.Date, DateTime.Now.Date) == 0)
     {
         e.TimeSlot.CssClass = "RadSchedulerToday";
     }
     else if (e.TimeSlot.Start.Date.DayOfWeek == DayOfWeek.Sunday)
     {
         e.TimeSlot.CssClass = "RadSchedulerHoliday";
     }
     else if (EPublicHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date))
     {
         e.TimeSlot.CssClass = "RadSchedulerHoliday";
     }
     else if (EStatutoryHoliday.IsHoliday(dbConn, e.TimeSlot.Start.Date))
     {
         e.TimeSlot.CssClass = "RadSchedulerHoliday";
     }
 }
        private static DataRow CreateWorkingSummaryTemplateRow(DatabaseConnection dbConn, DataTable dataTable, Hashtable hierarchyLevelHashTable, EEmpPersonalInfo empInfo, DateTime PeriodFrom, DateTime PeriodTo, EWorkHourPattern currentWorkHourPattern)
        {
            double restDayCount                    = 0;
            double statutoryHolidayCount           = 0;
            double restDayTaken                    = 0;
            double statutoryHolidayTaken           = 0;
            double workHourPatternWorkingDaysCount = 0;
            double workHourPatternLunchTimeCount   = 0;
            double workHourPatternWorkingHourCount = 0;
            double totalWorkingDays                = 0;
            double totalWorkingHours               = 0;
            double totalLunchMins                  = 0;
            double totalWorkingHoursExpected       = 0;
            double totalLateMins                   = 0;
            double totalEarlyLeaveMins             = 0;
            double totalOvertimeMins               = 0;
            double totalLeaveApplicationDayTaken   = 0;

            EEmpTermination empTermination = EEmpTermination.GetObjectByEmpID(dbConn, empInfo.EmpID);

            bool hasStatutoryHolidayRosterCode = false;
            //  Check if Roster Code List contains Statutory Holiday Roster Code
            ArrayList rosterCodeList = ERosterCode.db.select(dbConn, new DBFilter());

            foreach (ERosterCode rosterCode in rosterCodeList)
            {
                if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY))
                {
                    hasStatutoryHolidayRosterCode = true;
                    break;
                }
            }

            if (currentWorkHourPattern != null)
            {
                for (DateTime asOfDate = PeriodFrom; asOfDate <= PeriodTo; asOfDate = asOfDate.AddDays(1))
                {
                    if (EStatutoryHoliday.IsHoliday(dbConn, asOfDate))// && currentWorkHourPattern.WorkHourPatternUseStatutoryHolidayTable)
                    {
                        statutoryHolidayCount++;
                    }
                    //rest day must be integer and rest within 24 hour
                    restDayCount += (1 - currentWorkHourPattern.GetDefaultDayUnit(dbConn, asOfDate, false, false));

                    double workDayUnit   = 0;
                    double workHourUnit  = 0;
                    double LunchTimeUnit = 0;
                    if (empInfo.EmpDateOfJoin <= asOfDate)
                    {
                        workDayUnit   = currentWorkHourPattern.GetDefaultDayUnit(dbConn, asOfDate, false, false);
                        LunchTimeUnit = currentWorkHourPattern.GetDefaultLunch(dbConn, asOfDate);
                        workHourUnit  = currentWorkHourPattern.GetDefaultWorkHour(dbConn, asOfDate);
                        DBFilter leaveAppFilter = new DBFilter();
                        leaveAppFilter.add(new Match("EmpID", empInfo.EmpID));
                        leaveAppFilter.add(new Match("LeaveAppDateFrom", "<=", asOfDate));
                        leaveAppFilter.add(new Match("LeaveAppDateTo", ">=", asOfDate));
                        leaveAppFilter.add(new Match("LeaveAppNoPayProcess", false));

                        ArrayList leaveAppList = ELeaveApplication.db.select(dbConn, leaveAppFilter);
                        foreach (ELeaveApplication leaveApp in leaveAppList)
                        {
                            if (leaveApp.LeaveAppDateFrom.Equals(leaveApp.LeaveAppDateTo))
                            {
                                workDayUnit -= leaveApp.LeaveAppDays;
                                double currentDayDefaultDayUnit = currentWorkHourPattern.GetDefaultDayUnit(dbConn, asOfDate, false, false);
                                if (currentDayDefaultDayUnit * leaveApp.LeaveAppDays > 0)
                                {
                                    workHourUnit -= currentWorkHourPattern.GetDefaultWorkHour(dbConn, asOfDate) / currentDayDefaultDayUnit * leaveApp.LeaveAppDays;
                                }
                            }
                            else
                            {
                                workDayUnit   = 0;
                                workHourUnit  = 0;
                                LunchTimeUnit = 0;
                            }
                        }
                        if (workDayUnit < 0)
                        {
                            workDayUnit = 0;
                        }
                        if (workHourUnit < 0)
                        {
                            workHourUnit = 0;
                        }
                        if (workDayUnit < 1)
                        {
                            LunchTimeUnit = 0;
                        }
                        if (empTermination != null)
                        {
                            if (empTermination.EmpTermLastDate < asOfDate)
                            {
                                workDayUnit   = 0;
                                workHourUnit  = 0;
                                LunchTimeUnit = 0;
                            }
                        }
                    }
                    workHourPatternWorkingDaysCount += workDayUnit;
                    workHourPatternWorkingHourCount += workHourUnit;
                    workHourPatternLunchTimeCount   += LunchTimeUnit;
                }
                DBFilter leaveAppTakenFilter = new DBFilter();
                leaveAppTakenFilter.add(new Match("EmpID", empInfo.EmpID));
                leaveAppTakenFilter.add(new Match("LeaveAppDateFrom", "<=", PeriodTo));
                leaveAppTakenFilter.add(new Match("LeaveAppDateTo", ">=", PeriodFrom));
                leaveAppTakenFilter.add(new Match("LeaveAppNoPayProcess", false));
                ArrayList leaveAppTakenList = ELeaveApplication.db.select(dbConn, leaveAppTakenFilter);
                foreach (ELeaveApplication leaveApp in leaveAppTakenList)
                {
                    totalLeaveApplicationDayTaken += leaveApp.LeaveAppDays;
                }
            }
            DBFilter attendanceRecordFilter = new DBFilter();

            attendanceRecordFilter.add(new Match("EmpID", empInfo.EmpID));
            attendanceRecordFilter.add(new Match("AttendanceRecordDate", ">=", PeriodFrom));
            attendanceRecordFilter.add(new Match("AttendanceRecordDate", "<=", PeriodTo));
            attendanceRecordFilter.add("AttendanceRecordDate", true);
            ArrayList attendanceRecordList = EAttendanceRecord.db.select(dbConn, attendanceRecordFilter);

            foreach (EAttendanceRecord attendanceRecord in attendanceRecordList)
            {
                ERosterCode rosterCode = new ERosterCode();
                rosterCode.RosterCodeID = attendanceRecord.RosterCodeID;
                if (ERosterCode.db.select(dbConn, rosterCode))
                {
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_RESTDAY))
                    {
                        restDayTaken++;
                    }
                    if (rosterCode.RosterCodeType.Equals(ERosterCode.ROSTERTYPE_CODE_STATUTORYHOLIDAY))
                    {
                        statutoryHolidayTaken++;
                    }
                }
                double workingHours = attendanceRecord.TotalWorkingHourTimeSpan(dbConn).TotalHours;
                if (workingHours <= 0)
                {
                    workingHours = attendanceRecord.AttendanceRecordActualWorkingHour + Convert.ToDouble(attendanceRecord.AttendanceRecordActualEarlyLeaveMins - attendanceRecord.AttendanceRecordActualLateMins + attendanceRecord.AttendanceRecordActualOvertimeMins) / 60.0;
                }

                totalWorkingDays          += attendanceRecord.AttendanceRecordActualWorkingDay;
                totalWorkingHours         += workingHours;
                totalWorkingHoursExpected += attendanceRecord.AttendanceRecordActualWorkingHour;
                totalLateMins             += attendanceRecord.AttendanceRecordActualLateMins;
                totalEarlyLeaveMins       += attendanceRecord.AttendanceRecordActualEarlyLeaveMins;
                totalOvertimeMins         += attendanceRecord.AttendanceRecordActualOvertimeMins;
                totalLunchMins            += attendanceRecord.AttendanceRecordActualLunchTimeMins;
            }
            if (totalWorkingDays <= 0 && totalWorkingHours <= 0 && totalLunchMins <= 0 && empInfo.EmpDateOfJoin <= PeriodFrom)
            {
                totalWorkingDays  = workHourPatternWorkingDaysCount;
                totalWorkingHours = workHourPatternWorkingHourCount;
                totalLunchMins    = workHourPatternLunchTimeCount * 60;
            }
            DataRow row = dataTable.NewRow();

            row[FIELD_EMP_NO]  = empInfo.EmpNo;
            row["EnglishName"] = empInfo.EmpEngFullName;
            row["ChineseName"] = empInfo.EmpChiFullName;

            DBFilter empPosFilter = new DBFilter();

            EEmpPositionInfo empPos = AppUtils.GetLastPositionInfo(dbConn, PeriodTo, empInfo.EmpID);

            if (empPos != null)
            {
                ECompany company = new ECompany();
                company.CompanyID = empPos.CompanyID;
                if (ECompany.db.select(dbConn, company))
                {
                    row["Company"] = company.CompanyCode;
                }
                DBFilter empHierarchyFilter = new DBFilter();
                empHierarchyFilter.add(new Match("EmpPosID", empPos.EmpPosID));
                ArrayList empHierarchyList = EEmpHierarchy.db.select(dbConn, empHierarchyFilter);
                foreach (EEmpHierarchy empHierarchy in empHierarchyList)
                {
                    EHierarchyLevel hierarchyLevel = (EHierarchyLevel)hierarchyLevelHashTable[empHierarchy.HLevelID];
                    if (hierarchyLevel != null)
                    {
                        EHierarchyElement hierarchyElement = new EHierarchyElement();
                        hierarchyElement.HElementID = empHierarchy.HElementID;
                        if (EHierarchyElement.db.select(dbConn, hierarchyElement))
                        {
                            row[hierarchyLevel.HLevelDesc] = hierarchyElement.HElementCode;
                        }
                    }
                }
            }

            row[FIELD_AS_OF_DATE]        = PeriodTo;
            row[FIELD_REST_DAY_ENTITLED] = restDayCount - statutoryHolidayCount;
            if (hasStatutoryHolidayRosterCode)
            {
                row[FIELD_REST_DAY_TAKEN] = restDayTaken;
            }
            else
            {
                row[FIELD_REST_DAY_TAKEN] = restDayTaken > statutoryHolidayCount ? restDayTaken - statutoryHolidayCount : 0;
            }
            row[FIELD_TOTAL_WORKING_DAYS]                  = totalWorkingDays;
            row[FIELD_TOTAL_WORKING_HOURS]                 = totalWorkingHours;
            row[FIELD_TOTAL_LUNCH_HOURS]                   = totalLunchMins / 60.0;
            row[FIELD_EXTRA_TOTAL_STATUTORY_HOLIDAY]       = statutoryHolidayCount;
            row[FIELD_EXTRA_TOTAL_LEAVE_APPLICATION_TAKEN] = totalLeaveApplicationDayTaken;
            row[FIELD_EXTRA_TOTAL_WORKING_HOURS_EXPECTED]  = totalWorkingHoursExpected;
            row[FIELD_EXTRA_TOTAL_LATE_MINS]               = totalLateMins;
            row[FIELD_EXTRA_TOTAL_EARLYLEAVE_MINS]         = totalEarlyLeaveMins;
            row[FIELD_EXTRA_TOTAL_OVERTIME_MINS]           = totalOvertimeMins;
            dataTable.Rows.Add(row);
            return(row);
        }