Beispiel #1
0
        private void gridViewLeaveDayDetail_ShowingEditor(object sender, CancelEventArgs e)
        {
            LeaveApplicationDayDetail dsRow = (LeaveApplicationDayDetail)gridViewLeaveDayDetail.GetFocusedRow();

            if (dsRow == null)
            {
                return;
            }
            if (dsRow.LeaveDayOffType == eLeaveDayOffType.WeekEnd || dsRow.LeaveDayOffType == eLeaveDayOffType.Holiday || dsRow.LeaveDayOffType == eLeaveDayOffType.Absent)
            {
                e.Cancel = true;
            }
        }
Beispiel #2
0
        void LoadDayDetail()
        {
            leaveApplicationDayDetailBindingSource.Clear();
            if (lookupEmployee.EditValue == null || lookupLeaveType.EditValue == null || deDateFrom.EditValue == null || deDateTo.EditValue == null || deDateTo.DateTime < deDateFrom.DateTime)
            {
                return;
            }
            if (SelectedEmployee == null || SelectedLeaveType == null)
            {
                return;
            }

            var Location = (SelectedEmployee.tblEmployeeServiceDetail != null ? LocationDALObj.GetLatestWeekendSetting(SelectedEmployee.tblEmployeeServiceDetail.LocationID) : null);

            List <HolidayLookupListModel> holidays = null;

            if (!SelectedLeaveType.IncludePublicHoliday)
            {
                holidays = HolidayDALObj.GetLookupList(deDateFrom.DateTime, deDateTo.DateTime);
            }

            List <DateTime> RestDays = null;

            if ((Model.Employee.eTAWeekendtype)SelectedEmployee.TAWeekendType == eTAWeekendtype.RestDay)
            {
                RestDays = (new EmployeeRestDayDAL()).GetRestDates(SelectedEmployee.EmployeeID, deDateFrom.DateTime, deDateTo.DateTime);
            }

            decimal remainingLeaves = LeaveBalance;

            for (DateTime date = deDateFrom.DateTime; date <= deDateTo.DateTime; date = date.AddDays(1))
            {
                HolidayLookupListModel holiday = null;
                if (holidays != null)
                {
                    holiday = holidays.FirstOrDefault(r => r.DateFrom >= date && r.DateTo <= date);
                }

                LeaveApplicationDayDetail newDay = new LeaveApplicationDayDetail()
                {
                    LeaveDate          = date,
                    LeaveDayOffType    = (holiday != null ? eLeaveDayOffType.Holiday : eLeaveDayOffType.FullDay),
                    IsHolidayOrWeekEnd = (holiday != null),
                    Descr = (holiday != null ? holiday.HolidayName : ""),
                };

                if (Location != null && !SelectedLeaveType.IncludeWeekend)
                {
                    if ((Model.Employee.eTAWeekendtype)SelectedEmployee.TAWeekendType == eTAWeekendtype.Weekend)
                    {
                        Model.Settings.eWeekDayType WeekendType =
                            (date.Date.DayOfWeek == DayOfWeek.Monday ? Location.Monday :
                             (date.Date.DayOfWeek == DayOfWeek.Tuesday ? Location.Tuesday :
                              (date.Date.DayOfWeek == DayOfWeek.Wednesday ? Location.Wednesday :
                               (date.Date.DayOfWeek == DayOfWeek.Thursday ? Location.Thursday :
                                (date.Date.DayOfWeek == DayOfWeek.Friday ? Location.Friday :
                                 (date.Date.DayOfWeek == DayOfWeek.Saturday ? Location.Saturday :
                                  (date.Date.DayOfWeek == DayOfWeek.Sunday ? Location.Sunday : Model.Settings.eWeekDayType.WorkingDay)))))));

                        if (WeekendType == Model.Settings.eWeekDayType.Weekend || WeekendType == Model.Settings.eWeekDayType.HalfDay)
                        {
                            newDay.IsHolidayOrWeekEnd = true;
                            newDay.Descr           = (!String.IsNullOrWhiteSpace(newDay.Descr) ? newDay.Descr + ", " : "") + "Weekend";
                            newDay.LeaveDayOffType = (WeekendType == Model.Settings.eWeekDayType.HalfDay ? eLeaveDayOffType.SecondHalf : eLeaveDayOffType.WeekEnd);
                        }
                    }
                    else // Rest Day
                    {
                        if (RestDays.Any(r => r == date.Date))
                        {
                            newDay.IsHolidayOrWeekEnd = true;
                            newDay.Descr           = (!String.IsNullOrWhiteSpace(newDay.Descr) ? newDay.Descr + ", " : "") + "Rest day";
                            newDay.LeaveDayOffType = eLeaveDayOffType.WeekEnd;
                        }
                    }
                }

                decimal leavedays = (newDay.LeaveDayOffType == eLeaveDayOffType.FullDay ? 1 : (newDay.LeaveDayOffType == eLeaveDayOffType.FirstHalf || newDay.LeaveDayOffType == eLeaveDayOffType.SecondHalf ? 0.5M : 0));

                if (remainingLeaves < leavedays && SelectedEmployee.TANegativeLeave == (byte)eTANegativeLeave.NotAllowed &&
                    newDay.LeaveDayOffType == eLeaveDayOffType.FullDay &&
                    remainingLeaves >= leavedays - 0.5M)
                {
                    newDay.LeaveDayOffType = eLeaveDayOffType.FirstHalf;
                    leavedays = 0.5M;
                }

                if (remainingLeaves < leavedays && SelectedEmployee.TANegativeLeave == (byte)eTANegativeLeave.NotAllowed)
                {
                    newDay.LeaveDayOffType = eLeaveDayOffType.Absent;
                }
                else
                {
                    remainingLeaves -= leavedays;
                }

                leaveApplicationDayDetailBindingSource.Add(newDay);

                CalculateLeaveDays();
            }
        }