public void SaveEmployeePlanningDay(EmployeePlanningDay planningday)
        {
            EmployeeDayStatePlanning state = GetEmployeesState(planningday.EmployeeId, planningday.Date);

            if (!planningday.IsBlockedDay)
            {
                if (state == null)
                {
                    state            = new EmployeeDayStatePlanning();
                    state.EmployeeID = planningday.EmployeeId;
                    state.Date       = planningday.Date;
                }
                state.WorkingHours         = planningday.CountDailyWorkingHours;
                state.AllreadyPlannedHours = planningday.CountDailyPlannedWorkingHours;
                state.EmplBalanceHours     = 0;
                state.PlusMinusHours       = 0;
                state.SumOfAddHours        = planningday.CountDailyAdditionalCharges;
                state.StoreWorldId         = planningday.WorldId;

                SaveOrUpdate(state);
            }
            else
            {
                if (state != null)
                {
                    DeleteByID(state.ID);
                }
            }
        }
예제 #2
0
        private void CalculateWeeklyMessageOrSaldoWorkingModels(EmployeePlanningWeek planningweek)
        {
            if (planningweek.IsValidWeek)
            {
                EmployeePlanningDay          epday  = planningweek.Days[planningweek.EndDate];
                EmployeePlanningWorkingModel entity = null;
                foreach (WorkingModelWrapper wrap in _weeklyMessagesModels)
                {
                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                                                       planningweek.BeginDate, planningweek.EndDate))
                    {
                        continue;
                    }

                    if (wrap.Validate(planningweek, planningweek.BeginDate))
                    {
                        entity                = new EmployeePlanningWorkingModel();
                        entity.EmployeeID     = epday.EmployeeId;
                        entity.Date           = epday.Date;
                        entity.WorkingModelID = wrap.Model.ID;

                        if (epday.WorkingModels == null)
                        {
                            epday.WorkingModels = new List <EmployeePlanningWorkingModel>();
                        }

                        epday.WorkingModels.Add(entity);
                    }
                }
            }
        }
예제 #3
0
        public bool CanEditEmployeeDay(EmployeePlanningDay planningday)
        {
            if (ReadOnly)
            {
                return(false);
            }
            if (planningday.Date < DateTime.Today)
            {
                return(false);
            }
            if (planningday.WorldId != CurrentStoreWorldId)
            {
                return(false);
            }
            if (planningday.HasLongAbsence)
            {
                return(false);
            }
            if (!planningday.HasContract)
            {
                return(false);
            }

            return(true);
        }
        public bool Validate(EmployeePlanningWeek employeeweek)
        {
            int                 count          = 0;
            DateTime            currentDate    = employeeweek.BeginDate;
            EmployeePlanningDay currentDay     = null;
            EmployeePlanningDay lastWorkingDay = null;

            Value = employeeweek.ContractHoursPerWeek;

            for (int i = 0; i < 7; i++)
            {
                currentDay = employeeweek.Days[currentDate];

                if (currentDay.CountDailyWorkingHours > 0)
                {
                    count         += currentDay.CountDailyWorkingHours;
                    lastWorkingDay = currentDay;
                }

                currentDate = currentDate.AddDays(1);
            }

            if (count > Value)
            {
                int t = count - Value;
                if (Wrapper.Hours == -1 || Wrapper.Hours > t)
                {
                    Wrapper.Hours = t;
                }
                return(true);
            }

            return(false);
        }
예제 #5
0
        public override bool Validate()
        {
            EmployeePlanningDay day = Wrapper.EmployeeWeek.Days[Wrapper.CurrentDate];

            //StoreDay storeday = Wrapper.StoreDays[Wrapper.CurrentDate];

            return(Validate(null, day));
        }
예제 #6
0
 public override void Process(EmployeePlanningDay day)
 {
     if (day.WorkingTimeList != null && day.WorkingTimeList.Count > 0)
     {
         for (int i = 0; i < day.WorkingTimeList.Count; i++)
         {
             Process(day.WorkingTimeList[i]);
         }
     }
 }
예제 #7
0
        public bool Validate(StoreDay storeday1, EmployeePlanningDay employeeday)
        {
            if (employeeday.Date.DayOfWeek == DayOfWeek.Monday)
            {
                return(false);
            }

            if (employeeday.WorkingTimeList == null ||
                employeeday.WorkingTimeList.Count == 0)
            {
                return(false);
            }

            DateTime prevDate = employeeday.Date.AddDays(-1);

            EmployeePlanningDay prevDay = employeeday.PlanningWeek.Days[prevDate];

            if (prevDay.WorkingTimeList == null ||
                prevDay.WorkingTimeList.Count == 0)
            {
                return(false);
            }

            short maxvalue = 0;
            short minvalue = 24 * 60;

            foreach (WorkingTimePlanning wtp in prevDay.WorkingTimeList)
            {
                if (wtp.End > maxvalue)
                {
                    maxvalue = wtp.End;
                }
            }

            foreach (WorkingTimePlanning wtp in employeeday.WorkingTimeList)
            {
                if (wtp.Begin < minvalue)
                {
                    minvalue = wtp.Begin;
                }
            }


            int diff = (Utills.MinutesInDay - maxvalue) + minvalue;

            int countHour = (int)(Value * 60);

            if (countHour > diff)
            {
                return(true);
            }


            return(false);
        }
예제 #8
0
        private int GetWorkingMinutes(EmployeePlanningDay day)
        {
            int result = 0;

            if (day.WorkingTimeList != null && day.WorkingTimeList.Count > 0)
            {
                foreach (WorkingTimePlanning r in day.WorkingTimeList)
                {
                    result += r.Time;
                }
            }
            return(result);
        }
        private bool IsNeedSave(EmployeePlanningDay employeeday)
        {
            if (employeeday == null)
            {
                throw new ArgumentNullException();
            }

            bool bNeedSave = false;

            bNeedSave = employeeday.HasContract & !employeeday.HasLongAbsence & employeeday.HasRelation;

            return(bNeedSave);
        }
예제 #10
0
        public bool Validate(EmployeePlanningDay employeeday)
        {
            CountMinutes = 0;
            if (WeekDayMasks == WeeksDayMask.Empty)
            {
                return(false);
            }
            if (employeeday.CountDailyWorkingHours == 0 ||
                employeeday.WorkingTimeList == null ||
                employeeday.WorkingTimeList.Count == 0)
            {
                return(false);
            }
            DayOfWeek    dayofweek      = employeeday.Date.DayOfWeek;
            WeeksDayMask currentDayMask = WeeksDayMask.Empty;

            switch (dayofweek)
            {
            case DayOfWeek.Monday: currentDayMask = WeeksDayMask.Monday; break;

            case DayOfWeek.Tuesday: currentDayMask = WeeksDayMask.Tuesday; break;

            case DayOfWeek.Wednesday: currentDayMask = WeeksDayMask.Wednesday; break;

            case DayOfWeek.Thursday: currentDayMask = WeeksDayMask.Thursday; break;

            case DayOfWeek.Friday: currentDayMask = WeeksDayMask.Friday; break;

            case DayOfWeek.Saturday: currentDayMask = WeeksDayMask.Saturday; break;

            case DayOfWeek.Sunday: currentDayMask = WeeksDayMask.Sunday; break;
            }

            if ((WeekDayMasks & currentDayMask) != WeeksDayMask.Empty)
            {
                CountMinutes = employeeday.CountDailyWorkingHours;

                if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                {
                    Wrapper.Hours = CountMinutes;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void SaveEmployeeDay(EmployeePlanningDay planningday)
        {
            if (planningday != null)
            {
                DeleteByEmployeeDay(planningday.EmployeeId, planningday.Date);

                if (planningday.WorkingModels != null && planningday.WorkingModels.Count > 0)
                {
                    foreach (EmployeePlanningWorkingModel model in planningday.WorkingModels)
                    {
                        model.ID = 0;
                        ServiceDao.SaveOrUpdate(model);
                    }
                }
            }
        }
예제 #12
0
        public override void Process(EmployeePlanningDay day)
        {
            int time = 0;

            if (day.WorkingTimeList != null && day.WorkingTimeList.Count > 0)
            {
                for (int i = 0; i < day.WorkingTimeList.Count; i++)
                {
                    time += day.WorkingTimeList[i].End - day.WorkingTimeList[i].Begin;
                }

                if (time >= ConditionTime)
                {
                    day.CountDailyWorkingHours = time + ApplyValue;
                }
            }
        }
        private EmployeePlanningDay ProcessDayCell(XRControl cell)
        {
            EmployeePlanningDay result = null;

            EmployeePlanningWeek employeeWeek = GetCurrentRow();

            StoreDay storeDay = _planningContext.StoreDays[(DateTime)cell.Tag];

            if (employeeWeek != null && storeDay != null && employeeWeek.Days.ContainsKey(storeDay.Date))
            {
                result = employeeWeek.Days[storeDay.Date];
            }

            ReportPainter.ApplyEmployeePlanningDayStyle(cell, storeDay, result, CurrentWorldID);

            return(result);
        }
예제 #14
0
        protected void _ApplyLunchBrakeModels(EmployeePlanningDay day, bool beforeCalc)
        {
            if (_innerList == null || _innerList.Count == 0)
            {
                return;
            }

            if ((beforeCalc && DurationATime) || (!beforeCalc && !DurationATime))
            {
                foreach (LunchBrakeModel m in _innerList)
                {
                    if (m.IsValidModelByData(day.Date))
                    {
                        m.Process(day);
                    }
                }
            }
        }
예제 #15
0
 public bool Validate(EmployeePlanningDay employeeday)
 {
     if (employeeday.HasRelation && employeeday.HasContract)
     {
         if (employeeday.WorkingTimeList != null &&
             employeeday.WorkingTimeList.Count > 0 &&
             employeeday.StoreDay.Feast
             )
         {
             if (Wrapper.Hours == -1 || Wrapper.Hours > employeeday.CountDailyWorkingHours)
             {
                 Wrapper.Hours = employeeday.CountDailyWorkingHours;
             }
             return(true);
         }
     }
     return(false);
 }
예제 #16
0
        private void CalculateWeeklyWorkingModels(EmployeePlanningWeek planningweek)
        {
            if (planningweek.IsValidWeek)
            {
                EmployeePlanningDay          epday  = planningweek.Days[planningweek.EndDate];
                EmployeePlanningWorkingModel entity = null;
                foreach (WorkingModelWrapper wrap in _weeklyModels)
                {
                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                                                       planningweek.BeginDate, planningweek.EndDate))
                    {
                        continue;
                    }

                    if (wrap.Validate(/*daysInfo, */ planningweek, planningweek.BeginDate))
                    {
                        entity                = new EmployeePlanningWorkingModel();
                        entity.EmployeeID     = epday.EmployeeId;
                        entity.Date           = epday.Date;
                        entity.WorkingModelID = wrap.Model.ID;

                        if (!wrap.IsMessageModel)
                        {
                            entity.AdditionalCharge = wrap.Model.AddCharges;
                            entity.Hours           += wrap.GetModelValue;;

                            if (wrap.Model.AddCharges)
                            {
                                epday.CountDailyAdditionalCharges += entity.Hours;// result += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                            }
                            else
                            {
                                epday.CountDailyPlannedWorkingHours += entity.Hours;  //result += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                            }
                        }
                        if (epday.WorkingModels == null)
                        {
                            epday.WorkingModels = new List <EmployeePlanningWorkingModel>();
                        }
                        epday.WorkingModels.Add(entity);
                    }
                }
            }
        }
        private void PrintDataCell(XRTableCell cell)
        {
            XRPanel panel = ReportPainter.GetPanelControl(cell);

            panel.Dock = XRDockStyle.Fill;
            panel.Controls.Clear();

            EmployeePlanningDay planningDay = ProcessDayCell(cell);

            if (planningDay.HasLongAbsence)
            {
                string s = _planningContext.GetLongTimeAbbreviation(planningDay.LongAbsenceId);
                if (!String.IsNullOrEmpty(s))
                {
                    XRLabel label = ReportPainter.AddLabelLine(panel, s, Color.Black, 0, false);

                    label.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                    int?color = _planningContext.GetLongTimeAbsenceColor(planningDay.LongAbsenceId);
                    if (color.HasValue)
                    {
                        label.BackColor = Color.FromArgb(color.Value);
                        cell.BackColor  = Color.FromArgb(color.Value);
                    }
                    //cell.Text = s;
                    //cell.ForeColor = Color.White;
                    //cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                }
                return;
            }
            else
            {
                cell.ForeColor = Color.Black;
            }

            int y = 0;

            foreach (__TimeRange range in GetDayTimes(planningDay))
            {
                XRLabel label = ReportPainter.AddLabelLine(panel, range.AsTimeString, String.IsNullOrEmpty(range.AbsenceCode) ? Color.Black : range.BeginColor, y, false);
                y = y + label.Height + 1;
            }
        }
        public bool Validate(EmployeePlanningDay employeeday)
        {
            throw new Exception();
            //int count = 0;
            //EmployeePlanningWeek week = employeeday.PlanningWeek;
            //DateTime currentDate = week.BeginDate;

            //if (employeeday.Date.AddDays(-Value) < week.BeginDate) return false;
            //count = week.CountWorkDaysBefore;
            //while (currentDate <= employeeday.Date)
            //{
            //    if (week.Days[currentDate].CountDailyWorkingHours > 0) count++;
            //    else count = 0;

            //    if (count >= Value) return true;

            //    currentDate = currentDate.AddDays(1);
            //}
            //return false;
        }
예제 #19
0
        public bool Validate(EmployeePlanningDay employeeday)
        {
            CountMinutes = 0;
            if (employeeday.WorkingTimeList == null)
            {
                return(false);
            }

            short minutes = (short)(Value * 60);

            foreach (WorkingTimePlanning wtp in employeeday.WorkingTimeList)
            {
                if (LessThan)
                {
                    if (wtp.Time < minutes)
                    {
                        CountMinutes = wtp.Time;
                        if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                        {
                            Wrapper.Hours = CountMinutes;
                        }
                        return(true);
                    }
                }
                else
                {
                    if (wtp.Time > minutes)
                    {
                        CountMinutes = wtp.Time - minutes;
                        if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                        {
                            Wrapper.Hours = CountMinutes;
                        }
                        return(true);
                    }
                }
            }

            return(false);
        }
        public bool Validate(EmployeePlanningDay employeeday)
        {
            CountMinutes = 0;
            if (employeeday.HasRelation && employeeday.HasContract)
            {
                if (employeeday.WorkingTimeList == null ||
                    employeeday.WorkingTimeList.Count == 0)
                {
                    return(false);
                }

                short openTime  = employeeday.StoreDay.OpenTime; //storeday.OpenTime;
                short closeTime = employeeday.StoreDay.CloseTime;

                foreach (WorkingTimePlanning wtp in employeeday.WorkingTimeList)
                {
                    for (short start = wtp.Begin; start <= wtp.End; start += 15)
                    {
                        if (openTime <= start && start <= closeTime)
                        {
                            continue;
                        }

                        CountMinutes += 15;
                    }
                }

                if (CountMinutes > 0)
                {
                    if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                    {
                        Wrapper.Hours = CountMinutes;
                    }

                    return(true);
                }
            }

            return(false);
        }
        private static List <__TimeRange> GetDayTimes(EmployeePlanningDay epd)
        {
            List <__TimeRange> result = new List <__TimeRange>();

            if (epd.WorkingTimeList != null)
            {
                foreach (WorkingTimePlanning wtp in epd.WorkingTimeList)
                {
                    result.Add(new __TimeRange(wtp.Begin, wtp.End));
                }
            }

            if (epd.AbsenceTimeList != null)
            {
                foreach (AbsenceTimePlanning atp in epd.AbsenceTimeList)
                {
                    result.Add(new __TimeRange(atp.Begin, atp.End, atp.Absence.CharID, Color.FromArgb(atp.Absence.Color)));
                }
            }
            result.Sort();

            return(result);
        }
예제 #22
0
        public bool Validate(EmployeePlanningDay employeeday)
        {
            CountMinutes = 0;

            if (employeeday.WorkingTimeList == null)
            {
                return(false);
            }
            if (employeeday.WorkingTimeList.Count == 0)
            {
                return(false);
            }

            foreach (WorkingTimePlanning wtp in employeeday.WorkingTimeList)
            {
                for (short start = wtp.Begin; start < wtp.End; start += 15)
                {
                    if (BeginTime <= start && start < EndTime) //continue;
                    {
                        CountMinutes += 15;
                    }
                }
            }
            if (CountMinutes > 0)
            {
                if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                {
                    Wrapper.Hours = CountMinutes;
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #23
0
        public void FillEmployeePlanningWeeks(List <EmployeePlanningWeek> planningweeks, DateTime beginDate, DateTime endDate)
        {
            if (planningweeks != null && planningweeks.Count > 0)
            {
                List <long> lstIds = new List <long>(planningweeks.Count);
                Dictionary <long, EmployeePlanningWeek> _diction = new Dictionary <long, EmployeePlanningWeek>();
                foreach (EmployeePlanningWeek epw in planningweeks)
                {
                    lstIds.Add(epw.EmployeeId);
                    _diction[epw.EmployeeId] = epw;
                }

                long[] ids = lstIds.ToArray();

                List <EmployeeDayStatePlanning> daystates = GetEmployeesState(ids, beginDate, endDate);

                if (daystates != null)
                {
                    EmployeePlanningWeek lastWeek = planningweeks [0];
                    EmployeePlanningDay  day      = null;
                    foreach (EmployeeDayStatePlanning edsp in daystates)
                    {
                        if (edsp.EmployeeID != lastWeek.EmployeeId)
                        {
                            lastWeek = _diction[edsp.EmployeeID];
                        }

                        day = lastWeek.Days[edsp.Date];

                        day.CountDailyAdditionalCharges   = edsp.SumOfAddHours;
                        day.CountDailyPlannedWorkingHours = edsp.AllreadyPlannedHours;
                        day.CountDailyWorkingHours        = edsp.WorkingHours;
                    }
                }
            }
        }
예제 #24
0
        public override bool Validate()
        {
            EmployeePlanningDay day = Wrapper.EmployeeWeek.Days[Wrapper.CurrentDate];

            return(Validate(day.CountDailyWorkingHours));
        }
예제 #25
0
            public void AssignTo(EmployeePlanningDay employeeday)
            {
                if (employeeday.WorkingTimeList == null)
                    employeeday.WorkingTimeList = new List<WorkingTimePlanning>();
                else employeeday.WorkingTimeList.Clear();

                WorkingTimePlanning entity = null;
                foreach (WorkingTimePlanning wtp in WorkingTimes)
                {
                    entity = new WorkingTimePlanning();

                    entity.ID = 0;
                    entity.EmployeeID = employeeday.EmployeeId;
                    entity.Date = employeeday.Date;
                    entity.Begin = wtp.Begin;
                    entity.End = wtp.End;
                    entity.Time = (short)(entity.End - entity.Begin);

                    employeeday.WorkingTimeList.Add(entity);

                }

                if (employeeday.AbsenceTimeList == null)
                    employeeday.AbsenceTimeList = new List<AbsenceTimePlanning>();
                else employeeday.AbsenceTimeList.Clear();

                AbsenceTimePlanning entity1 = null;
                foreach (AbsenceTimePlanning atp in AbsenceTimes)
                {
                    entity1 = new AbsenceTimePlanning();
                    entity1.ID = 0;
                    entity1.EmployeeID = employeeday.EmployeeId;
                    entity1.Date = employeeday.Date;
                    entity1.Begin = atp.Begin;
                    entity1.End = atp.End;
                    entity1.AbsenceID = atp.AbsenceID;
                    entity1.Absence = atp.Absence;

                    employeeday.AbsenceTimeList.Add(entity1);
                }

                employeeday.Modified = true;
            }
예제 #26
0
 public virtual void Process(EmployeePlanningDay day)
 {
     return;
 }
예제 #27
0
 public void SaveEmployeePlanningDay(EmployeePlanningDay plday)
 {
     servicedao.SaveEmployeePlanningDay(plday);
 }
예제 #28
0
        public static void ApplyEmployeePlanningDayStyle(XRControl control, StoreDay storeDay, EmployeePlanningDay employeeDay, long worldID)
        {
            control.BackColor = Color.Transparent;

            ApplyStoreDayStyle(control, storeDay);

            if (employeeDay != null)
            {
                if (employeeDay.CountDailyAdditionalCharges > 0)
                {
                    control.BackColor = Color.Yellow;
                }
                else if (employeeDay.WorldId != worldID || employeeDay.HasLongAbsence)
                {
                    control.BackColor = Color.Gray;
                }
            }
        }
예제 #29
0
            public void Assign(EmployeePlanningDay employeeday)
            {
                Clear();
                if (employeeday.WorkingTimeList != null)
                    WorkingTimes.AddRange(employeeday.WorkingTimeList);

                if (employeeday.AbsenceTimeList != null)
                    AbsenceTimes.AddRange(employeeday.AbsenceTimeList);
            }
예제 #30
0
        public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
        {
            EmployeePlanningDay day = planningWeek.Days[date];

            return(Validate(day.CountDailyWorkingHours));
        }