Пример #1
0
        private void ProcessQuery(AbsencePlanningQuery query)
        {
            gcAbsencePlanning.DataSource = null;
            if (query == null) return;

            if (_absencemanager == null) return;

            if (query.Plannings != null && query.Plannings.Count > 0)
                _absencemanager.FillAbsencePlanningTimes(query.Plannings);

            if (query.Recordings != null && query.Recordings.Count > 0)
                _absencemanager.FillAbsenceRecordingTimes(query.Recordings);

            if (query.Longabsences != null && query.Longabsences.Count > 0)
                _longabsencesmanager.FillEmployeelongAbsences(query.Longabsences);

            

            ShowHideColumnForAustria();
            DictionListEmployeesContract c_indexer = null;
            if (query.Contracts != null)
            {
                c_indexer = new DictionListEmployeesContract(query.Contracts);
            }
            DictionListEmployeeRelations r_indexer = null;
            if (query.Relations != null)
            {
                r_indexer = new DictionListEmployeeRelations(query.Relations);
            }

            List<long> ids = new List<long>();

            if (query.Plannings != null)
            {
                foreach (AbsenceTimePlanning a in query.Plannings)
                    ids.Add(a.ID);
            }

            ids.Sort();
            _ids_absences_from_server = ids.ToArray();

            Dictionary<long, BzEmployeeHoliday> _index = new Dictionary<long, BzEmployeeHoliday>();
            if (query._holidays != null)
            {
                foreach (BzEmployeeHoliday e in query._holidays)
                    _index[e.EmployeeId] = e;

                List<EmployeeRelation> relations = null;
                List<EmployeeContract> contracts = null;
                foreach (BzEmployeeHoliday e in query._holidays)
                {
                    e.AvgDayInWeek = query.AvgDaysPerWeek;
                    e.IsAustria = IsAustria;
                    e.HwgrName = GetHwgrName(e.HwgrId);
                    if (r_indexer != null)
                        relations = r_indexer[e.EmployeeId];
                    if (c_indexer != null)
                        contracts = c_indexer[e.EmployeeId];
                    if (relations != null)
                        e.AddRelation(relations);
                    if (contracts != null)
                        e.AddContract(contracts);

                    if (query.Plannings != null)
                    {
                        foreach (AbsenceTimePlanning a in query.Plannings)
                        {
                            if (a.EmployeeID == e.EmployeeId)
                                e.AddAbsences(a);
                        }
                    }
                    if (query.Recordings != null)
                    {
                        foreach (AbsenceTimeRecording a in query.Recordings)
                        {
                            if (a.EmployeeID == e.EmployeeId)
                                e.AddAbsences(a);
                        }
                    }

                    if (query.Longabsences != null)
                    {
                        foreach (EmployeeLongTimeAbsence a in query.Longabsences)
                        {
                            if (a.EmployeeID == e.EmployeeId)
                            {
                                e.AddLongAbsence(a);
                            }
                        }
                    }
                    e.BuildWeeks();

                    if (_ListStoreToWorld != null)
                    {
                        foreach (StoreToWorld sw in _ListStoreToWorld)
                        {
                            if (sw == _emptyworld)// all worlds
                            {
                                continue;
                            }
                            if (e.Relations != null && e.Relations.IsExistsWorldAssignment(sw))
                            {
                                if (!_indexEmployeeByWorld.ContainsKey(sw.ID))
                                {
                                    _indexEmployeeByWorld[sw.ID] = new BindingList<BzEmployeeHoliday>();
                                }
                                _indexEmployeeByWorld[sw.ID].Add(e);
                            }
                        }

                        
                    }
                }
                _EmployeesList = null;
                _EmployeesList = new BindingList<BzEmployeeHoliday>(query._holidays);

                _indexEmployeeByWorld[_emptyworld.ID] = _EmployeesList;

            }



        }
Пример #2
0
        private void LoadHolidaysInfo()
        {
            Store store = CurrentStore;
            ClearContext();
            if (store != null)
            {
                _query = ClientEnvironment.EmployeeService.EmployeeTimeService.GetAllAbsencePlanning(store.ID, store.CountryID, Year, DateTime.Today);
                IsAustria = CurrentCountryId == ClientEnvironment.CountryService.AustriaCountryID;

                btn_TakeFromPrevYear.Enabled = !IsAustria && (Year >= _TodayYear)  && UserCanEdit ;
                if (_query != null && ProcessErrorQuery(_query))
                {
                    ProcessQuery(_query);

                    _currentworld = storeworldControl.CurrentEntity;
                    if (ViewAbsencePlanning == AbsencePlanningView.WeeklyView )
                        OnChangeWeek();
                    else 
                        ApplyFilterByWorld();

                    ShowCurrentColumn();
                }
            }

        }
Пример #3
0
        private bool ProcessErrorQuery(AbsencePlanningQuery query)
        {
            if (query != null)
            {
                StringBuilder sb = new StringBuilder();

                if (query.AvgDaysPerWeek <= 0)
                {
                    sb.AppendLine(GetLocalized("NotExistsAvgDaysPerWeek"));
                }

                if (query.StoreDays == null || query.StoreDays.IsUndefined())
                {
                    sb.AppendLine(GetLocalized("NotExistsOpenTime"));
                }

                if (sb.Length > 0)
                {
                    string message = sb.ToString();
                    ErrorMessage(message, GetLocalized("Attention"));
                    return false;
                }
                return true;
            }
            else return false;
        }
Пример #4
0
        private void ClearContext()
        {
            gcAbsencePlanning.DataSource = null;
            _query = null;
            if (_EmployeesList != null)
                _EmployeesList.Clear();

            if (_indexIdToEntity != null)
                _indexIdToEntity.Clear();

            if (_indexEmployeeByWorld != null)
                _indexEmployeeByWorld.Clear();

            _currentworld = null;
            _ids_absences_from_server = null;
            Modified = false;
            BuildTotalSums();
        }