Example #1
0
        public static List <EmployeePlanningWeek> GetEmployeesByWorldAndDate(long storeworldid, DateTime date, List <EmployeePlanningWeek> planningemployee)
        {
            if (storeworldid == 0)
            {
                return(null);
            }

            List <EmployeePlanningWeek> result = new List <EmployeePlanningWeek>();

            if (planningemployee != null)
            {
                foreach (EmployeePlanningWeek epw in planningemployee)
                {
                    if (epw.IsHasWorldByDate(storeworldid, date))
                    {
                        EmployeePlanningDay plday = epw.Days[date];
                        if (plday.HasRelation && !plday.HasLongAbsence && plday.HasContract)
                        {
                            result.Add(epw);
                        }
                    }
                }
            }

            return(result);
        }
        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;
        }
        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;
        }
        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 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;
        }
        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;
        }
Example #7
0
 public void SetEmployeePlanningDay(EmployeePlanningDay emp_day)
 {
     _planningday         = emp_day;
     ContractHoursPerWeek = Convert.ToInt32(_planningday.ContractHoursPerWeek * 60);
     SetWorkingTimePlanningEntities(_planningday.WorkingTimeList);
     SetAbsenceTimePlanningEntities(_planningday.AbsenceTimeList);
     Modified = false;
 }
Example #8
0
        public void RecalculateTotals()
        {
            ClearAll();

            foreach (EmployeeDayView var in this.Values)
            {
                var.UpdateCountWorkingTime();
                for (int i = 0; i < 24 * 4; i++)
                {
                    if (var.IsWorkingTime(i))
                    {
                        m_totalTimes[i]         += 15;
                        TotalPlannedHoursPerDay += 15;
                    }

                    if (_bCashDesk)
                    {
                        if (i % 4 == 0)
                        {
                            int  ii = i / 4;
                            bool b  = false;
                            b |= var.IsWorkingTime(i);
                            b |= var.IsWorkingTime(i + 1);
                            b |= var.IsWorkingTime(i + 2);
                            b |= var.IsWorkingTime(i + 3);
                            if (b)
                            {
                                m_UnitPerHour[ii]++;
                            }
                        }
                    }
                }
            }



            if (_WorldWeekState != null && _DayWeeklyList != null)
            {
                _WorldWeekState.Calculate();

                EmployeePlanningDay epd = null;
                foreach (EmployeePlanningWeek epw in _DayWeeklyList)
                {
                    epd = epw.Days[ViewDate];

                    TotalWorkingHoursPerWeek    += epw.ContractHoursPerWeek;
                    TotalPlannedWorkingHours    += epd.CountDailyPlannedWorkingHours;
                    TotalSumOfAdditianalCharges += epd.CountDailyAdditionalCharges;
                    TotalPlusMinusHours         += epw.CountWeeklyPlusMinusHours;
                    TotalEmployeeBalanceHours   += epw.Saldo;
                }
            }
        }
        protected virtual void ProccessDay(EmployeePlanningDay employee_day, bool cashdesk)
        {
            if (employee_day.WorldId == FilterStoreWorldId)
            {
                int index = (int)employee_day.Date.DayOfWeek;

                DaysSum[index]          += employee_day.CountDailyWorkingHours;
                CountWorldPlanningHours += employee_day.CountDailyPlannedWorkingHours;
                if (cashdesk)
                {
                    employee_day.FillQuoters(CashDeskUnitsPerHour[index]);
                }
            }
        }
Example #10
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;
 }
Example #11
0
        public EmployeePlanningWeek(long id, string fullname, DateTime from, DateTime to)
        {
            Debug.Assert(from.DayOfWeek == DayOfWeek.Monday);
            Debug.Assert(to.DayOfWeek == DayOfWeek.Sunday);

            _EmployeeId = id;
            _EmployeeFullName = fullname;
            BeginDate = from;
            EndDate = to;

            DateTime d = BeginDate;
            while (d <= EndDate)
            {
                _dictionDays[d] = new EmployeePlanningDay(this, d);
                d = d.AddDays(1);
            }
        }
Example #12
0
        public static void AssignTimes(List <EmployeePlanningWeek> planningemployee,
                                       List <WorkingTimePlanning> worktimes,
                                       List <AbsenceTimePlanning> absencetimes)
        {
            Dictionary <long, EmployeePlanningWeek> dict = ListToDictionary(planningemployee);


            EmployeePlanningWeek currentWeekEmployee = null;
            EmployeePlanningDay  currentDayEmployee  = null;

            if (worktimes != null)
            {
                foreach (WorkingTimePlanning wtp in worktimes)
                {
                    if (dict.TryGetValue(wtp.EmployeeID, out currentWeekEmployee))
                    {
                        if (currentWeekEmployee.Days.TryGetValue(wtp.Date, out currentDayEmployee))
                        {
                            if (currentDayEmployee.WorkingTimeList == null)
                            {
                                currentDayEmployee.WorkingTimeList = new List <WorkingTimePlanning> ();
                            }
                            currentDayEmployee.WorkingTimeList.Add(wtp);
                        }
                    }
                }
            }

            if (absencetimes != null)
            {
                foreach (AbsenceTimePlanning atp in absencetimes)
                {
                    if (dict.TryGetValue(atp.EmployeeID, out currentWeekEmployee))
                    {
                        if (currentWeekEmployee.Days.TryGetValue(atp.Date, out currentDayEmployee))
                        {
                            if (currentDayEmployee.AbsenceTimeList == null)
                            {
                                currentDayEmployee.AbsenceTimeList = new List <AbsenceTimePlanning>();
                            }
                            currentDayEmployee.AbsenceTimeList.Add(atp);
                        }
                    }
                }
            }
        }
Example #13
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;
                }
            }
        }
Example #14
0
        public EmployeePlanningWeek(long id, string fullname, DateTime from, DateTime to)
        {
            Debug.Assert(from.DayOfWeek == DayOfWeek.Monday);
            Debug.Assert(to.DayOfWeek == DayOfWeek.Sunday);

            _EmployeeId       = id;
            _EmployeeFullName = fullname;
            BeginDate         = from;
            EndDate           = to;

            DateTime d = BeginDate;

            while (d <= EndDate)
            {
                _dictionDays[d] = new EmployeePlanningDay(this, d);
                d = d.AddDays(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;
        }
Example #16
0
        public static void AssignTimes(List <EmployeePlanningWeek> planningemployee,
                                       long employeeid,
                                       DateTime date,
                                       List <WorkingTimePlanning> worktimes,
                                       List <AbsenceTimePlanning> absencetimes)
        {
            Dictionary <long, EmployeePlanningWeek> dict = ListToDictionary(planningemployee);


            EmployeePlanningWeek currentWeekEmployee = null;
            EmployeePlanningDay  currentDayEmployee  = null;


            if (dict.TryGetValue(employeeid, out currentWeekEmployee))
            {
                if (currentWeekEmployee.Days.TryGetValue(date, out currentDayEmployee))
                {
                    currentDayEmployee.WorkingTimeList = worktimes;
                    currentDayEmployee.AbsenceTimeList = absencetimes;
                }
            }
        }
Example #17
0
        public static void ResetTimesForDate(List <EmployeePlanningWeek> planningemployee, DateTime date)
        {
            if (planningemployee != null)
            {
                EmployeePlanningDay epd = null;

                foreach (EmployeePlanningWeek epw in planningemployee)
                {
                    if (epw.Days.ContainsKey(date))
                    {
                        epd = epw.Days[date];
                        if (epd.WorkingTimeList != null)
                        {
                            epd.WorkingTimeList.Clear();
                        }
                        if (epd.AbsenceTimeList != null)
                        {
                            epd.AbsenceTimeList.Clear();
                        }
                    }
                }
            }
        }
Example #18
0
        private void AddEmployeePlanningWeeks(StoreWorldWeekPlanningState worldweekstate, DateTime date)
        {
            ClearAll();
            _WorldWeekState = worldweekstate;
            _date           = date;
            if (WorldWeekState != null)
            {
                _DayWeeklyList = PlanningWeekProcessor.GetEmployeesByWorldAndDate(WorldWeekState.StoreWorldId, date, WorldWeekState.List);
                if (_DayWeeklyList != null)
                {
                    EmployeeDayView     dayView     = null;
                    EmployeePlanningDay dayPlanning = null;
                    foreach (EmployeePlanningWeek emplWeek in _DayWeeklyList)
                    {
                        if (emplWeek.Days.TryGetValue(date, out dayPlanning))
                        {
                            if (!dayPlanning.HasContract || dayPlanning.HasLongAbsence ||
                                !dayPlanning.HasRelation)
                            {
                                continue;
                            }


                            dayView = new EmployeeDayView(emplWeek.EmployeeId, date);
                            this[emplWeek.EmployeeId] = dayView;

                            dayView.SetEmployeePlanningDay(dayPlanning);
                            TotalWorkingHoursPerWeek += dayView.ContractHoursPerWeek;
                        }
                    }
                }
            }
            else
            {
                ClearAll();
            }
        }
        protected virtual void ProccessDay(EmployeePlanningDay employee_day, bool cashdesk)
        {
            if (employee_day.WorldId == FilterStoreWorldId)
            {
                int index = (int)employee_day.Date.DayOfWeek;

                DaysSum[index] += employee_day.CountDailyWorkingHours;
                CountWorldPlanningHours += employee_day.CountDailyPlannedWorkingHours;
                if (cashdesk)
                {
                    employee_day.FillQuoters(CashDeskUnitsPerHour[index]);
                }
            }
        }
        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;
        }
Example #21
0
        public bool IsHasWorldByDate(long id, DateTime date)
        {
            EmployeePlanningDay epd = Days[date];

            return(epd.WorldId == id);
        }
Example #22
0
        public static bool InsertTimeRange(EmployeePlanningDay day, AbsenceTimePlanning newrange)
        {
            List <IEmployeeTimeRange> ranges = new List <IEmployeeTimeRange>();

            if (day.WorkingTimeList != null)
            {
                foreach (WorkingTimePlanning r in day.WorkingTimeList)
                {
                    ranges.Add(r);
                }
            }

            if (day.AbsenceTimeList != null)
            {
                foreach (AbsenceTimePlanning r in day.AbsenceTimeList)
                {
                    ranges.Add(r);
                }
            }
            ranges.Sort();
            // if newrange is part of exists range - return
            foreach (IEmployeeTimeRange range in ranges)
            {
                if (range.AbsenceID == newrange.AbsenceID && range.Begin <= newrange.Begin && newrange.End <= range.End)
                {
                    return(false);
                }
            }
            //ranges.Add(newrange);
            ranges.Sort();


            foreach (IEmployeeTimeRange range in ranges)
            {
                if (newrange.Begin <= range.Begin && range.End <= newrange.End)
                {
                    range.Begin = range.End;
                }
                else if (range.Begin <= newrange.Begin && newrange.Begin <= range.End)
                {
                    range.End = (short)(newrange.Begin - 1);
                }
                else if (range.Begin <= newrange.End && newrange.End <= range.End)
                {
                    range.Begin = (short)(newrange.End + 1);
                }
            }
            if (day.AbsenceTimeList == null)
            {
                day.AbsenceTimeList = new List <AbsenceTimePlanning>(1);
            }
            if (day.AbsenceTimeList != null)
            {
                day.AbsenceTimeList.Add(newrange);
            }
            for (int i = day.AbsenceTimeList.Count - 1; i >= 0; i--)
            {
                if (day.AbsenceTimeList[i].Begin >= day.AbsenceTimeList[i].End)
                {
                    day.AbsenceTimeList.RemoveAt(i);
                }
            }
            if (day.WorkingTimeList != null)
            {
                for (int i = day.WorkingTimeList.Count - 1; i >= 0; i--)
                {
                    if (day.WorkingTimeList[i].Begin >= day.WorkingTimeList[i].End)
                    {
                        day.WorkingTimeList.RemoveAt(i);
                    }
                }
            }
            for (int i = day.AbsenceTimeList.Count - 1; i >= 1; i--)
            {
                if (day.AbsenceTimeList[i].AbsenceID == day.AbsenceTimeList[i - 1].AbsenceID &&
                    day.AbsenceTimeList[i].Begin - 1 == day.AbsenceTimeList[i - 1].End)
                {
                    day.AbsenceTimeList[i - 1].End = day.AbsenceTimeList[i].End;
                    day.AbsenceTimeList.RemoveAt(i);
                }
            }
            return(true);
        }
 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;
 }