Esempio n. 1
0
        public void SaveEmployeeWeek(EmployeeWeek planningweek)
        {
            if (planningweek == null)
            {
                throw new ArgumentNullException();
            }

            EmployeeWeekTimeRecording entity = GetEmployeeWeekState(planningweek.EmployeeId, planningweek.BeginDate, planningweek.EndDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimeRecording();
            }

            EmployeeWeekProcessor.AssignTo(entity, planningweek);

            SaveOrUpdate(entity);

            //planningweek.ID = entity.ID;
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public void SaveEmployeeWeek(EmployeeWeek planningweek)
        {
            if (planningweek == null)
            {
                throw new ArgumentNullException();
            }

            EmployeeWeekTimePlanning entity = GetEmployeeWeekState(planningweek.EmployeeId, planningweek.BeginDate, planningweek.EndDate);

            if (entity == null)
            {
                entity = new EmployeeWeekTimePlanning();
            }

            EmployeeWeekProcessor.AssignTo(entity, planningweek);

            SaveOrUpdate(entity);

            //planningweek.ID = entity.ID;
            if (DateTimeHelper.Between(DateTime.Today, planningweek.BeginDate, planningweek.EndDate))
            {
                UpdatePlanningSaldo(entity);
            }
        }
Esempio n. 4
0
        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));
        }