private void subreportDetails_BeforePrint(object sender, PrintEventArgs e)
        {
            StoreToWorld        currentWorld     = (StoreToWorld)GetCurrentRow();
            StoreWorldWeekState plannedWeekState = _hashStates[currentWorld][0];
            StoreWorldWeekState actualWeekState  = _hashStates[currentWorld][1];

            if (plannedWeekState != null)
            {
                plannedWeekState.Calculate();
            }
            else
            {
                e.Cancel = true;
                return;
            }

            object dataSource = null;

            if (_viewType == ViewType.Weekly)
            {
                List <EmployeeWeekView> weekViews = new List <EmployeeWeekView>();

                if (plannedWeekState.List != null)
                {
                    foreach (EmployeeWeek ew in plannedWeekState.List)
                    {
                        Employee emp = ClientEnvironment.EmployeeService.FindById(ew.EmployeeId);
                        weekViews.Add(
                            new EmployeeWeekView(_timeRecordingContext, ew, actualWeekState[ew.EmployeeId],
                                                 emp.OrderHwgrID ?? 0));
                    }
                }

                // acpro #125528
                dataSource = SortUtils <EmployeeWeekView> .Sort(weekViews, _sortFields);

                _weeklyPrintout.StoreToWorldID = currentWorld.ID;
            }
            else
            {
                if (plannedWeekState.List != null)
                {
                    // acpro #125528
                    dataSource =
                        SortUtils <EmployeeWeek> .Sort(
                            plannedWeekState.List.FindAll(
                                delegate(EmployeeWeek ew) { return(ew.IsHasWorldByDate(currentWorld.ID, _viewDate)); }),
                            _sortFields);
                }
            }

            subreportDetails.ReportSource.PaperKind = PaperKind;
            subreportDetails.ReportSource.Landscape = Landscape;

            subreportDetails.ReportSource.DataSource = dataSource;
        }
Beispiel #2
0
        private void ClearContext()
        {
            if (_PlanningWorldState != null)
            {
                _PlanningWorldState.Context = null;
                _PlanningWorldState         = null;
            }
            if (_ActualWorldState != null)
            {
                _ActualWorldState.Context = null;
                _ActualWorldState         = null;
            }
            //_storetimeinfo = null;

            Modified = false;
            OnChangedContext();
        }
Beispiel #3
0
        public void SetCountryAndStore(long countryid, long storeid)
        {
            if (CountryId != countryid)
            {
                _countryID              = countryid;
                Absences.CountryId      = CountryId;
                WorkingModels.CountryId = CountryId;
                CountryColors.CountryId = CountryId;
                LongAbsences.CountryId  = CountryId;
            }

            if (StoreId != storeid)
            {
                _storeID            = storeid;
                _planningWorldState = null;
                _actualWorldState   = null;
                LoadStoreDayInfo();
            }
        }
Beispiel #4
0
        public void LoadEmployeePlanningAndRecording(StoreToWorld world)
        {
            _currentWorldID = 0;

            if (world != null)
            {
                _currentWorldID = world.WorldID;

                List <EmployeeWeek> planningWeeks = ClientEnvironment.EmployeeService.GetTimePlannignEmployeeByWorld2(StoreId, _currentWorldID, BeginWeekDate, EndWeekDate);
                Absences.FillEmployeeWeek(planningWeeks);
                _planningWorldState = new StoreWorldWeekState(world, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsPlannedWeek(planningWeeks);

                if (planningWeeks != null)
                {
                    _planningWorldState.List.AddRange(planningWeeks);
                    foreach (EmployeeWeek ew in planningWeeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _planningWorldState.Context = this;
                _planningWorldState.Calculate();

                planningWeeks = ClientEnvironment.EmployeeService.GetTimeRecordingEmployeeByWorld(StoreId, _currentWorldID, BeginWeekDate, EndWeekDate);
                Absences.FillEmployeeWeek(planningWeeks);
                _actualWorldState = new StoreWorldWeekState(world, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsRecordingWeek(planningWeeks);
                if (planningWeeks != null)
                {
                    _actualWorldState.List.AddRange(planningWeeks);
                    foreach (EmployeeWeek ew in planningWeeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _actualWorldState.Context = this;
                _actualWorldState.Calculate();
            }
        }
        private void LoadData()
        {
            // Worlds
            List <StoreToWorld> worldsDataSource;

            if (_storeToWorldIDs == null)
            {
                worldsDataSource = ClientEnvironment.StoreToWorldService.FindAllForStore(_storeID);
            }
            else
            {
                worldsDataSource = ClientEnvironment.StoreToWorldService.FindByIDList(new List <long>(_storeToWorldIDs));
            }


            //
            // Planning Context
            //
            _timeRecordingContext = new WorldsTimeRecordingPrintoutContext(_countryID, _storeID, _startDate, _viewDate);
            List <long> spanIDs = new List <long>();

            foreach (StoreToWorld world in worldsDataSource)
            {
                _timeRecordingContext.LoadEmployeePlanningAndRecording(world);
                StoreWorldWeekState[] state = new StoreWorldWeekState[] { _timeRecordingContext.WorldPlanningState,
                                                                          _timeRecordingContext.WorldActualState };
                _hashStates[world] = state;
                if (state[0].List == null || state[0].List.Count == 0 ||
                    state[1].List == null || state[1].List.Count == 0)
                {
                    spanIDs.Add(world.ID);
                }
            }
            worldsDataSource.RemoveAll(delegate(StoreToWorld stw) { return(spanIDs.Contains(stw.ID)); });
            worldsDataSource.Sort(new WorldComparer());
            DataSource = worldsDataSource;


            field_WorldName.DataBindings.Add("Text", DataSource, "WorldName", Localizer.GetLocalized("World") + ": {0}");
        }
Beispiel #6
0
        public void SetCountryAndStore(long countryid, long storeid)
        {
            if (CountryId != countryid)
            {
                _CountryId              = countryid;
                Absences.CountryId      = CountryId;
                WorkingModels.CountryId = CountryId;
                CountryColors.CountryId = CountryId;
                LongAbsences.CountryId  = CountryId;
            }

            if (StoreId != storeid)
            {
                QuestionToSaveAndSave();

                _StoreId      = storeid;
                m_storeworlds = _StoreService.StoreToWorldService.FindAllForStore(StoreId);

                if (m_storeworlds != null)
                {
                    m_storeworlds.Sort(new StoreToWorldSorter());
                }

                //_WorldId = _StoreWorldId = 0;
                _CurrentStoreWorld  = null;
                _PlanningWorldState = _ActualWorldState = null;
                LoadStoreDayInfo();

                _storetimeinfo = _StoreService.GetStoreTimeEnvironment(StoreId);


                DisplayWarningMessage();

                OnChangedContext();
            }
        }
Beispiel #7
0
        private void LoadEmployeePlanningAndRecording(bool bLoadStoreDays)
        {
            ClearContext();

            if (bLoadStoreDays)
            {
                LoadStoreDayInfo();
            }

            ErrorCode = ErrorCodes.Empty;
            if (m_storedays.IsUndefined())
            {
                ErrorCode |= ErrorCodes.NotExistsOpenTime;
            }
            if (m_storedays.AvgDayInWeek == 0)
            {
                ErrorCode |= ErrorCodes.NotExistsAvgDaysPerWeek;
            }

            if (ErrorCodes.Empty != ErrorCode)
            {
                ProcessError();
                return;
            }

            if (CurrentStoreWorld != null)
            {
                List <EmployeeWeek> planningweeks = _EmployeeService.GetTimePlannignEmployeeByWorld2(StoreId, WorldId, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsPlannedWeek(planningweeks);

                Absences.FillEmployeeWeek(planningweeks);

                _PlanningWorldState = new StoreWorldWeekState(CurrentStoreWorld, BeginWeekDate, EndWeekDate);

                if (planningweeks != null)
                {
                    _PlanningWorldState.List.AddRange(planningweeks);
                    foreach (EmployeeWeek ew in planningweeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _PlanningWorldState.Context = this;
                _PlanningWorldState.Calculate();


                planningweeks = _EmployeeService.GetTimeRecordingEmployeeByWorld(StoreId, WorldId, BeginWeekDate, EndWeekDate);
                EmployeeWeekProcessor.MarkAsRecordingWeek(planningweeks);
                Absences.FillEmployeeWeek(planningweeks);

                _ActualWorldState = new StoreWorldWeekState(CurrentStoreWorld, BeginWeekDate, EndWeekDate);

                if (planningweeks != null)
                {
                    _ActualWorldState.List.AddRange(planningweeks);
                    foreach (EmployeeWeek ew in planningweeks)
                    {
                        ew.InitWeekState();
                    }
                }

                _ActualWorldState.PlannedWorld = false;
                _ActualWorldState.Context      = this;
                _ActualWorldState.Calculate();


                WorldPlanningInfo infoworld =
                    _StoreService.StoreToWorldService.GetStoreWorldPlanningInfo(false, StoreId, WorldId, BeginWeekDate);



                _ActualWorldState.StoreWorldInfo   = infoworld;
                _PlanningWorldState.StoreWorldInfo = infoworld;

                FillRecordingWorldInfoFromPlanningInfo();

                Modified = false;
                OnChangedContext();
            }
        }