public StoreToWorld GetById(long id) { StoreToWorld sw = null; if (_dictionentity.TryGetValue(id, out sw)) { return(sw); } return(null); }
private void context_WorldChanged(object sender, EventArgs e) { StoreToWorld world = m_context.TakeStoreWorld.GetWorld(m_context.StoreToWorldID); bool realWorld = world != null, anyWgr = m_context.TakeStoreStructure.IsAnyWgr; nbi_ViewMinMax.Enabled = realWorld; nbi_ViewHistory.Enabled = realWorld && world.IsWorld && anyWgr; nbi_AssignWgr.Enabled = nbi_AssignHwgr.Enabled = realWorld && world.IsWorld && anyWgr; }
public WorldType GetWorldType(long storeworldid) { StoreToWorld sw = GetById(storeworldid); if (sw != null) { return(Worlds.GetWorldType(sw.WorldID)); } throw new NullReferenceException(); }
public World GetByStoreToWorldID(long storeToWorldID) { //return RemoteService.GetByStoreToWorldID(storeToWorldID); StoreToWorld sw = ClientEnvironment.StoreToWorldService.FindById(storeToWorldID); if (sw == null) { return(null); } return(FindById(sw.WorldID)); }
public long GetStoreWorldIdByWorldId(long id) { StoreToWorld sw = null; if (_dictionworld.TryGetValue(id, out sw)) { return(sw.ID); } return(0); }
public WorldAvailableBufferHoursManager(StoreToWorld storeworld, int year) : this() { Debug.Assert(storeworld != null); StoreWorld = storeworld; CurrentDate = DateTimeHelper.GetBeginYearDate(year); Debug.Assert(year == Year); LoadBufferHours(); }
public WorldAvailableBufferHoursManager(StoreToWorld storeworld, BufferHours entity) : this() { Debug.Assert(entity != null); Debug.Assert(storeworld != null); StoreWorld = storeworld; BufferHours = entity; CurrentDate = DateTimeHelper.GetBeginYearDate(entity.Year); Debug.Assert(entity.Year == Year); CheckBufferHours(); }
public string GetWorldNameById(long id) { StoreToWorld sw = GetById(id); if (sw == null) { return(String.Empty); } else { return(_worldDiction.GetNameById(sw.WorldID)); } }
public bool IsExistsWorldAssignment(StoreToWorld sw, DateTime begin, DateTime end) { bool b = false; foreach (EmployeeRelation rel in this) { b = DateTimeHelper.IsIntersectExc(begin, end, rel.BeginTime, rel.EndTime); if (rel.WorldID.HasValue && rel.StoreID == sw.StoreID && rel.WorldID == sw.WorldID && b) { return(true); } } return(false); }
public StoreWorldWeekState(StoreToWorld storeworld, DateTime begin, DateTime end) { StoreWorld = storeworld; Debug.Assert(begin < end); Debug.Assert(begin.DayOfWeek == DayOfWeek.Monday); Debug.Assert(end.DayOfWeek == DayOfWeek.Sunday); BeginWeekDate = begin; EndWeekDate = end; for (int i = 0; i < 7; i++) { datas[i] = new int[24]; } }
private void cms_Opening(object sender, CancelEventArgs e) { StoreToWorld entity = m_context.TakeStoreWorld.GetWorld(m_context.StoreToWorldID); e.Cancel = false; if (entity == null || entity.WorldTypeID != WorldType.World) { e.Cancel = true; } if (isUserStoreAdministrator) { ts_AssignHwgr.Visible = false; } e.Cancel = e.Cancel || !m_context.TakeStoreStructure.IsAnyWgr; }
public void AddList(List <StoreToWorld> lst) { if (lst != null) { StoreToWorld sw = null; for (int i = 0; i < lst.Count; i++) { sw = lst[i]; if (!_list.ContainsKey(sw.ID)) { _list[sw.ID] = sw; sw.WorldName = _worldDiction.GetNameById(sw.WorldID); } } } }
public long GetStoreWorldIdByStoreAndWorldId(long storeid, long worldid) { Dictionary <long, StoreToWorld> dict = null; StoreToWorld entity = null; if (_dictionbyStore.TryGetValue(storeid, out dict)) { dict.TryGetValue(worldid, out entity); return((entity != null) ? entity.ID : 0); } else { return(LoadByStore(storeid, worldid)); } }
private void subreportDetails_BeforePrint(object sender, PrintEventArgs e) { StoreToWorld currentWorld = (StoreToWorld)GetCurrentRow(); StoreWorldWeekPlanningState weekPlanningState = _bindingHash[currentWorld]; if (weekPlanningState != null) { weekPlanningState.Calculate(); } else { e.Cancel = true; return; } object dataSource; if (_viewType == ViewType.Weekly) { // acpro #125528 dataSource = SortUtils <EmployeePlanningWeek> .Sort(weekPlanningState.List, _sortFields); BuildWeeklyReport(currentWorld.ID); } else { EmployeeDayViewList dayViewList = weekPlanningState.GetDailyListView(_viewDate); if (dayViewList == null) { e.Cancel = true; return; } // acpro #125528 dataSource = SortUtils <EmployeePlanningWeek> .Sort(dayViewList.DayWeeklyList, _sortFields); BuildDailyReport(dayViewList); } subreportDetails.ReportSource.PaperKind = PaperKind; subreportDetails.ReportSource.Landscape = Landscape; subreportDetails.ReportSource.DataSource = dataSource; }
private void FillStoreWorldEstimateData(StoreWorldPlanningInfo worldinfo, StoreToWorld storeworld, DateTime begin, DateTime end) { //IList lst = _storetoworldservice.GetEstimatedWorldWorkingHours(begin, end, storeworld.StoreID, storeworld.WorldID); //if (lst != null) //{ // if (_trendhelper == null) // { // _trendhelper = new TrendCorrectionHelper(_storeservice.TrendCorrectionService); // _trendhelper.LoadByStoreAndDateRange(storeworld.StoreID, begin, end); // } // bool isExistsTrendCorrection = _trendhelper.IsExistsForWorld(storeworld.ID); // decimal trendcorrection = 1; // foreach (EstimatedWorldWorkingHours workinghours in lst) // { // if (isExistsTrendCorrection) // { // trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, workinghours.Date)); // worldinfo.SetTargetedHoursByDate(workinghours.Date, (int)(workinghours.WorkingHours * 60 * trendcorrection)); // } // else // worldinfo.SetTargetedHoursByDate(workinghours.Date, (int)(workinghours.WorkingHours * 60)); // } //} WeeklyEstimatedWorldHoursBuilder estimateLoader = new WeeklyEstimatedWorldHoursBuilder(); estimateLoader.AssignTrendCorrecttionHelper(_trendhelper); int[] days = estimateLoader.BuildWeek(storeworld, begin); worldinfo.SetTargetedHours(days); //if (lst != null && estimateLoader.EstimatedHours != null) //{ // if (lst.Count == estimateLoader.EstimatedHours.Count) // { // for (int i = 0; i < 7; i++) // { // Debug.Assert(worldinfo.TargetedHours[i] == days[i]); // } // } //} }
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 WorldPlanningInfo GetWorldInfo(StoreToWorld storeworld, DateTime beginWeekDate) { Debug.Assert(beginWeekDate.DayOfWeek == DayOfWeek.Monday); if (storeworld == null) { throw new ArgumentException(); } StoreId = storeworld.StoreID; if (storeworld.WorldTypeID == WorldType.CashDesk) { return(GetCashDeskInfo(storeworld, beginWeekDate)); } else { DateTime endWeekDate = DateTimeHelper.GetSunday(beginWeekDate); StoreWorldPlanningInfo worldinfo = new StoreWorldPlanningInfo(); worldinfo.StoreWorldId = storeworld.ID; FillCommonInfoForWorld(worldinfo, storeworld, beginWeekDate, endWeekDate); IList listSums = _storetoworldservice.GetBusinessVolumes(IsPlanning, beginWeekDate, endWeekDate, storeworld.StoreID, storeworld.WorldID); if (listSums != null && listSums.Count == 1) { BusinessVolumeTargActSum targsum = listSums[0] as BusinessVolumeTargActSum; if (targsum != null) { worldinfo.TargetedNetPerformancePerHour = targsum.VolumeBC; } } // for recording don't need load estimated (targeted hours) // will be used hours from planning if (IsPlanning) { FillStoreWorldEstimateData(worldinfo, storeworld, beginWeekDate, endWeekDate); } return(worldinfo); } }
bool InsertEntity() { if (EntityBenchmark == null || EntityBenchmark.IsNew) { Benchmark bench = ClientEnvironment.StoreService.BenchmarkService.CreateEntity(); bench.StoreWorldID = StoreWorldId; bench.Year = Year; bench.Value = Value; try { List <Benchmark> cols = ClientEnvironment.StoreService.BenchmarkService.GetBenchmarkFiltered(_store.ID, Year, Year); if (cols == null || cols.Count == 0 || !CheckExistStoreWorldID(bench.StoreWorldID, cols)) { bench = ClientEnvironment.StoreService.BenchmarkService.Save(bench); StoreToWorld sw = (StoreToWorld)lookUpWorlds.Properties.GetDataSourceRowByKeyValue(StoreWorldId); if (sw != null) { bench.WorldName = sw.WorldName; } _entity = bench; _modified = true; return(true); } else { throw new DBDuplicateKeyException(); } } catch (DBDuplicateKeyException) { ErrorMessage(GetLocalized("WorldYearBenchmarkExist"), GetLocalized("Attention")); return(false); } } return(true); }
private void FillEmployeeDayByStoreDay(long storeid, DateTime aBegin, DateTime aEnd) { long countryid = EmployeeService.StoreService.GetCountryByStoreId(storeid); List <StoreToWorld> lst = EmployeeService.StoreWorldService.FindAllForCountry(countryid); Dictionary <long, StoreToWorld> _diction = new Dictionary <long, StoreToWorld>(); if (lst != null) { foreach (StoreToWorld sw in lst) { _diction[sw.ID] = sw; } } StoreDaysList dayslist = EmployeeService.StoreService.GetStoreDays(storeid, aBegin, aEnd); Dictionary <long, StoreDaysList> _dictionDays = new Dictionary <long, StoreDaysList>(); _dictionDays[storeid] = dayslist; if (_listweeks != null) { foreach (EmployeeWeek ew in _listweeks) { foreach (EmployeeDay ed in ew.DaysList) { if (ed.StoreWorldId > 0) { StoreToWorld sw = _diction[ed.StoreWorldId]; if (!_dictionDays.TryGetValue(sw.StoreID, out dayslist)) { dayslist = EmployeeService.StoreService.GetStoreDays(sw.StoreID, aBegin, aEnd); _dictionDays[sw.StoreID] = dayslist; } if (_dictionDays.TryGetValue(sw.StoreID, out dayslist)) { ed.StoreDay = dayslist[ed.Date]; } } } } } }
private long LoadByStore(long storeid, long worldid) { List <StoreToWorld> lst = _service.FindAllForStore(storeid); StoreToWorld entity = null; Dictionary <long, StoreToWorld> newitem = new Dictionary <long, StoreToWorld>(); if (lst != null) { foreach (StoreToWorld sw in lst) { newitem[sw.WorldID] = sw; _dictionentity[sw.ID] = sw; if (sw.WorldID == worldid) { entity = sw; } } } _dictionbyStore[storeid] = newitem; return((entity != null) ? 0 : entity.ID); }
public bool TestAndCompare2(StoreToWorld storeworld, int year) { bool equal = true; #if DEBUG DateTime begin = DateTimeHelper.GetBeginYearDate(year); DateTime end = DateTimeHelper.GetEndYearDate(year); int count_weeks = DateTimeHelper.GetCountWeekInYear(year); int[] sums = new int[count_weeks]; int[] sums2 = new int[count_weeks]; DateTime date = begin; EstimatedWorldHoursBuilder b = new EstimatedWorldHoursBuilder(); EstimatedWorldHoursBuilder2 b2 = new EstimatedWorldHoursBuilder2(); for (int i = 0; i < count_weeks; i++) { sums[i] = b.Build(storeworld, date, DateTimeHelper.GetSunday(date)); sums2[i] = b2.Build(storeworld, date, DateTimeHelper.GetSunday(date)); date = DateTimeHelper.GetNextMonday(date); } int[] sums3 = BuildYear(storeworld, year); for (int i = 0; i < count_weeks; i++) { Debug.WriteLine(sums[i].ToString() + " ----------------- " + sums2[i] + " ----- " + sums[i]); Debug.Assert(sums[i] == sums2[i]); Debug.Assert(sums[i] == sums3[i]); Debug.Assert(sums2[i] == sums3[i]); equal &= (sums[i] == sums2[i]) & (sums2[i] == sums3 [i]); } #endif return(equal); }
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(); } }
public int[] BuildWeek(StoreToWorld storeworld, DateTime monday) { return(BuildWeek(storeworld.StoreID, storeworld.WorldID, storeworld.ID, monday)); }
private void FillCashDeskEstimateData(CashDeskPlanningInfo cashdesk, StoreToWorld storeworld, DateTime begin, DateTime end) { Debug.Assert(cashdesk != null); Debug.Assert(begin < end); Debug.Assert(begin.DayOfWeek == DayOfWeek.Monday); Debug.Assert(end.DayOfWeek == DayOfWeek.Sunday); if (cashdesk == null) { return; } if (_trendhelper == null) { _trendhelper = new TrendCorrectionHelper(_storeservice.TrendCorrectionService); _trendhelper.LoadByStoreAndDateRange(storeworld.StoreID, begin, end); } bool isExistsTrendCorrection = _trendhelper.IsExistsForWorld(storeworld.ID); decimal trendcorrection = 1; IList lst = _storetoworldservice.GetCashDeskPeopleEstimated(begin, end, storeworld.StoreID); if (lst != null) { foreach (CashDeskPeoplePerHourEstimateShort cashdeskitem in lst) { if (isExistsTrendCorrection) { trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, cashdeskitem.Date)); cashdeskitem.PeoplePerHour = Convert.ToInt16(cashdeskitem.PeoplePerHour * trendcorrection); cashdeskitem.TargReceiptsPerHour = cashdeskitem.TargReceiptsPerHour * trendcorrection; cashdesk.AddCashDeskItem(cashdeskitem); } else { cashdesk.AddCashDeskItem(cashdeskitem); } } } EstimatedWorldHoursBuilder2 estimatedHoursLoader = new EstimatedWorldHoursBuilder2(); estimatedHoursLoader.AssignTrendCorrecttionHelper(_trendhelper); cashdesk.SumPlannedWorkingHours = estimatedHoursLoader.Build(storeworld, begin, end); //IList list = _storetoworldservice.GetEstimatedWorldWorkingHours(begin, end, storeworld.StoreID, storeworld.WorldID); //if (list != null) //{ // int totalTime = 0; // foreach (EstimatedWorldWorkingHours workinghours in list) // { // if (isExistsTrendCorrection) // { // trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, workinghours.Date)); // } // totalTime += (int)(workinghours.WorkingHours * 60 * trendcorrection); // } // cashdesk.SumPlannedWorkingHours = totalTime; //} }
public static void RecalculateAfterModifiedContractEndDate(long[] emplids) { ILog Log = LogManager.GetLogger("EmployeeBusinessObject"); if (emplids == null || emplids.Length == 0) { Log.Debug("RecalculateAfterModifiedContractEndDate - Count of employees = 0"); return; } CacheListEmployeeContracts contracts = new CacheListEmployeeContracts(); contracts.LoadByEmployees(emplids); if (Log.IsDebugEnabled) { Log.Debug("Load contracts by long[] ids of employees"); } CacheListEmployeeRelations relations = new CacheListEmployeeRelations(); relations.LoadByEmployees(emplids); if (Log.IsDebugEnabled) { Log.Debug("Load relations by long[] ids of employees"); } #region debug checking #if DEBUG { //for (int i = 0; i < emplids.Length; i++) //{ // ListEmployeeContracts contract_list1 = contracts[emplids[i]]; // ListEmployeeRelations relation_list1 = relations[emplids[i]]; // if (contract_list1 == null && relation_list1 == null) // { // Log.Debug("Employee (" + emplids[i].ToString() + ") don't have contract and relation"); // } // if (contract_list1 == null) // { // Log.Debug("Employee (" + emplids[i].ToString() + ") don't have contract"); // } // if (relation_list1 == null) // { // Log.Debug("Employee (" + emplids[i].ToString() + ") don't have relation"); // } // DateTime lastContractDate = contract_list1.GetLastContractDate(); // DateTime lastRelationDate = relation_list1.GetLastRelationDate(); // if (lastContractDate != lastRelationDate) // { // Log.Debug(String.Format("Employee({0}) has not equal contract and relation end date: {1} and {2}", emplids[i], lastContractDate.ToShortDateString(), lastRelationDate.ToShortDateString())); // } //} } #endif #endregion Dictionary <long, DateTime> setStoreWorlds = new Dictionary <long, DateTime>(); Dictionary <long, DateTime> setStores = new Dictionary <long, DateTime>(); ListEmployeeContracts contract_list = null; DateTime last_contract_date; SrvEmployeeWeekRecordingList recording_weeks = new SrvEmployeeWeekRecordingList(); recording_weeks.InitList(emplids, DateTimeSql.FirstMinMonday); SrvEmployeeWeekPlanningList planning_weeks = new SrvEmployeeWeekPlanningList(emplids, DateTimeSql.FirstMinMonday); foreach (long employeeid in emplids) { Employee employee = ServerEnvironment.EmployeeService.FindById(employeeid); if (employee == null) { Log.Warn(String.Format("Employee({0}) not found !!!", employeeid)); continue; } setStores[employee.MainStoreID] = DateTime.Today; if (Log.IsDebugEnabled) { String debugMessage = String.Format(" Process {0}({1}) ( {2} )", employee.FullName, employee.PersID, employee.PersNumber); Log.Debug(debugMessage); } contract_list = contracts[employeeid]; if (contract_list == null || contract_list.Count == 0) { continue; } last_contract_date = contract_list.GetLastContractDate(); last_contract_date = last_contract_date.AddDays(1); last_contract_date = last_contract_date.Date; EmployeePlanningDayListEx planning_days = new EmployeePlanningDayListEx(employeeid, last_contract_date); foreach (EmployeeDayStatePlanning day in planning_days) { if (last_contract_date <= day.Date) { if (setStoreWorlds.ContainsKey(day.StoreWorldId)) { DateTime date = setStoreWorlds[day.StoreWorldId]; if (last_contract_date < date) { setStoreWorlds[day.StoreWorldId] = last_contract_date; } } else { setStoreWorlds[day.StoreWorldId] = last_contract_date; } } } EmployeeRecordingDayListEx recording_days = new EmployeeRecordingDayListEx(employeeid, last_contract_date, DateTimeSql.SmallDatetimeMax); foreach (EmployeeDayStateRecording day in recording_days) { if (last_contract_date <= day.Date) { if (setStoreWorlds.ContainsKey(day.StoreWorldId)) { DateTime date = setStoreWorlds[day.StoreWorldId]; if (last_contract_date < date) { setStoreWorlds[day.StoreWorldId] = last_contract_date; } } else { setStoreWorlds[day.StoreWorldId] = last_contract_date; } } } recording_weeks.ValidateWeekWithContractEnd(employeeid, last_contract_date); planning_weeks.ValidateWeekWithContractEnd(employeeid, last_contract_date); if (recording_days.Count > 0) { recording_days.RemoveFromDatabase(last_contract_date, DateTimeSql.SmallDatetimeMax); } if (planning_days.Count > 0) { planning_days.RemoveFromDatabase(last_contract_date, DateTimeSql.SmallDatetimeMax); } ClearEmployeeTimes(employeeid, last_contract_date, DateTimeSql.SmallDatetimeMax); if (last_contract_date.DayOfWeek != DayOfWeek.Monday) { DateTime monday = DateTimeHelper.GetMonday(last_contract_date); DateTime sunday = DateTimeHelper.GetSunday(monday); planning_days = new EmployeePlanningDayListEx(employeeid, monday, sunday); EmployeeWeekTimePlanning week_planning = planning_weeks.GetByDate(employeeid, monday); if (week_planning != null) { week_planning.PlannedHours = 0; week_planning.WorkingHours = 0; week_planning.AdditionalCharge = 0; int prevSaldo = week_planning.GetPrevSaldo(); foreach (EmployeeDayStatePlanning e in planning_days) { week_planning.PlannedHours += e.AllreadyPlannedHours; week_planning.WorkingHours += e.WorkingHours; week_planning.AdditionalCharge += e.SumOfAddHours; } week_planning.CalculateSaldo(prevSaldo); ServerEnvironment.EmployeeWeekTimePlanningService.Update(week_planning); } recording_days = new EmployeeRecordingDayListEx(employeeid, monday, sunday); EmployeeWeekTimeRecording week_recording = recording_weeks.GetByDate(employeeid, monday); if (week_recording != null) { week_recording.PlannedHours = 0; week_recording.WorkingHours = 0; week_recording.AdditionalCharge = 0; int prevSaldo = week_recording.GetPrevSaldo(); foreach (EmployeeDayStateRecording e in recording_days) { week_recording.PlannedHours += e.AllreadyPlannedHours; week_recording.WorkingHours += e.WorkingHours; week_recording.AdditionalCharge += e.SumOfAddHours; } week_recording.CalculateSaldo(prevSaldo); ServerEnvironment.EmployeeWeekTimeRecordingService.Update(week_recording); } } } List <StoreToWorld> lst = ServerEnvironment.StoreToWorldService.FindAll(); Dictionary <long, StoreToWorld> dc = new Dictionary <long, StoreToWorld>(); if (lst != null) { foreach (StoreToWorld sw in lst) { dc[sw.ID] = sw; } } //setStores.Clear(); StoreToWorld sw1 = null; foreach (long swid in setStoreWorlds.Keys) { if (dc.TryGetValue(swid, out sw1)) { setStores[sw1.StoreID] = DateTime.Today; } } foreach (long storeid in setStores.Keys) { StoreBufferHoursAvailableManager.UpdateWholeYear(storeid, 2008); } }
public WorldPlanningInfo GetWorldInfo(StoreToWorld storeworld, DateTime beginWeekDate) { Debug.Assert(beginWeekDate.DayOfWeek == DayOfWeek.Monday); if (storeworld == null) { throw new ArgumentException(); } StoreId = storeworld.StoreID; if (storeworld.WorldTypeID == WorldType.CashDesk) { return GetCashDeskInfo(storeworld, beginWeekDate); } else { DateTime endWeekDate = DateTimeHelper.GetSunday(beginWeekDate); StoreWorldPlanningInfo worldinfo = new StoreWorldPlanningInfo(); worldinfo.StoreWorldId = storeworld.ID; FillCommonInfoForWorld(worldinfo, storeworld, beginWeekDate, endWeekDate); IList listSums = _storetoworldservice.GetBusinessVolumes(IsPlanning, beginWeekDate, endWeekDate, storeworld.StoreID, storeworld.WorldID); if (listSums != null && listSums.Count == 1) { BusinessVolumeTargActSum targsum = listSums[0] as BusinessVolumeTargActSum; if (targsum != null) worldinfo.TargetedNetPerformancePerHour = targsum.VolumeBC; } // for recording don't need load estimated (targeted hours) // will be used hours from planning if (IsPlanning) { FillStoreWorldEstimateData(worldinfo, storeworld, beginWeekDate, endWeekDate); } return worldinfo; } }
private void FillCommonInfoForWorld(WorldPlanningInfo worldinfo, StoreToWorld storeworld, DateTime begin, DateTime end) { short year = (short)DateTimeHelper.GetYearByDate(begin); PersonMinMax personMinMax = ExStoreToWorld.GetPersonMinMax(storeworld, year); WorldAvailableBufferHoursManager availBufferHours = new WorldAvailableBufferHoursManager(storeworld, begin); AvgAmount avgamount = _avgamountservice.GetAvgAmountByYear(CountryId, year); worldinfo.StoreWorldId = storeworld.ID; if (personMinMax != null) { worldinfo.MinimumPresence = personMinMax.Min; worldinfo.MaximumPresence = personMinMax.Max; } if (availBufferHours.BufferHours != null && availBufferHours.BufferHours.Value != 0) { worldinfo.AvailableWorldBufferHours = Convert.ToInt32(availBufferHours.GetPrevAvailableBufferForWeek(begin) + availBufferHours.BufferHoursPerWeek); } else worldinfo.AvailableWorldBufferHours = Int32.MinValue; if (!worldinfo.IsCashDesk) { Benchmark benchmark = ExStoreToWorld.GetBenchmark(storeworld, year);//_benchmarkservice.GetBenchmark(storeworld.ID, year); if (benchmark != null) worldinfo.Benchmark = benchmark.Value; } }
protected void OnChangeWorld(StoreToWorld sw) { if (sw != _currentworld) { _currentworld = sw; ApplyFilterByWorld(); } }
private void btnOK_Click(object sender, EventArgs e) { if (StoreWorldId != -1) { if (Entity == null) { BufferHours bh = new BufferHours(); bh.StoreWorldID = StoreWorldId; bh.Year = Year; bh.Value = Value; bh.ValueWeek = BufferHours.GetWeekStepValue(bh);// Value / DateTimeHelper.GetCountWeekInYear(Year); try { List <BufferHours> cols = ClientEnvironment.StoreService.BufferHoursService.GetBufferHoursFiltered(_store.ID, Year, Year); if (cols == null || cols.Count == 0 || !CheckExistStoreWorldID(bh.StoreWorldID, cols)) { bh = ClientEnvironment.StoreService.BufferHoursService.ValidateAndUpdate(bh); if (bh != null) { StoreToWorld sw = (StoreToWorld)lookUpWorlds.Properties.GetDataSourceRowByKeyValue(StoreWorldId); if (sw != null) { bh.WorldName = sw.WorldName; } _entity = bh; DialogResult = DialogResult.OK; } else { throw new DBDuplicateKeyException(); } } else { throw new DBDuplicateKeyException(); } } catch (DBDuplicateKeyException) { XtraMessageBox.Show(UILocalizer.Current["WorldYearBufferHoursExist"], UILocalizer.Current["Attention"], MessageBoxButtons.OK, MessageBoxIcon.Error); seYear.Focus(); return; } } else { BufferHours bh = new BufferHours(); bh.ID = Entity.ID; bh.StoreWorldID = StoreWorldId; bh.Year = Year; bh.Value = Value; bh.ValueWeek = BufferHours.GetWeekStepValue(bh);// Value / DateTimeHelper.GetCountWeekInYear(Year); try { bh = ClientEnvironment.StoreService.BufferHoursService.ValidateAndUpdate(bh); Entity.ID = bh.ID; Entity.StoreWorldID = StoreWorldId; Entity.Year = Year; Entity.Value = Value; Entity.ValueWeek = BufferHours.GetWeekStepValue(bh); DialogResult = DialogResult.OK; } catch (ValidationException) { XtraMessageBox.Show(UILocalizer.Current["WorldYearBufferHoursExist"], UILocalizer.Current["Attention"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (EntityException) { XtraMessageBox.Show(UILocalizer.Current["BufferHoursNotExist"], UILocalizer.Current["Attention"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } } else { XtraMessageBox.Show(UILocalizer.Current["ErrorSelectWorld"]); } }
public ExStoreToWorld(StoreToWorld sw) { entity = sw; }
public ExStoreToWorld(long storeworldid) { entity = Service.FindById (storeworldid); }
public int[] BuildYear(StoreToWorld storeworld, int year) { return(BuildYear(storeworld.StoreID, storeworld.WorldID, storeworld.ID, year)); }
public int[] BuildYear(StoreToWorld storeworld, int year) { return BuildYear(storeworld.StoreID, storeworld.WorldID, storeworld.ID, year); }
private void ApplyFilterByWorld() { BindingList<BzEmployeeHoliday> worldEmployeesList = null; if (_currentworld == null) { _currentworld = _emptyworld; } _indexEmployeeByWorld.TryGetValue(_currentworld.ID, out worldEmployeesList); if (ViewAbsencePlanning == AbsencePlanningView.WeeklyView) { if (_currentworld != _emptyworld) { BindingList<BzEmployeeHoliday> filteredEmployeesList = new BindingList<BzEmployeeHoliday>(); if (worldEmployeesList != null) { DateTime sunday = CurrentMondayDate.AddDays(6); foreach (BzEmployeeHoliday entity in worldEmployeesList) { if (entity.Relations.IsExistsWorldAssignment(_currentworld, CurrentMondayDate, sunday)) filteredEmployeesList.Add(entity); } } worldEmployeesList = filteredEmployeesList; } } gcAbsencePlanning.DataSource = worldEmployeesList; BuildTotalSums(); }
public bool TestAndCompare2(StoreToWorld storeworld, int year) { bool equal = true; #if DEBUG DateTime begin = DateTimeHelper.GetBeginYearDate(year); DateTime end = DateTimeHelper.GetEndYearDate(year); int count_weeks = DateTimeHelper.GetCountWeekInYear(year); int[] sums = new int[count_weeks]; int[] sums2 = new int[count_weeks]; DateTime date = begin; EstimatedWorldHoursBuilder b = new EstimatedWorldHoursBuilder(); EstimatedWorldHoursBuilder2 b2 = new EstimatedWorldHoursBuilder2(); for (int i = 0; i < count_weeks; i++) { sums[i] = b.Build(storeworld, date, DateTimeHelper.GetSunday(date)); sums2[i] = b2.Build(storeworld, date, DateTimeHelper.GetSunday(date)); date = DateTimeHelper.GetNextMonday(date); } int[] sums3 = BuildYear(storeworld, year); for (int i = 0; i < count_weeks; i++) { Debug.WriteLine(sums[i].ToString() + " ----------------- " + sums2[i] + " ----- " + sums[i]); Debug.Assert(sums[i] == sums2[i]); Debug.Assert(sums[i] == sums3[i]); Debug.Assert(sums2[i] == sums3[i]); equal &= (sums[i] == sums2[i]) & (sums2[i] == sums3 [i]); } #endif return equal; }
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(); }
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(); } } }
private void FillCashDeskEstimateData(CashDeskPlanningInfo cashdesk, StoreToWorld storeworld, DateTime begin, DateTime end) { Debug.Assert(cashdesk != null); Debug.Assert(begin < end); Debug.Assert(begin.DayOfWeek == DayOfWeek.Monday); Debug.Assert(end.DayOfWeek == DayOfWeek.Sunday); if (cashdesk == null) return; if (_trendhelper == null) { _trendhelper = new TrendCorrectionHelper(_storeservice.TrendCorrectionService); _trendhelper.LoadByStoreAndDateRange(storeworld.StoreID, begin, end); } bool isExistsTrendCorrection = _trendhelper.IsExistsForWorld(storeworld.ID); decimal trendcorrection = 1; IList lst = _storetoworldservice.GetCashDeskPeopleEstimated(begin, end, storeworld.StoreID); if (lst != null) { foreach (CashDeskPeoplePerHourEstimateShort cashdeskitem in lst) { if (isExistsTrendCorrection) { trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, cashdeskitem.Date)); cashdeskitem.PeoplePerHour = Convert.ToInt16(cashdeskitem.PeoplePerHour * trendcorrection); cashdeskitem.TargReceiptsPerHour = cashdeskitem.TargReceiptsPerHour * trendcorrection; cashdesk.AddCashDeskItem(cashdeskitem); } else { cashdesk.AddCashDeskItem(cashdeskitem); } } } EstimatedWorldHoursBuilder2 estimatedHoursLoader = new EstimatedWorldHoursBuilder2(); estimatedHoursLoader.AssignTrendCorrecttionHelper(_trendhelper); cashdesk.SumPlannedWorkingHours = estimatedHoursLoader.Build(storeworld, begin, end); //IList list = _storetoworldservice.GetEstimatedWorldWorkingHours(begin, end, storeworld.StoreID, storeworld.WorldID); //if (list != null) //{ // int totalTime = 0; // foreach (EstimatedWorldWorkingHours workinghours in list) // { // if (isExistsTrendCorrection) // { // trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, workinghours.Date)); // } // totalTime += (int)(workinghours.WorkingHours * 60 * trendcorrection); // } // cashdesk.SumPlannedWorkingHours = totalTime; //} }
private CashDeskPlanningInfo GetCashDeskInfo(StoreToWorld storeworld, DateTime beginWeekDate) { if (storeworld == null) throw new ArgumentNullException(); if (storeworld.WorldTypeID != WorldType.CashDesk) throw new ArgumentException("storeworld must be cashdesk"); DateTime endWeekDate = DateTimeHelper.GetSunday (beginWeekDate ); CashDeskPlanningInfo worldinfo = new CashDeskPlanningInfo(); worldinfo.StoreWorldId = storeworld.ID; FillCommonInfoForWorld(worldinfo, storeworld, beginWeekDate, endWeekDate); if (IsPlanning) { FillCashDeskEstimateData(worldinfo, storeworld, beginWeekDate, endWeekDate); } return worldinfo; }
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(); } }
protected override void readCSVFile(CachedCsvReader csv) { #if(UseHeaders) int worldIDIndex = csv.GetFieldIndex(_WorldID); int worldNameIndex = csv.GetFieldIndex(_WorldName); #else int worldIDIndex = _WorldIDIndex; int worldNameIndex = _WorldNameIndex; #endif Dictionary<string, World> dbWorldHash = getDBWorldHash(); Dictionary<long, Store> dbStoreHash = getDBStoreList(); Dictionary<string, StoreToWorld> dbStore_WorldHash = getStore_WorldHash(); List<World> worldSaveList = new List<World>(); List<StoreToWorld> store_WorldSaveList = new List<StoreToWorld>(); bool isNew= false; while (csv.ReadNextRecord()) { csvDataNextRow(); string worldID = csv[worldIDIndex]; string worldName = csv[worldNameIndex]; string key = worldID; World world; if (dbWorldHash.ContainsKey(key)) { world = dbWorldHash[key]; } else { world = new World(); } world.ExSystemID = int.Parse(worldID); world.LanguageID = SharedConsts.NeutralLangId; world.Name = worldName; world.WorldTypeID = WorldType.World; world.Import = true; if (!worldSaveList.Contains(world)) worldSaveList.Add(world); else message(string.Format(GetLocalized("WorldExists"), _CurrentRow, _WorldID, worldID)); if (world.IsNew && !dbWorldHash.ContainsKey(key)) { dbWorldHash.Add(key, world); isNew= true; } } csvDataEndRead(); SaveOrUpdateList<World>(_IStoreService.WorldService,worldSaveList); if (isNew) dbWorldHash = getDBWorldHash(); foreach (Store store in dbStoreHash.Values) { foreach (World world in dbWorldHash.Values) { string key= store.ID.ToString () + world.ID.ToString (); if (!dbStore_WorldHash.ContainsKey(key)) { StoreToWorld store_world = new StoreToWorld(world.ID, store.ID); store_WorldSaveList.Add(store_world); dbStore_WorldHash.Add(key, store_world); } } } if (dbStoreHash.Count == 0) message(GetLocalized("StoresNotExistsDB")); SaveList<StoreToWorld>(_IStoreService.StoreToWorldService, store_WorldSaveList); }
public StoreWorldWeekState(StoreToWorld storeworld, DateTime begin, DateTime end, bool bPlanned) : this(storeworld, begin,end) { _bPlanned = bPlanned; }
public int Build(StoreToWorld storeworld,DateTime beginWeek, DateTime endWeek) { return Build(storeworld.StoreID, storeworld.WorldID, storeworld.ID, beginWeek, endWeek); }
public bool IsExistsWorldAssignment(StoreToWorld sw) { return(IsExistsWorldAssignment(sw.StoreID, sw.WorldID)); }
public int[] BuildWeek(StoreToWorld storeworld, DateTime monday) { return BuildWeek(storeworld.StoreID, storeworld.WorldID, storeworld.ID, monday); }
public StoreWorldWeekState(StoreToWorld storeworld, DateTime begin, DateTime end, bool bPlanned) : this(storeworld, begin, end) { _bPlanned = bPlanned; }
public virtual int Build(StoreToWorld storeworld, DateTime beginWeek, DateTime endWeek) { return(Build(storeworld.StoreID, storeworld.WorldID, storeworld.ID, beginWeek, endWeek)); }