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();
            }
        }
        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();
            }
        }
        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}");
        }