private void ProcessNotFixedTimeAbsence(Absence absence) { if (absence.WithoutFixedTime) { if (gridView.SelectedRowsCount == 1) { using (FormEnterAbsenceTime form = new FormEnterAbsenceTime()) { if (form.ShowDialog() == DialogResult.OK) { EmployeeDayView dayView = GetEmployeeDayView(); if (dayView != null) { dayView.SetAbsence(absence, form.BeginTime, form.EndTime); if (dayView.Modified) { Context.Modified = true; } UpdateEmployeePlanningDays(); } } } } } }
public static void DrawDailyViewCell(RowCellCustomDrawEventArgs e, int index, DailyViewStyle view, StoreDay storeday, EmployeeDayView dayView) { Rectangle cellBound = Rectangle.Inflate(e.Bounds, 1, 1); e.Cache.FillRectangle(Color.White, cellBound); Rectangle rect; int squareWidth = cellBound.Width; Color squareColor = Color.White; //int index = infoColumn.FromTime / 15; int squareCount = 1; if (view == DailyViewStyle.View30) { cellBound = Rectangle.Inflate(cellBound, -2, 0); squareWidth = ((cellBound.Width - 1) / 2); squareCount = 2; } else if (view == DailyViewStyle.View60) { cellBound = Rectangle.Inflate(cellBound, -2, 0); squareWidth = ((cellBound.Width - 3) / 4); squareCount = 4; } int positionX = cellBound.X; int currentTime = index * 15; Color backColor = Color.White; for (int i = 0; i < squareCount; i++) { currentTime = (index + i) * 15; if (!storeday.IsOpeningTime((short)currentTime)) { backColor = Color.LightGray; } else backColor = Color.White; squareColor = dayView.GetColor(index + i); rect = new Rectangle(positionX, cellBound.Y, squareWidth, cellBound.Height); if (squareColor == Color.White) squareColor = backColor; e.Cache.FillRectangle(squareColor, rect); positionX += squareWidth + 1; } e.Handled = true; }
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; } } } }
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 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; }
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 mi_MarkAsAbsence_Click(object sender, EventArgs e) { using (FormSelectAbsence formSelectAbsence = new FormSelectAbsence()) { formSelectAbsence.IsPlanning = true; formSelectAbsence.Absences = Context.Absences.ToList; StoreDay sd = Context.StoreDays[ViewDate]; formSelectAbsence.ShowTimePanel = false; formSelectAbsence.SetDayInfo(sd.OpenTime, sd.CloseTime, Context.StoreDays.AvgDayInWeek); if (formSelectAbsence.Execute()) { if (gridView.SelectedRowsCount == 1) { EmployeeDayView dayView = GetEmployeeDayView(); //m_dailyView.GetByEmployeeId(empl.EmployeeId); TimeColumnInfo info = null; GridCell[] cells = gridView.GetSelectedCells(); if (dayView != null && cells != null && cells.Length > 0) { foreach (GridCell cell in cells) { info = GetColumnInfo(cell.Column); if (info != null) { dayView.SetAbsence(formSelectAbsence.SelectedAbsence, info.FromTime, info.ToTime); } } if (dayView.Modified) { Context.Modified = true; } UpdateEmployeePlanningDays(); } } } } }
private void gridViewHalfHour_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e) { // if cell focused or selected do nothing if (gridView.IsCellSelected(e.RowHandle, e.Column) && e.Column.Tag != null)// != gc_Employee) { e.Appearance.BackColor = Color.Gold; e.Handled = false; return; } // if is not hour column return if (e.Column.Tag == null) { //e.Handled = false; DrawFixedCells(e); return; } StoreDay storeday = Context.StoreDays[Context.ViewDate]; TimeColumnInfo infoColumn = GetColumnInfo(e.Column); if (infoColumn == null) { return; } EmployeeDayView dayView = GetEmployeeDayView(e.RowHandle); if (dayView == null) { return; } int index = infoColumn.FromTime / 15; Painters.DrawDailyViewCell(e, index, CurrentView, storeday, dayView); }
private void gridControl_MouseDoubleClick(object sender, MouseEventArgs e) { if (ReadOnly) { return; } GridHitInfo info = gridView.CalcHitInfo(e.X, e.Y); if (info.InRow) { TimeColumnInfo timeinfo = GetColumnInfo(info.Column); if (timeinfo != null) { EmployeeDayView dayView = GetEmployeeDayView(); if (dayView != null) { if (dayView.IsBuzyByTimeRange(timeinfo.FromTime, timeinfo.ToTime)) { dayView.RemoveWorkingTime(timeinfo.FromTime, timeinfo.ToTime); } else { dayView.AddWorkingTime(timeinfo.FromTime, timeinfo.ToTime); } if (dayView.Modified) { Context.Modified = true; } UpdateEmployeePlanningDays(); } } } }
private void ProcessFixedTimeAbsence(Absence absence) { if (absence.Value > 0) { int count = (int)(absence.Value * 60); if (gridView.SelectedRowsCount == 1) { EmployeeDayView dayView = GetEmployeeDayView(); TimeColumnInfo info = GetColumnInfo(gridView.FocusedColumn); if (dayView != null && info != null) { dayView.SetAbsence(absence, info.FromTime, info.FromTime + count); if (dayView.Modified) { Context.Modified = true; } UpdateEmployeePlanningDays(); } } } }
private void ProcessCountAliquotAbsence(Absence absence) { if (absence.IsFixed) { if (gridView.SelectedRowsCount == 1) { EmployeeDayView dayView = GetEmployeeDayView(); TimeColumnInfo info = GetColumnInfo(gridView.FocusedColumn); if (dayView != null && info != null) { int count = DateTimeHelper.RoundToQuoter((short)((dayView.ContractHoursPerWeek / Context.StoreDays.AvgDayInWeek))); dayView.SetAbsence(absence, info.FromTime, info.FromTime + count); if (dayView.Modified) { Context.Modified = true; } UpdateEmployeePlanningDays(); } } } }
public static void DrawDailyViewCell(RowCellCustomDrawEventArgs e, int index, DailyViewStyle view, StoreDay storeday, EmployeeDayView dayView) { Rectangle cellBound = Rectangle.Inflate(e.Bounds, 1, 1); e.Cache.FillRectangle(Color.White, cellBound); Rectangle rect; int squareWidth = cellBound.Width; Color squareColor = Color.White; //int index = infoColumn.FromTime / 15; int squareCount = 1; if (view == DailyViewStyle.View30) { cellBound = Rectangle.Inflate(cellBound, -2, 0); squareWidth = ((cellBound.Width - 1) / 2); squareCount = 2; } else if (view == DailyViewStyle.View60) { cellBound = Rectangle.Inflate(cellBound, -2, 0); squareWidth = ((cellBound.Width - 3) / 4); squareCount = 4; } int positionX = cellBound.X; int currentTime = index * 15; Color backColor = Color.White; for (int i = 0; i < squareCount; i++) { currentTime = (index + i) * 15; if (!storeday.IsOpeningTime((short)currentTime)) { backColor = Color.LightGray; } else { backColor = Color.White; } squareColor = dayView.GetColor(index + i); rect = new Rectangle(positionX, cellBound.Y, squareWidth, cellBound.Height); if (squareColor == Color.White) { squareColor = backColor; } e.Cache.FillRectangle(squareColor, rect); positionX += squareWidth + 1; } e.Handled = true; }
private void workingTimeToolStripMenuItem_Click(object sender, EventArgs e) { if (ReadOnly) { return; } EmployeeDayView dayView = GetEmployeeDayView(); if (gridView.SelectedRowsCount == 1) { GridCell[] cells = gridView.GetSelectedCells(); if (cells.Length > 1) { bool ignore = false; for (int i = 0; i < cells.Length; i++) { if (cells[i].Column.Tag == null) { ignore = true; } } if (!ignore) { if (dayView != null) { foreach (GridCell cell in cells) { TimeColumnInfo infocolumn = GetColumnInfo(cell.Column); if (infocolumn != null) { dayView.AddWorkingTime(infocolumn.FromTime, infocolumn.ToTime); } } if (dayView.Modified) { Context.Modified = true; } } UpdateEmployeePlanningDays(); } } else { if (cells != null && cells.Length == 1) { TimeColumnInfo info = GetColumnInfo(cells[0].Column); StoreDay sd = Context.StoreDays[Context.ViewDate]; if (info != null) { using (FormEnterWorkingTime form = new FormEnterWorkingTime()) { if (sd.OpenTime == 0) { form.BeginTime = 9 * 60; } else { form.BeginTime = sd.OpenTime; } form.EndTime = sd.CloseTime; if (sd.CloseTime == 0) { form.EndTime = 18 * 60; } else { form.EndTime = sd.CloseTime; } form.BeginTime = info.FromTime; if (form.ShowDialog() == DialogResult.OK) { int bt = form.BeginTime; int et = form.EndTime; if (dayView != null) { dayView.AddWorkingTime(bt, et); if (dayView.Modified) { Context.Modified = true; } } UpdateEmployeePlanningDays(); } } } } } } }
private void gridView_MouseDown(object sender, MouseEventArgs e) { GridHitInfo info = gridView.CalcHitInfo(e.Location); if (e.Button == MouseButtons.Left && info.InColumn) { GridColumn column = info.Column; if (column == gc_HWGR || column == gc_Employee) { column.SortMode = ColumnSortMode.DisplayText; if (column.SortOrder == ColumnSortOrder.Ascending) { column.SortOrder = ColumnSortOrder.Descending; } else { column.SortOrder = ColumnSortOrder.Ascending; } if (column == gc_HWGR) { gridView.SortInfo.ClearAndAddRange(new GridColumnSortInfo[] { new GridColumnSortInfo(gc_HWGR, gc_HWGR.SortOrder), new GridColumnSortInfo(gc_Employee, gc_Employee.SortOrder) }); } else { gridView.SortInfo.ClearAndAddRange(new GridColumnSortInfo[] { new GridColumnSortInfo(gc_Employee, gc_Employee.SortOrder), new GridColumnSortInfo(gc_HWGR, gc_HWGR.SortOrder) }); } } } if (e.Button == MouseButtons.Left && info.InRowCell) { if (selectedCell != null && selectedCell.Length > 1) { if (selectedCell[0].RowHandle == info.RowHandle) { bool bOk = false; foreach (GridCell cell in selectedCell) { if (cell.Column == info.Column) { bOk = true; break; } } if (bOk && !ReadOnly) { EmployeeDayView dayView = GetEmployeeDayView(info.RowHandle); //m_dailyView.GetByEmployeeId(empl.EmployeeId); TimeColumnInfo columninfo = null; if (dayView != null) { foreach (GridCell cell in selectedCell) { columninfo = GetColumnInfo(cell.Column); if (columninfo != null) { dayView.AddWorkingTime(columninfo.FromTime, columninfo.ToTime); } } if (dayView.Modified) { Context.Modified = true; } UpdateEmployeePlanningDays(); } selectedCell = null; } } } } }