Exemple #1
0
        public EmployeeWeek this[long id]
        {
            get
            {
                if (_listemployeesweek.Count != _dictionEmployees.Count)
                {
                    BuildDiction();
                }
                EmployeeWeek result = null;
                _dictionEmployees.TryGetValue(id, out result);
                return(result);
            }

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

                    _dictionEmployees[id] = value;
                    _listemployeesweek.Add(value);
                }
                else
                {
                    throw new NullReferenceException();
                }
            }
        }
        public bool FillEmployeeWeek(EmployeeWeek week)
        {
            if (week == null)
            {
                return(false);
            }
            bool bExistsContract = false;
            int  contracthours   = EmployeeContract.InvalidContractHours;

            foreach (EmployeeDay d in week.DaysList)
            {
                contracthours = GetContractHours(d.EmployeeId, d.Date);

                if (contracthours != EmployeeContract.InvalidContractHours)
                {
                    d.HasContract = true;
                    if (week.ContractHoursPerWeek == 0)
                    {
                        week.ContractHoursPerWeek = contracthours;
                    }
                }
                bExistsContract |= d.HasContract;
            }


            return(bExistsContract);
        }
        public bool FillEmployeeWeek(EmployeeWeek week)
        {
            if (week == null)
            {
                return(false);
            }
            bool bExists = false;
            List <EmployeeLongTimeAbsence> lst = this[week.EmployeeId];

            if (lst != null && lst.Count > 0)
            {
                foreach (EmployeeLongTimeAbsence entity in lst)
                {
                    foreach (EmployeeDay d in week.DaysList)
                    {
                        if (entity.IsContainDate(d.Date))
                        {
                            d.LongAbsenceId = entity.LongTimeAbsenceID;
                        }
                    }
                }
                bExists = true;
                foreach (EmployeeDay d in week.DaysList)
                {
                    bExists &= d.HasLongAbsence;
                }
            }
            return(!bExists);
        }
        public bool FillEmployeeWeek(EmployeeWeek week)
        {
            if (week == null) return false;
            bool bExists = false;
            List<EmployeeLongTimeAbsence> lst = this[week.EmployeeId];

            if (lst != null && lst.Count > 0)
            {

                foreach (EmployeeLongTimeAbsence entity in lst)
                {
                    foreach (EmployeeDay d in week.DaysList)
                    {
                        if (entity.IsContainDate(d.Date))
                        {
                            d.LongAbsenceId = entity.LongTimeAbsenceID;
                        }
                    }
                }
                bExists = true;
                foreach (EmployeeDay d in week.DaysList)
                {

                    bExists &= d.HasLongAbsence;
                }

            }
            return !bExists;
        }
Exemple #5
0
        public static int GetLastSaldoFromSaldo(EmployeeWeek week)
        {
            int LastSaldo = week.Saldo - week.CountWeeklyPlusMinusHours;

            if (week.CustomEdit)
            {
                LastSaldo = 0;
            }

            return(LastSaldo);
        }
Exemple #6
0
 public EmployeeWeekView(IPlanningContext context, EmployeeWeek planweek, EmployeeWeek actualweek, long orderHWGR) :
     this(context)
 {
     _planningWeek = planweek;
     _actualWeek   = actualweek;
     _OrderHWGR    = orderHWGR;
     if (_planningWeek != null)
     {
         _EmplFullName = _planningWeek.FullName;
     }
 }
Exemple #7
0
 public EmployeeWeekView(IPlanningContext context, EmployeeWeek planweek, EmployeeWeek actualweek, long orderHWGR)
     : this(context)
 {
     _planningWeek = planweek;
     _actualWeek = actualweek;
     _OrderHWGR = orderHWGR;
     if (_planningWeek != null)
     {
         _EmplFullName = _planningWeek.FullName;
     }
 }
Exemple #8
0
 public static bool IsModified(EmployeeWeekTimePlanning entity, EmployeeWeek week)
 {
     return(entity.EmployeeID != week.EmployeeId ||
            entity.Saldo != week.Saldo ||
            entity.WeekBegin != week.BeginDate ||
            entity.WeekEnd != week.EndDate ||
            entity.WeekNumber != DateTimeHelper.GetWeekNumber(week.BeginDate, week.EndDate) ||
            entity.AdditionalCharge != week.CountWeeklyAdditionalCharges ||
            entity.PlannedHours != week.CountWeeklyPlanningWorkingHours ||
            entity.PlusMinusHours != week.CountWeeklyPlusMinusHours ||
            entity.WorkingHours != week.CountWeeklyWorkingHours ||
            entity.ContractHours != week.ContractHoursPerWeek ||
            entity.CustomEdit != week.CustomEdit ||
            entity.AllIn != week.AllIn);
 }
Exemple #9
0
 public static IEmployeeWeek AssignTo(IEmployeeWeek entity, EmployeeWeek week)
 {
     //entity.ID = week.ID;
     entity.EmployeeID       = week.EmployeeId;
     entity.OrderHWGR        = week.OrderHWGR;
     entity.Saldo            = week.Saldo;
     entity.WeekBegin        = week.BeginDate;
     entity.WeekEnd          = week.EndDate;
     entity.WeekNumber       = DateTimeHelper.GetWeekNumber(week.BeginDate, week.EndDate);
     entity.AdditionalCharge = week.CountWeeklyAdditionalCharges;
     entity.PlannedHours     = week.CountWeeklyPlanningWorkingHours;
     entity.PlusMinusHours   = week.CountWeeklyPlusMinusHours;
     entity.WorkingHours     = week.CountWeeklyWorkingHours;
     entity.ContractHours    = week.ContractHoursPerWeek;
     entity.CustomEdit       = week.CustomEdit;
     entity.AllIn            = week.AllIn;
     return(entity);
 }
Exemple #10
0
        public static List <EmployeeWorkingModel> GetWorkingModels(EmployeeWeek week)
        {
            if (week == null)
            {
                throw new ArgumentNullException();
            }

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

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

            return(lstResult);
        }
Exemple #11
0
        public RecordingDayRow(EmployeeWeek week, RecordingDayView dayview,
            EmployeeWeek actualweek, RecordingDayView actualdayview, long orderHwgr)
        {
            _plannedWeek = week;
            _plannedDayView = dayview;

            _actualWeek = actualweek;
            _actualDayView = actualdayview;

            if (_plannedDayView != null)
                _plannedDay = _plannedDayView.RecordingDay;

            if (_actualDayView != null)
                _actualDay = _actualDayView.RecordingDay;

            if (_plannedWeek.FullName != null)
                _fullname = _plannedWeek.FullName;

            _OrderHWGR = orderHwgr;
        }
Exemple #12
0
 public static EmployeeWeek Assign(IEmployeeWeek entity, EmployeeWeek week)
 {
     //week.ID = entity.ID;
     if (entity.ID > 0)
     {
         week.NewWeek = false;
     }
     week.EmployeeId = entity.EmployeeID;
     week.OrderHWGR  = entity.OrderHWGR;
     week.Saldo      = entity.Saldo;
     week.BeginDate  = entity.WeekBegin;
     week.EndDate    = entity.WeekEnd;
     week.CountWeeklyAdditionalCharges    = entity.AdditionalCharge;
     week.CountWeeklyPlanningWorkingHours = entity.PlannedHours;
     week.CountWeeklyPlusMinusHours       = entity.PlusMinusHours;
     week.CountWeeklyWorkingHours         = entity.WorkingHours;
     week.ContractHoursPerWeek            = entity.ContractHours;
     week.CustomEdit = entity.CustomEdit;
     week.AllIn      = entity.AllIn;
     return(week);
 }
Exemple #13
0
        public List<EmployeeWeek> BuildEmployeeWeeks(long storeid, long worldid, DateTime aBegin, DateTime aEnd, bool bPlanning)
        {
            Store store = ServerEnvironment.StoreService.FindById(storeid);

            if (store == null)
                return null;
            long countryid = store.CountryID;
            bool IsAustria = store.CountryID == ServerEnvironment.CountryService.AustriaCountryID;

            // list of all employee for storeid and world
            IList employees = EmployeeService.EmployeeDao.GetPlanningEmployeesByWorld(storeid, worldid, aBegin, aEnd);

            if (employees == null && employees.Count == 0) return null;

            long[] ids = new long[employees.Count];
            for (int i = 0; i < employees.Count; i++)
            {
                ids[i] = (employees[i] as Employee).ID;
            }

            EmployeeRelationService relationService = EmployeeService.EmployeeRelationService as EmployeeRelationService;

            List<EmployeeRelation> emplRelations = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBegin, aEnd);

            //CountryStoreWorldManager swmanager = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
            //swmanager.StoreId = storeid;
            if (swCountryManager == null)
            {
                //long countryid = EmployeeService.StoreService.GetCountryByStoreId(storeid);
                swCountryManager = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
                swCountryManager.CountryId = countryid;
            }

            List<EmployeeLongTimeAbsence> emplLongTimeAbsences =
                EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBegin, aEnd);

            EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences);

            DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations);

            List<EmployeeContract> contracts = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBegin, aEnd);
            ContractIndexer = new DictionListEmployeesContract(contracts);

            // applly relations
            EmployeeRelation relationWorld = null;
            bool bExistsRelation = false;
            bool bExistsContract = false;
            bool bNotExistsAbsence = true;

            _listweeks = new List<EmployeeWeek>();
            EmployeeWeek emplWeek = null;

            foreach (Employee empl in employees)
            {
                emplWeek = new EmployeeWeek(empl.ID, empl.FullName, aBegin, aEnd, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0);
                emplWeek.LastSaldo = (int)Math.Round(empl.BalanceHours);
                bExistsRelation = false;

                foreach (EmployeeDay d in emplWeek.DaysList)
                {
                    relationWorld = relationIndexer.GetRelationEntity(empl.ID, d.Date);
                    if (relationWorld != null)
                    {
                        d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId (relationWorld.StoreID, relationWorld.WorldID.Value);
                        d.StoreId = relationWorld.StoreID;
                    }

                    bExistsRelation |= d.HasRelation;
                }
                if (bExistsRelation)
                {
                    bExistsContract = ContractIndexer.FillEmployeeWeek(emplWeek);
                    if (bExistsContract)
                    {
                        bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek);

                        if (bNotExistsAbsence)
                        {
                            _listweeks.Add(emplWeek);
                        }
                    }
                }
            }

            FillEmployeeDayByStoreDay(storeid, aBegin, aEnd);

            _dictionWeek = EmployeeWeekProcessor.GetDictionary(_listweeks);
            _employeeids = EmployeeWeekProcessor.GetEmployeeIds(_listweeks);

            if (bPlanning)
                FillPlanningEmployeeWeeks(storeid, worldid, aBegin, aEnd);
            else
                FillActualEmployeeWeeks(storeid, worldid, aBegin, aEnd);

            //LastSaldoBuilder saldoBuilder = new LastSaldoBuilder();
            LastSaldoBuilder saldoBuilder = (IsAustria) ? new LastSaldoBuilderAustria() : new LastSaldoBuilder();

            saldoBuilder.FillLastSaldo(_dictionWeek, _employeeids, aBegin, bPlanning);

            EmployeeMonthWorkingTime monthData = new EmployeeMonthWorkingTime(EmployeeService.EmployeeTimeService as EmployeeTimeService);
            monthData.IsPlanning = bPlanning;
            monthData.CurrentMonday = aBegin;
            CacheEmployeesAllIn managerAllIn = new CacheEmployeesAllIn();
            managerAllIn.LoadByStoreRelation(storeid);

            foreach (EmployeeWeek ew in _listweeks)
            {
               ew.WorkingTimeByMonth = monthData.GetMonthWorkingTime(ew.EmployeeId);
               ew.CountSaturday = (byte)monthData.CountSaturday;
               ew.CountSunday = (byte)monthData.CountSunday;

               ew.WorkingDaysBefore = (byte)monthData.WorkingDaysBefore;
               ew.WorkingDaysAfter = (byte)monthData.WorkingDaysAfter;
               ew.AllIn = managerAllIn.GetAllIn(ew.EmployeeId, aBegin, aEnd);

            }

            return _listweeks;
        }
Exemple #14
0
        public static int GetLastSaldoFromSaldo(EmployeeWeek week)
        {
            int LastSaldo = week.Saldo - week.CountWeeklyPlusMinusHours;

            if (week.CustomEdit)
                LastSaldo = 0;

            return LastSaldo;
        }
Exemple #15
0
        public static List<EmployeeWorkingModel> GetWorkingModels(EmployeeWeek week)
        {
            if (week == null)
                throw new ArgumentNullException();

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

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

            return lstResult;
        }
Exemple #16
0
 public static bool IsModified(EmployeeWeekTimePlanning entity, EmployeeWeek week)
 {
     return (entity.EmployeeID != week.EmployeeId ||
     entity.Saldo != week.Saldo ||
     entity.WeekBegin != week.BeginDate ||
     entity.WeekEnd != week.EndDate ||
     entity.WeekNumber != DateTimeHelper.GetWeekNumber(week.BeginDate, week.EndDate) ||
     entity.AdditionalCharge != week.CountWeeklyAdditionalCharges ||
     entity.PlannedHours != week.CountWeeklyPlanningWorkingHours ||
     entity.PlusMinusHours != week.CountWeeklyPlusMinusHours ||
     entity.WorkingHours != week.CountWeeklyWorkingHours ||
     entity.ContractHours != week.ContractHoursPerWeek ||
     entity.CustomEdit != week.CustomEdit ||
     entity.AllIn != week.AllIn);
 }
Exemple #17
0
        public void CalculateNew(EmployeeWeek planningweek, bool bPlanned)
        {
            if (_lunchManager != null)
                _lunchManager.Process(planningweek);

            planningweek.CalculateBeforeWorkingModels();
            CalculateDailyWorkingModels(planningweek);
            CalculateWeeklyWorkingModels(planningweek);
            planningweek.CalculateAfterWorkingModels();
            CalculateWeeklyMessageOrSaldoWorkingModels(planningweek);
        }
Exemple #18
0
        private void CalculateDailyWorkingModels(EmployeeWeek planningweek)
        {
            #region daily calculation

            Debug.Assert(planningweek != null);

            if (planningweek.IsValidWeek)
            {
                EmployeeWorkingModel entity = null;
                foreach (EmployeeDay epd in planningweek.DaysList)
                {
                    epd.CountDailyAdditionalCharges = 0;
                    epd.WorkingModels = null;

                    if (!epd.IsValidDay) continue;

                    foreach (WorkingModelWrapperNew wrap in _dailyModels)
                    {
                        if (!planningweek.PlannedWeek)
                        {
                            if (!wrap.Model.UseInRecording) continue;

                        }

                        if (!DateTimeHelper.Between(epd.Date, wrap.Model.BeginTime, wrap.Model.EndTime)) continue;

                        if (wrap.Validate(planningweek, epd.Date))
                        {
                            entity = new EmployeeWorkingModel();
                            entity.EmployeeID = epd.EmployeeId;
                            entity.Date = epd.Date;
                            entity.WorkingModelID = wrap.Model.ID;
                            // modify 20.12.2007
                            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 (wrap.Model.AddCharges)
                                //{
                                //    entity.AdditionalCharge = true;
                                //    if (wrap.Model.AddValue != 0)
                                //    {
                                //        entity.Hours += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //        epd.CountDailyAdditionalCharges += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //    }
                                //    if (wrap.Model.MultiplyValue != 0)
                                //    {
                                //        entity.Hours = DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //        epd.CountDailyAdditionalCharges += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //    }
                                //}
                                //else
                                //{
                                //    entity.AdditionalCharge = false;
                                //    if (wrap.Model.AddValue != 0)
                                //    {
                                //        entity.Hours += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //        epd.CountDailyPlannedWorkingHours += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                                //    }
                                //    if (wrap.Model.MultiplyValue != 0)
                                //    {
                                //        entity.Hours += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //        epd.CountDailyPlannedWorkingHours += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                                //    }

                                //}
                            }

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

                }
            }
            #endregion
        }
Exemple #19
0
        private void CalculateWeeklyMessageOrSaldoWorkingModels(EmployeeWeek planningweek)
        {
            if (planningweek.IsValidWeek)
            {
                EmployeeDay epday = planningweek.GetDay(planningweek.EndDate);
                EmployeeWorkingModel entity = null;
                foreach (WorkingModelWrapperNew wrap in _weeklyMessagesModels)
                {
                    if (!planningweek.PlannedWeek)
                    {
                        if (!wrap.Model.UseInRecording) continue;

                    }
                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                        planningweek.BeginDate, planningweek.EndDate)) continue;

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

                            if (epday.WorkingModels == null)
                                epday.WorkingModels = new List<EmployeeWorkingModel>();
                            epday.WorkingModels.Add(entity);
                        }
                    }
                }
            }
        }
        public virtual void UpdateEntityAfterRecording(EmployeeWeek week)
        {
            EmployeeWeekTimeRecording entity = GetByDate(week.EmployeeId, week.BeginDate);
            List<EmployeeWeekTimeRecording> list = GetEntitiesByEmployeeId(week.EmployeeId);

            if (entity == null)
            {
                entity = new EmployeeWeekTimeRecording();
                EmployeeWeekProcessor.AssignTo(entity, week);
                UpdateEntity(entity);

                if (list == null)
                {
                    list = new List<EmployeeWeekTimeRecording>();

                    _index[week.EmployeeId] = list;
                }

                _entities.Add(entity);
                list.Add(entity);

                list.Sort();

            }
            else
            {
                if (EmployeeWeekProcessor.IsModified(entity, week))
                {
                    EmployeeWeekProcessor.AssignTo(entity, week);
                    UpdateEntity(entity);
                }
            }

            if (list != null)
            {
                int previous_saldo = entity.Saldo;
                foreach (EmployeeWeekTimeRecording next_entity in list)
                {
                    if (next_entity.WeekBegin <= week.BeginDate) continue;

                    if (next_entity.CalculateSaldo(previous_saldo))
                    {
                        UpdateEntity(next_entity);
                        previous_saldo = next_entity.Saldo;
                    }
                    else break;
                }
            }

            SrvEmployeeWeekPlanningList planList = new SrvEmployeeWeekPlanningList(week.EmployeeId, week.EndDate.AddDays(1));
            //planList.UpdateSaldoFrom2(week.EmployeeId, week.EndDate.AddDays(1), week.Saldo);
            planList.UpdateSaldoAfterRecording(week.EmployeeId, list, week.EndDate.AddDays(1));
        }
Exemple #21
0
        //////////////////////////////////////////////////////////////////////////////////////
        public EmployeeWeek BuildEmployeeWeek(long emplid, DateTime aBeginWeek)
        {
            if (aBeginWeek.DayOfWeek != DayOfWeek.Monday)
                throw new ArgumentException();

            if (emplid <= 0)
                throw new ArgumentException();

            Employee empl = EmployeeService.FindById(emplid);

            if (empl == null)
                throw new ArgumentNullException();

            long[] ids = new long[] { emplid };
            DateTime aEndWeek = DateTimeHelper.GetSunday(aBeginWeek);
            EmployeeRelationService relationService = EmployeeService.EmployeeRelationService as EmployeeRelationService;
            List<EmployeeLongTimeAbsence> emplLongTimeAbsences =
                EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBeginWeek, aEndWeek);
            EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences);

            List<EmployeeRelation> emplRelations = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBeginWeek, aEndWeek);
            DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations);

            List<EmployeeContract> contracts = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBeginWeek, aEndWeek);
            DictionListEmployeesContract contractIndexer = new DictionListEmployeesContract(contracts);

            EmployeeWeek emplWeek = new EmployeeWeek(emplid, "", aBeginWeek,aEndWeek, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0);

            EmployeeRelation relationWorld = null;
            bool bExistsRelation = false;
            bool bExistsContract = false;
            bool bNotExistsAbsence = true;

            if (swCountryManager == null)
            {
                long countryid = EmployeeService.StoreService.GetCountryByStoreId(empl.MainStoreID);
                swCountryManager = new CountryStoreWorldManager(EmployeeService.StoreWorldService);
                swCountryManager.CountryId = countryid;
            }

            bExistsContract = contractIndexer.FillEmployeeWeek(emplWeek);
            if (bExistsContract)
            {
                bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek);
                if (bNotExistsAbsence)
                {
                    foreach (EmployeeDay d in emplWeek.DaysList)
                    {
                        relationWorld = relationIndexer.GetRelationEntity(emplid, d.Date);
                        if (relationWorld != null)
                        {
                            d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId(relationWorld.StoreID, relationWorld.WorldID.Value);
                            d.StoreId = relationWorld.StoreID;
                        }

                        bExistsRelation |= d.HasRelation;
                    }
                }
            }
            if (!bExistsContract || !bExistsRelation || !bNotExistsAbsence)
                emplWeek = null;

            return emplWeek;
        }
Exemple #22
0
        private void CalculateWeeklyWorkingModels(EmployeeWeek planningweek)
        {
            Debug.Assert(planningweek != null);

            if (planningweek.IsValidWeek)
            {
                EmployeeDay epday = planningweek.GetDay(planningweek.EndDate);
                EmployeeWorkingModel entity = null;

                foreach (WorkingModelWrapperNew wrap in _weeklyModels)
                {
                    if (!planningweek.PlannedWeek)
                    {
                        if (!wrap.Model.UseInRecording) continue;

                    }

                    if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime,
                        planningweek.BeginDate, planningweek.EndDate)) continue;

                    if (wrap.Validate(planningweek, planningweek.BeginDate))
                    {
                        entity = new EmployeeWorkingModel();
                        entity.EmployeeID = epday.EmployeeId;
                        entity.Date = epday.Date;
                        entity.WorkingModelID = wrap.Model.ID;
                        if (!wrap.IsMessageModel)
                        {
                            entity.Hours = wrap.GetModelValue;
                            entity.AdditionalCharge = wrap.Model.AddCharges;

                            if (wrap.Model.AddCharges)
                            {
                                epday.CountDailyAdditionalCharges += entity.Hours;
                            }
                            else
                            {
                                epday.CountDailyPlannedWorkingHours += entity.Hours;
                            }
                        }
                        //if (!wrap.IsMessageModel)
                        //{
                        //    int result = 0;
                        //    if (wrap.Model.AddValue != 0)
                        //    {
                        //        result += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue));
                        //    }
                        //    if (wrap.Model.MultiplyValue != 0)
                        //    {
                        //        result += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours));
                        //    }

                        //    if (wrap.Model.AddCharges)
                        //    {
                        //        entity.AdditionalCharge = true;
                        //        entity.Hours = result;
                        //        epday.CountDailyAdditionalCharges += result;

                        //    }
                        //    else
                        //    {
                        //        entity.AdditionalCharge = false;
                        //        entity.Hours = result;
                        //        epday.CountDailyPlannedWorkingHours += result;
                        //    }
                        //}
                        if (epday.WorkingModels == null)
                            epday.WorkingModels = new List<EmployeeWorkingModel>();
                        epday.WorkingModels.Add(entity);
                    }
                }
            }
        }
Exemple #23
0
 private void FillEmployeeDayByStoreDay(EmployeeWeek emplweek)
 {
     if (emplweek != null)
     {
         StoreDaysList dayslist = null;
         foreach (EmployeeDay day in emplweek.DaysList)
         {
             if (day.HasRelation)
             {
                 if (!m_dictionDays.TryGetValue(day.StoreId, out dayslist))
                 {
                     dayslist = EmployeeService.StoreService.GetStoreDays(day.StoreId, emplweek.BeginDate, emplweek.EndDate.AddDays(356));
                     m_dictionDays[day.StoreId] = dayslist;
                 }
                 if (m_dictionDays.TryGetValue(day.StoreId, out dayslist))
                 {
                     day.StoreDay = dayslist[day.Date];
                 }
             }
         }
     }
 }
Exemple #24
0
 public static IEmployeeWeek AssignTo(IEmployeeWeek entity, EmployeeWeek week)
 {
     //entity.ID = week.ID;
     entity.EmployeeID = week.EmployeeId;
     entity.OrderHWGR = week.OrderHWGR;
     entity.Saldo = week.Saldo;
     entity.WeekBegin = week.BeginDate;
     entity.WeekEnd = week.EndDate;
     entity.WeekNumber = DateTimeHelper.GetWeekNumber(week.BeginDate, week.EndDate);
     entity.AdditionalCharge = week.CountWeeklyAdditionalCharges;
     entity.PlannedHours = week.CountWeeklyPlanningWorkingHours;
     entity.PlusMinusHours = week.CountWeeklyPlusMinusHours;
     entity.WorkingHours = week.CountWeeklyWorkingHours;
     entity.ContractHours = week.ContractHoursPerWeek;
     entity.CustomEdit = week.CustomEdit;
     entity.AllIn = week.AllIn ;
     return entity;
 }
        public void SaveEmployeeWorkingModel(EmployeeWeek week)
        {
            List<EmployeeWorkingModel> lst = EmployeeWeekProcessor.GetWorkingModels(week);

            List<EmployeeRecordingWorkingModel> lstEntities = new List<EmployeeRecordingWorkingModel>(lst.Count);
            EmployeeRecordingWorkingModel entity = null;
            foreach (EmployeeWorkingModel model in lst)
            {
                entity = new EmployeeRecordingWorkingModel();
                model.AssignTo(entity);
                lstEntities.Add(entity);
            }

            SaveEmployeeWorkingModel(week.EmployeeId, lstEntities, week.BeginDate, week.EndDate);
        }
Exemple #26
0
 public void CalculateNew(EmployeeWeek planningweek, bool bPlanned)
 {
     //planningweek.CalculateBeforeWorkingModels ();
     //CalculateDailyWorkingModels(daysInfo, planningweek);
     //CalculateWeeklyWorkingModels(daysInfo, planningweek);
     //planningweek.CalculateAfterWorkingModels();
     //CalculateWeeklyMessageOrSaldoWorkingModels(daysInfo, planningweek);
 }
        public void UpdateSaldoAfterPlanning(EmployeeWeek week)
        {
            EmployeeWeekTimePlanning entity = GetByDate(week.EmployeeId, week.BeginDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimePlanning();
                EmployeeWeekProcessor.AssignTo(entity, week);
                UpdateEntity(entity);
            }
            else
            {
                if (EmployeeWeekProcessor.IsModified(entity, week))
                {
                    EmployeeWeekProcessor.AssignTo(entity, week);
                    UpdateEntity(entity);
                }
            }

            UpdateSaldoFrom(week.EmployeeId, DateTimeHelper.GetNextMonday(week.BeginDate), week.Saldo);
        }
Exemple #28
0
 public void FillEmployeeWeek(EmployeeWeek entity)
 {
     if (entity != null && entity.DaysList != null)
     {
         foreach (EmployeeDay day in entity.DaysList)
             FillEmployeeDay(day);
     }
 }
Exemple #29
0
 public static EmployeeWeek Assign(IEmployeeWeek entity, EmployeeWeek week)
 {
     //week.ID = entity.ID;
     if (entity.ID > 0)
         week.NewWeek = false;
     week.EmployeeId = entity.EmployeeID;
     week.OrderHWGR = entity.OrderHWGR;
     week.Saldo = entity.Saldo;
     week.BeginDate = entity.WeekBegin;
     week.EndDate = entity.WeekEnd;
     week.CountWeeklyAdditionalCharges = entity.AdditionalCharge;
     week.CountWeeklyPlanningWorkingHours = entity.PlannedHours;
     week.CountWeeklyPlusMinusHours = entity.PlusMinusHours;
     week.CountWeeklyWorkingHours = entity.WorkingHours;
     week.ContractHoursPerWeek = entity.ContractHours;
     week.CustomEdit = entity.CustomEdit;
     week.AllIn = entity.AllIn;
     return week;
 }