public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
        {
            if (planningWeek.Saldo > (int)(Value * 60))
                return true;

            return false;
        }
        public EmployeePlanningWeek this[long id]
        {
            get
            {
                EmployeePlanningWeek result = null;
                _dictionEmployees.TryGetValue(id, out result);
                return(result);
            }

            set
            {
                if (value != null)
                {
                    EmployeePlanningWeek week = this[id];
                    if (week != null)
                    {
                        _dictionEmployees.Remove(id);
                        _listemployeesweek.Remove(week);
                    }

                    _dictionEmployees[id] = value;
                    _listemployeesweek.Add(value);
                }
                else
                {
                    throw new NullReferenceException();
                }
            }
        }
        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;
        }
        public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
        {
            int count = 0;

            foreach (EmployeePlanningDay day in planningWeek.Days.Values)
                count += day.CountDailyWorkingHours;

            return Validate(count);
        }
        public void SavePlanningWeek(EmployeePlanningWeek week)
        {
            Debug.Assert(week != null);
            Debug.Assert(week.EmployeeId > 0);

            List<WorkingTimePlanning> list_old = Service.GetWorkingTimeByEmployeeId(week.EmployeeId, week.BeginDate, week.EndDate);

            List<WorkingTimePlanning> list_new = new List<WorkingTimePlanning>(10);

            List<WorkingTimePlanning> temp_list = new List<WorkingTimePlanning>(10);

            foreach (EmployeePlanningDay day in week.Days.Values)
            {
                if (day.WorkingTimeList != null)
                {
                    list_new.AddRange(day.WorkingTimeList);
                }
            }

            if (list_new.Count > 0)
            {
                bool bFound = false;
                foreach (WorkingTimePlanning entity in list_new)
                {
                    bFound = false;
                    if (list_old != null && list_old.Count > 0)
                    {
                        for (int i = 0; i < list_old.Count; i++)
                        {
                            if (list_old[i] != null && list_old[i].Compare(entity))
                            {
                                entity.ID = list_old[i].ID;
                                bFound = true;
                                list_old[i] = null;
                                break;
                            }
                        }
                    }

                    if (!bFound)
                    {
                        Service.Save(entity);
                    }
                }
            }

            if (list_old != null)
            {
                foreach (WorkingTimePlanning entity in list_old)
                {
                    if (entity != null)
                        Service.Delete(entity);
                }
            }
        }
        public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
        {
            int count = planningWeek.CountWorkingSundayPerMonth;

            if (Value <= count) return true;

            if (planningWeek.BeginDate.Month != planningWeek.EndDate.Month)
            {
                if (planningWeek.IsSundayWorking && (Value <= 1)) return true;
            }
            return false;
        }
 protected virtual void ProccessWeek(EmployeePlanningWeek employee_week, bool cashdesk)
 {
     foreach (EmployeePlanningDay epd in employee_week.Days.Values)
     {
         if (epd.WorldId == FilterStoreWorldId)
         {
             ProccessDay(epd, cashdesk);
         }
     }
     ColumnSumContractWorkingHoursPerWeek += employee_week.ContractHoursPerWeek;
     ColumnSumAlreadyPlannedWorkingHours  += employee_week.CountWeeklyPlanningWorkingHours;
     ColumnSumAdditionalCharges           += employee_week.CountWeeklyAdditionalCharges;
     ColumnSumPlusMinusHours += employee_week.CountWeeklyPlusMinusHours;
     ColumnSumSaldo          += employee_week.Saldo;
 }
Beispiel #8
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);
                        }
                    }
                }
            }
        }
Beispiel #9
0
        public static List <EmployeePlanningWorkingModel> GetWorkingModels(EmployeePlanningWeek week)
        {
            if (week == null)
            {
                throw new ArgumentNullException();
            }

            List <EmployeePlanningWorkingModel> lstResult = new List <EmployeePlanningWorkingModel>();

            foreach (EmployeePlanningDay day in week.Days.Values)
            {
                if (day.WorkingModels != null && day.WorkingModels.Count > 0)
                {
                    lstResult.AddRange(day.WorkingModels);
                }
            }

            return(lstResult);
        }
        public bool Validate(EmployeePlanningWeek employeeweek)
        {
            int count = 0;
            DateTime beginWeek = employeeweek.BeginDate;
            DateTime currentDate;
            count = employeeweek.WorkingDaysBefore;
            for (int i = 0; i < 7; i++)
            {
                currentDate = beginWeek.AddDays(i);

                if (employeeweek.Days[currentDate].CountDailyWorkingHours > 0) count++;
                else count = 0;

                if (count >= Value) return true;
            }
            if ((count > 0) && (count + employeeweek.WorkingDaysAfter >= Value))
                return true;

            return false;
        }
        public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
        {
            int count = planningWeek.CountWorkingSundayAndSaturdayPerMonth ;

            if (Value <= count) return true;

            if (planningWeek.BeginDate.Month != planningWeek.EndDate.Month)
            {
                DateTime dtSaturday = planningWeek.EndDate.AddDays(-1);
                count = 0;
                if (planningWeek.BeginDate.Month != dtSaturday.Month)
                {
                    if (planningWeek.IsSaturdayWorking) count++;
                }
                if (planningWeek.IsSundayWorking) count++;

                if (Value <= count) return true;
            }
            return false;
        }
Beispiel #12
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;
                }
            }
        }
Beispiel #13
0
 public EmployeePlanningDay(EmployeePlanningWeek parent, /*Employee empl, */DateTime d)
 {
     _owner = parent;
     //_employee = empl;
     Date = d;
 }
Beispiel #14
0
        public static List<EmployeePlanningWorkingModel> GetWorkingModels(EmployeePlanningWeek week)
        {
            if (week == null)
                throw new ArgumentNullException();

            List<EmployeePlanningWorkingModel> lstResult = new List<EmployeePlanningWorkingModel>();

            foreach (EmployeePlanningDay day in week.Days.Values)
            {
                if (day.WorkingModels != null && day.WorkingModels.Count > 0)
                {
                    lstResult.AddRange(day.WorkingModels);
                }
            }

            return lstResult;
        }
Beispiel #15
0
 public bool Validate(EmployeePlanningWeek planningWeek, DateTime date)
 {
     _employeeweek = planningWeek;
     _currentDate = date;
     _Hours = -1;
     return Validate();
 }
Beispiel #16
0
 public void ResetContext()
 {
     //_storedays = null;
     _employeeweek = null;
     Hours = -1;
 }
 public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
 {
     return Validate(planningWeek.Days [date]);
 }
Beispiel #18
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);
                    }
                }
            }
        }
Beispiel #19
0
 public virtual bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
 {
     return false;
 }
Beispiel #20
0
        public static int GetLastSaldoFromSaldo(EmployeePlanningWeek week)
        {
            int LastSaldo = week.Saldo - week.CountWeeklyPlusMinusHours;

            return(LastSaldo);
        }
 public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
 {
     EmployeePlanningDay day = planningWeek.Days[date];
     return Validate(day.CountDailyWorkingHours );
 }
Beispiel #22
0
        public void Calculate(EmployeePlanningWeek planningweek)
        {
            if (_lunchManager != null)
                _lunchManager.Process(planningweek);

            planningweek.CalculateWithoutWorkingModels();

            CalculateDailyWorkingModels(planningweek);
            CalculateWeeklyWorkingModels(planningweek);
            planningweek.CalculateAfterWorkingModels();
            CalculateWeeklyMessageOrSaldoWorkingModels(planningweek);
        }
Beispiel #23
0
 public void Calculate(EmployeePlanningWeek planningweek)
 {
 }
Beispiel #24
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);
                    }
                }
            }
        }
Beispiel #25
0
        public static int GetLastSaldoFromSaldo(EmployeePlanningWeek week)
        {
            int LastSaldo = week.Saldo - week.CountWeeklyPlusMinusHours;

            return LastSaldo;
        }
        public void SaveEmployeeWorkingModel(EmployeePlanningWeek week)
        {
            List<EmployeePlanningWorkingModel> lst = PlanningWeekProcessor.GetWorkingModels(week);

            SaveEmployeeWorkingModel(week.EmployeeId, lst, week.BeginDate, week.EndDate);
        }
 public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
 {
     return false;
 }
Beispiel #28
0
        private void CalculateDailyWorkingModels(EmployeePlanningWeek planningweek)
        {
            #region daily calculation
            if (planningweek.IsValidWeek)
            {
                EmployeePlanningWorkingModel entity = null;
                foreach (EmployeePlanningDay epd in planningweek.Days.Values)
                {
                    epd.CountDailyAdditionalCharges = 0;
                    epd.WorkingModels = null;
                    // if day don't have - contractr, relation or it under long absence
                    if (epd.IsBlockedDay) continue;

                    foreach (WorkingModelWrapper wrap in _dailyModels)
                    {
                        if (!DateTimeHelper.Between(epd.Date, wrap.Model.BeginTime, wrap.Model.EndTime)) continue;

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

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

                                if (wrap.Model.AddCharges)
                                {
                                    epd.CountDailyAdditionalCharges += entity.Hours;
                                }
                                else
                                {
                                    epd.CountDailyPlannedWorkingHours += entity.Hours;
                                }
                            }

                            if (epd.WorkingModels == null)
                                epd.WorkingModels = new List<EmployeePlanningWorkingModel>();
                            epd.WorkingModels.Add(entity);
                        }
                    }

                }
            }
            #endregion
        }
 public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
 {
     return CheckingDate(planningWeek.BeginDate) && CheckSaldo(planningWeek.Saldo);
 }
Beispiel #30
0
 public EmployeePlanningDay(EmployeePlanningWeek parent, /*Employee empl, */ DateTime d)
 {
     _owner = parent;
     //_employee = empl;
     Date = d;
 }
 public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date)
 {
     return base.ValidateWeek(planningWeek, date);
 }
 protected virtual void ProccessWeek(EmployeePlanningWeek employee_week, bool cashdesk)
 {
     foreach (EmployeePlanningDay epd in employee_week.Days.Values)
     {
         if (epd.WorldId == FilterStoreWorldId)
         {
             ProccessDay(epd, cashdesk);
         }
     }
     ColumnSumContractWorkingHoursPerWeek += employee_week.ContractHoursPerWeek;
     ColumnSumAlreadyPlannedWorkingHours += employee_week.CountWeeklyPlanningWorkingHours;
     ColumnSumAdditionalCharges += employee_week.CountWeeklyAdditionalCharges;
     ColumnSumPlusMinusHours += employee_week.CountWeeklyPlusMinusHours;
     ColumnSumSaldo += employee_week.Saldo;
 }