Beispiel #1
0
        // user can change saldo from Employee manager
        // here recalculate saldo for planning week
        public void UpdateCustomSaldo(int saldo)
        {
            CheckAndInit();

            if (!AustriaEmployee)
            {
                EmployeeWeekTimeRecording entity = RecordingWeeks.UpdateLastSaldoAsCustom(Employee.ID, saldo);

                int lastsaldo = saldo;

                DateTime date = DateTimeSql.FirstMinMonday;

                if (entity != null)
                {
                    date = entity.WeekBegin.AddDays(7);
                }
                else
                {
                    _employee.BalanceHours = Convert.ToDecimal(saldo);
                    (ServerEnvironment.EmployeeService as EmployeeService).EmployeeDao.UpdateSaldo(Employee.ID, Employee.BalanceHours);
                }
                PlanningWeeks = new SrvEmployeeWeekPlanningList();

                if (entity != null)
                {
                    PlanningWeeks.InitList(Employee.ID, entity.WeekBegin);
                    PlanningWeeks.SetCustomEditFlag(Employee.ID, entity.WeekBegin, saldo);
                }
                else
                {
                    PlanningWeeks.InitList(Employee.ID, date);
                }

                PlanningWeeks.AllInManager = AllInManagers;
                PlanningWeeks.UpdateSaldoFrom(Employee.ID, date, lastsaldo);
            }
        }
Beispiel #2
0
        public static void Recalculate(long[] ids)
        {
            EmployeeService empl_service = ServerEnvironment.EmployeeService as EmployeeService;

            List <Employee> lst = empl_service.EmployeeDao.GetEmployeeByIds(ids);

            IList list = empl_service.EmployeeDao.GetDifferenceContractsAndRelations();

            if (lst == null)
            {
                return;
            }
            int i = 0;

            DictionListEmployeeRelations rels = new DictionListEmployeeRelations(ServerEnvironment.EmployeeRelationService.LoadAllSorted());



            CacheListEmployeeContracts contracts = (new CacheListEmployeeContracts()).LoadAll();

            CacheEmployeesAllIn all = (new CacheEmployeesAllIn()).LoadAll();

            DateTime beginDate = DateTime.Today.AddDays(-7);

            beginDate = DateTimeHelper.GetMonday(beginDate);


            SrvEmployeeWeekPlanningList PlanningWeeks = new SrvEmployeeWeekPlanningList();

            PlanningWeeks.InitList(null, beginDate);

            SrvEmployeeWeekRecordingList RecordingWeeks = new SrvEmployeeWeekRecordingList();

            RecordingWeeks.InitList(null, beginDate);

            List <Store>             stores         = ServerEnvironment.StoreService.FindAll();
            Dictionary <long, Store> diction_stores = new Dictionary <long, Store>();

            foreach (Store s in stores)
            {
                diction_stores[s.ID] = s;
            }

            long austriaid = ServerEnvironment.CountryService.AustriaCountryID;
            //rels.LoadRelations(ServerEnvironment.EmployeeRelationService);
            EmployeeBusinessObject bz = null;

            foreach (Employee e in lst)
            {
                i++;

                if (bz == null)
                {
                    bz = new EmployeeBusinessObject(e, DateTime.Today);
                }
                else
                {
                    bz.Employee = e;
                }

                bz.AustriaEmployee = diction_stores[e.MainStoreID].CountryID == austriaid;

                bz.Relations     = rels;
                bz.Contracts     = contracts;
                bz.AllInManagers = all;

                bz.PlanningWeeks  = PlanningWeeks;
                bz.RecordingWeeks = RecordingWeeks;
                bz.RecalculateFrom();
            }
        }