public EmployeePlanningWeek this[long id] { get { EmployeePlanningWeek result = null; _dictionEmployees.TryGetValue(id, out result); return(result); } set { if (value != null) { EmployeePlanningWeek week = this[id]; if (week != null) { _dictionEmployees.Remove(id); _listemployeesweek.Remove(week); } _dictionEmployees[id] = value; _listemployeesweek.Add(value); } else { throw new NullReferenceException(); } } }
public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date) { int count = planningWeek.CountWorkingSundayAndSaturdayPerMonth; if (Value <= count) { return(true); } if (planningWeek.BeginDate.Month != planningWeek.EndDate.Month) { DateTime dtSaturday = planningWeek.EndDate.AddDays(-1); count = 0; if (planningWeek.BeginDate.Month != dtSaturday.Month) { if (planningWeek.IsSaturdayWorking) { count++; } } if (planningWeek.IsSundayWorking) { count++; } if (Value <= count) { return(true); } } return(false); }
private void CalculateWeeklyMessageOrSaldoWorkingModels(EmployeePlanningWeek planningweek) { if (planningweek.IsValidWeek) { EmployeePlanningDay epday = planningweek.Days[planningweek.EndDate]; EmployeePlanningWorkingModel entity = null; foreach (WorkingModelWrapper wrap in _weeklyMessagesModels) { if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime, planningweek.BeginDate, planningweek.EndDate)) { continue; } if (wrap.Validate(planningweek, planningweek.BeginDate)) { entity = new EmployeePlanningWorkingModel(); entity.EmployeeID = epday.EmployeeId; entity.Date = epday.Date; entity.WorkingModelID = wrap.Model.ID; if (epday.WorkingModels == null) { epday.WorkingModels = new List <EmployeePlanningWorkingModel>(); } epday.WorkingModels.Add(entity); } } } }
public bool Validate(EmployeePlanningWeek employeeweek) { int count = 0; DateTime currentDate = employeeweek.BeginDate; EmployeePlanningDay currentDay = null; EmployeePlanningDay lastWorkingDay = null; Value = employeeweek.ContractHoursPerWeek; for (int i = 0; i < 7; i++) { currentDay = employeeweek.Days[currentDate]; if (currentDay.CountDailyWorkingHours > 0) { count += currentDay.CountDailyWorkingHours; lastWorkingDay = currentDay; } currentDate = currentDate.AddDays(1); } if (count > Value) { int t = count - Value; if (Wrapper.Hours == -1 || Wrapper.Hours > t) { Wrapper.Hours = t; } return(true); } return(false); }
public void SaveEmployeePlanningWeek(EmployeePlanningWeek planningweek) { if (planningweek == null) { throw new ArgumentNullException(); } EmployeeWeekTimePlanning entity = null; entity = GetEmployeeWeekState(planningweek.EmployeeId, planningweek.BeginDate, planningweek.EndDate); if (entity == null) { entity = planningweek.CreateEntity(); entity.ID = 0; } else { planningweek.AssignTo(entity); } entity.WeekNumber = DateTimeHelper.GetWeekNumber(planningweek.BeginDate, planningweek.EndDate); SaveOrUpdate(entity); if (DateTimeHelper.Between(DateTime.Today, planningweek.BeginDate, planningweek.EndDate)) { UpdatePlanningSaldo(entity); } }
private void DrawFixedCells(RowCellCustomDrawEventArgs e) { EmployeePlanningWeek empl = GetEntityByRowHandle(e.RowHandle); if (Context != null) { if (e.Column == gc_PlusMinusHours) { int value = empl.CountWeeklyPlusMinusHours; Color color = Context.CountryColors.GetColorByEmployeePlusMinus(value); e.Appearance.ForeColor = color; } if (e.Column == gc_SummOfAdditionalCharges) { int value = empl.CountWeeklyAdditionalCharges; Color color = Context.CountryColors.GetColorByEmployeeAdditionalCharges(value); e.Appearance.ForeColor = color; } if (e.Column == gc_EmployeeBalanceHours) { int value = empl.Saldo; Color color = Context.CountryColors.GetColorByEmployeeBalanceHours(value); e.Appearance.ForeColor = color; } } Painters.DrawFixedCells(e, empl.FullName, e.RowHandle == gridView.FocusedRowHandle); e.Handled = true; }
public bool Validate(EmployeePlanningWeek employeeweek) { int count = 0; DateTime beginWeek = employeeweek.BeginDate; DateTime currentDate; count = employeeweek.WorkingDaysBefore; for (int i = 0; i < 7; i++) { currentDate = beginWeek.AddDays(i); if (employeeweek.Days[currentDate].CountDailyWorkingHours > 0) { count++; } else { count = 0; } if (count >= Value) { return(true); } } if ((count > 0) && (count + employeeweek.WorkingDaysAfter >= Value)) { return(true); } return(false); }
public bool Validate(EmployeePlanningWeek planningWeek, DateTime date) { _employeeweek = planningWeek; _currentDate = date; _Hours = -1; return(Validate()); }
public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date) { if (planningWeek.Saldo > (int)(Value * 60)) { return(true); } return(false); }
public void SavePlanningWeek(EmployeePlanningWeek week) { Debug.Assert(week != null); Debug.Assert(week.EmployeeId > 0); List <WorkingTimePlanning> list_old = Service.GetWorkingTimeByEmployeeId(week.EmployeeId, week.BeginDate, week.EndDate); List <WorkingTimePlanning> list_new = new List <WorkingTimePlanning>(10); List <WorkingTimePlanning> temp_list = new List <WorkingTimePlanning>(10); foreach (EmployeePlanningDay day in week.Days.Values) { if (day.WorkingTimeList != null) { list_new.AddRange(day.WorkingTimeList); } } if (list_new.Count > 0) { bool bFound = false; foreach (WorkingTimePlanning entity in list_new) { bFound = false; if (list_old != null && list_old.Count > 0) { for (int i = 0; i < list_old.Count; i++) { if (list_old[i] != null && list_old[i].Compare(entity)) { entity.ID = list_old[i].ID; bFound = true; list_old[i] = null; break; } } } if (!bFound) { Service.Save(entity); } } } if (list_old != null) { foreach (WorkingTimePlanning entity in list_old) { if (entity != null) { Service.Delete(entity); } } } }
private void CalculateDailyWorkingModels(EmployeePlanningWeek planningweek) { #region daily calculation if (planningweek.IsValidWeek) { EmployeePlanningWorkingModel entity = null; foreach (EmployeePlanningDay epd in planningweek.Days.Values) { epd.CountDailyAdditionalCharges = 0; epd.WorkingModels = null; // if day don't have - contractr, relation or it under long absence if (epd.IsBlockedDay) { continue; } foreach (WorkingModelWrapper wrap in _dailyModels) { if (!DateTimeHelper.Between(epd.Date, wrap.Model.BeginTime, wrap.Model.EndTime)) { continue; } if (wrap.Validate(planningweek, epd.Date)) { entity = new EmployeePlanningWorkingModel(); entity.EmployeeID = epd.EmployeeId; entity.Date = epd.Date; entity.WorkingModelID = wrap.Model.ID; if (!wrap.IsMessageModel) { entity.Hours = wrap.GetModelValue; entity.AdditionalCharge = wrap.Model.AddCharges; if (wrap.Model.AddCharges) { epd.CountDailyAdditionalCharges += entity.Hours; } else { epd.CountDailyPlannedWorkingHours += entity.Hours; } } if (epd.WorkingModels == null) { epd.WorkingModels = new List <EmployeePlanningWorkingModel>(); } epd.WorkingModels.Add(entity); } } } } #endregion }
private void PrintSummaryCell(object sender, PrintEventArgs args) { XRTableCell cell = (XRTableCell)sender; EmployeePlanningWeek employeeWeek = GetCurrentRow(); if (employeeWeek == null) { return; } switch ((string)cell.Tag) { case PrintoutConst.ContractWorkingHours: cell.Text = DateTimeHelper.IntTimeToStr(employeeWeek.ContractHoursPerWeek); break; case PrintoutConst.AvailableHolidays: cell.Text = DateTimeHelper.DecimalTimeToStr(0); break; case PrintoutConst.PlannedWorkingHours: cell.Text = DateTimeHelper.IntTimeToStr(employeeWeek.CountWeeklyPlanningWorkingHours); break; case PrintoutConst.AdditionalWorkingHours: { if (employeeWeek.AllIn) { cell.Text = "--:--"; } else { cell.Text = DateTimeHelper.IntTimeToStr(employeeWeek.CountWeeklyAdditionalCharges); } } break; case PrintoutConst.PlusMinusHours: cell.Text = DateTimeHelper.IntTimeToStr(employeeWeek.CountWeeklyPlusMinusHours); break; case PrintoutConst.BalanceHours: { if (employeeWeek.AllIn) { cell.Text = "--:--"; } else { cell.Text = DateTimeHelper.IntTimeToStr(employeeWeek.Saldo); } } break; } }
public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date) { int count = 0; foreach (EmployeePlanningDay day in planningWeek.Days.Values) { count += day.CountDailyWorkingHours; } return(Validate(count)); }
public override bool Validate() { EmployeePlanningWeek week = Wrapper.EmployeeWeek; if (week.LastSaldo < week.Saldo) { return(true); } return(false); }
public EmployeeDayView GetEmployeeDayView(int rowhandle) { EmployeePlanningWeek employee = GetEntityByRowHandle(rowhandle); if (employee == null) { return(null); } return(m_dailyView.GetByEmployeeId(employee.EmployeeId)); }
public EmployeePlanningWeek GetEntityByRowHandle(int rowHandle) { if (gridView.IsDataRow(rowHandle)) { EmployeePlanningWeek w = (EmployeePlanningWeek)gridView.GetRow(rowHandle); return(w); } else { return(null); } }
public void Calculate(EmployeePlanningWeek planningweek) { if (_lunchManager != null) { _lunchManager.Process(planningweek); } planningweek.CalculateWithoutWorkingModels(); CalculateDailyWorkingModels(planningweek); CalculateWeeklyWorkingModels(planningweek); planningweek.CalculateAfterWorkingModels(); CalculateWeeklyMessageOrSaldoWorkingModels(planningweek); }
private void tm_ClearTime_Click(object sender, EventArgs e) { if (ReadOnly) { return; } if (gridView.SelectedRowsCount == 1) { GridCell[] cells = gridView.GetSelectedCells(); if (cells != null && cells.Length >= 1) { bool ignore = false; for (int i = 0; i < cells.Length; i++) { if (cells[i].Column.Tag == null) { ignore = true; } } if (!ignore) { EmployeePlanningWeek empl = FocusedEntity; if (empl != null) { EmployeeDayView dayView = m_dailyView.GetByEmployeeId(empl.EmployeeId); if (dayView != null) { int begin = GetColumnInfo(cells[0].Column).FromTime; int end = GetColumnInfo(cells[cells.Length - 1].Column).FromTime; for (int i = begin; i < end + (int)CurrentView; i += (int)CurrentView) { dayView.RemoveWorkingTime(i, i + (int)CurrentView); } if (dayView.Modified) { Context.Modified = true; } } } UpdateEmployeePlanningDays(); return; } } } }
public void Process(EmployeePlanningWeek week) { foreach (EmployeePlanningDay epd in week.Days.Values) { _ApplyLunchBrakeModels(epd, true); epd.CountDailyWorkingHours = 0; epd.UnitPerDay = 0; if (epd.WorkingTimeList != null && epd.WorkingTimeList.Count > 0) { int beginTime = 0, endTime = 0; foreach (WorkingTimePlanning wtp in epd.WorkingTimeList) { epd.CountDailyWorkingHours += wtp.Time; beginTime = wtp.Begin; endTime = wtp.End; beginTime = beginTime / 60; // we need hour if (endTime % 60 != 0) { endTime = (endTime / 60) + 1; } else { endTime = (endTime / 60); } epd.UnitPerDay += (endTime - beginTime); } } _ApplyLunchBrakeModels(epd, false); epd.CountDailyPlannedWorkingHours = epd.CountDailyWorkingHours; if (epd.AbsenceTimeList != null && epd.AbsenceTimeList.Count > 0) { foreach (AbsenceTimePlanning atp in epd.AbsenceTimeList) { if (atp.Absence.UseInCalck) { epd.CountDailyPlannedWorkingHours += (atp.End - atp.Begin); } } } } }
private EmployeePlanningDay ProcessDayCell(XRControl cell) { EmployeePlanningDay result = null; EmployeePlanningWeek employeeWeek = GetCurrentRow(); StoreDay storeDay = _planningContext.StoreDays[(DateTime)cell.Tag]; if (employeeWeek != null && storeDay != null && employeeWeek.Days.ContainsKey(storeDay.Date)) { result = employeeWeek.Days[storeDay.Date]; } ReportPainter.ApplyEmployeePlanningDayStyle(cell, storeDay, result, CurrentWorldID); return(result); }
public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date) { int count = planningWeek.CountWorkingSundayPerMonth; if (Value <= count) { return(true); } if (planningWeek.BeginDate.Month != planningWeek.EndDate.Month) { if (planningWeek.IsSundayWorking && (Value <= 1)) { return(true); } } return(false); }
private void gridViewHalfHour_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) { EmployeePlanningWeek empl = GetEntityByRowHandle(e.RowHandle); EmployeeDayView dayView = null; if (empl != null && m_dailyView != null) { dayView = m_dailyView.GetByEmployeeId(empl.EmployeeId); } if (e.Column == gc_AllreadyPlannedWorkingHours) { if (dayView != null && dayView.PlanningDay != null) { e.Value = DateTimeHelper.IntTimeToStr(dayView.PlanningDay.CountDailyPlannedWorkingHours); } } }
private void CalculateWeeklyWorkingModels(EmployeePlanningWeek planningweek) { if (planningweek.IsValidWeek) { EmployeePlanningDay epday = planningweek.Days[planningweek.EndDate]; EmployeePlanningWorkingModel entity = null; foreach (WorkingModelWrapper wrap in _weeklyModels) { if (!DateTimeHelper.IsIntersectInc(wrap.Model.BeginTime, wrap.Model.EndTime, planningweek.BeginDate, planningweek.EndDate)) { continue; } if (wrap.Validate(/*daysInfo, */ planningweek, planningweek.BeginDate)) { entity = new EmployeePlanningWorkingModel(); entity.EmployeeID = epday.EmployeeId; entity.Date = epday.Date; entity.WorkingModelID = wrap.Model.ID; if (!wrap.IsMessageModel) { entity.AdditionalCharge = wrap.Model.AddCharges; entity.Hours += wrap.GetModelValue;; if (wrap.Model.AddCharges) { epday.CountDailyAdditionalCharges += entity.Hours;// result += DateTimeHelper.RoundToQuoter((short)(60 * wrap.Model.AddValue)); } else { epday.CountDailyPlannedWorkingHours += entity.Hours; //result += DateTimeHelper.RoundToQuoter((short)(wrap.Hours * wrap.Model.MultiplyValue - wrap.Hours)); } } if (epday.WorkingModels == null) { epday.WorkingModels = new List <EmployeePlanningWorkingModel>(); } epday.WorkingModels.Add(entity); } } } }
private void PrintTimeCell(object sender, PrintEventArgs e) { XRTableCell cell = (XRTableCell)sender; EmployeePlanningWeek employeePlanningWeek = GetCurrentEmployeeWeek(); EmployeeDayView dayView = DayViewList.GetByEmployeeId(employeePlanningWeek.EmployeeId); if (dayView == null) { return; } StoreDay storeDay = _planningContext.StoreDays[dayView.ViewDate]; if (storeDay == null) { return; } foreach (XRControl child in cell.Controls) { XRLabel shape = child as XRLabel; TimeCellInfo cellInfo = child.Tag as TimeCellInfo; if (shape == null || cellInfo == null) { continue; } short currentTime = Convert.ToInt16(cellInfo.DayTime.TotalMinutes); Color color = storeDay.IsOpeningTime(currentTime) ? Color.White : Color.LightGray; if (!cellInfo.ManualFill) { Color workingTimeColor = dayView.GetColor(currentTime / 15); if (workingTimeColor != Color.White) { color = workingTimeColor; } } ReportPainter.AcceptShape(shape, cell, color); } }
private void PrintSummaryColumn(object sender, PrintEventArgs e) { XRTableCell cell = (XRTableCell)sender; EmployeePlanningWeek employeePlanningWeek = GetCurrentEmployeeWeek(); if (employeePlanningWeek == null) { return; } EmployeeDayView dayView = DayViewList.GetByEmployeeId(GetCurrentEmployeeWeek().EmployeeId); string cellText = String.Empty; if (dayView != null) { //if(cell == fieldCell_ContractWorkingHours) //{ // cellText = DateTimeHelper.IntTimeToStr(dayView.ContractHoursPerWeek); //} else if(cell == fieldCell_PlannedWorkingHours) //{ // cellText = DateTimeHelper.IntTimeToStr(dayView.TotalWorkingTime); //} else if(cell == fieldCell_SumAdditionalHours) //{ // cellText = DateTimeHelper.IntTimeToStr(dayView.PlanningDay.CountDailyAdditionalCharges); //} else if(cell == fieldCell_PlusMinusHours) //{ // cellText = DateTimeHelper.IntTimeToStr(dayView.PlanningDay.PlanningWeek.CountWeeklyPlusMinusHours); //} else if(cell == fieldCell_BalanceHours) //{ // cellText = DateTimeHelper.IntTimeToStr(dayView.PlanningDay.PlanningWeek.Saldo); //} if (cell == fieldCell_PlannedWorkingHours) { cellText = DateTimeHelper.IntTimeToStr(dayView.PlanningDay.CountDailyPlannedWorkingHours /* TotalWorkingTime*/); } } cell.Text = cellText; }
public virtual void FillPlanningLastSaldo(Dictionary <long, EmployeePlanningWeek> dict, long[] ids, DateTime aBeginWeek) { if (ids == null || ids.Length == 0) { return; } long[][] result = Service.EmployeeTimeSaldoGet(ids, EmployeeTimeSaldoType.Planning, aBeginWeek); long id = 0; long value = 0; EmployeePlanningWeek entity = null; foreach (long[] data in result) { id = (long)data[0]; value = (long)data[1]; if (dict.TryGetValue(id, out entity)) { entity.LastSaldo = (int)value; } } }
public void SaveEmployeeWeek(EmployeePlanningWeek planningweek) { if (planningweek != null) { List <EmployeePlanningWorkingModel> models = new List <EmployeePlanningWorkingModel>(); ClearEmployeeByDateRange(planningweek.EmployeeId, planningweek.BeginDate, planningweek.EndDate); foreach (EmployeePlanningDay day in planningweek.Days.Values) { if (day.WorkingModels != null) { models.AddRange(day.WorkingModels); } } foreach (EmployeePlanningWorkingModel entity in models) { entity.ID = 0; ServiceDao.SaveOrUpdate(entity); } } }
public void FillEmployeePlanningWeeks(List <EmployeePlanningWeek> planningweeks, DateTime beginDate, DateTime endDate) { if (planningweeks != null && planningweeks.Count > 0) { List <long> lstIds = new List <long>(planningweeks.Count); Dictionary <long, EmployeePlanningWeek> _diction = new Dictionary <long, EmployeePlanningWeek>(); foreach (EmployeePlanningWeek epw in planningweeks) { lstIds.Add(epw.EmployeeId); _diction[epw.EmployeeId] = epw; } long[] ids = lstIds.ToArray(); List <EmployeeDayStatePlanning> daystates = GetEmployeesState(ids, beginDate, endDate); if (daystates != null) { EmployeePlanningWeek lastWeek = planningweeks [0]; EmployeePlanningDay day = null; foreach (EmployeeDayStatePlanning edsp in daystates) { if (edsp.EmployeeID != lastWeek.EmployeeId) { lastWeek = _diction[edsp.EmployeeID]; } day = lastWeek.Days[edsp.Date]; day.CountDailyAdditionalCharges = edsp.SumOfAddHours; day.CountDailyPlannedWorkingHours = edsp.AllreadyPlannedHours; day.CountDailyWorkingHours = edsp.WorkingHours; } } } }
public override bool ValidateWeek(EmployeePlanningWeek planningWeek, DateTime date) { return(Validate(planningWeek)); }
public void Calculate(EmployeePlanningWeek planningweek) { }