Beispiel #1
0
        public static void ApplyEmployeeDayStyle(XRControl control, StoreDay storeDay, EmployeeDay employeeDay, long worldID, IRecordingContext context)
        {
            control.BackColor = Color.Transparent;

            ApplyStoreDayStyle(control, storeDay);

            if (employeeDay != null)
            {
                if (employeeDay.CountDailyAdditionalCharges > 0)
                {
                    control.BackColor = Color.Yellow;
                }
                else if (employeeDay.StoreWorldId != worldID || employeeDay.HasLongAbsence || !employeeDay.HasRelation)
                {
                    control.BackColor = Color.Gray;

                    if (employeeDay.HasLongAbsence)
                    {
                        int?color = context.LongAbsences.GetColor(employeeDay.LongAbsenceId);
                        if (color.HasValue)
                        {
                            control.BackColor = Color.FromArgb(color.Value);
                        }
                        //control.ForeColor = Color.Black;
                    }
                }
            }
        }
Beispiel #2
0
        public StoreDay GetDayInfo(long storeid, DateTime date)
        {
            if (!_diction.ContainsKey(storeid))
            {
                LoadStoreInfo(storeid);
            }

            Dictionary <DateTime, StoreDay> dict = null;
            StoreDay day = null;

            if (!_cellDiction.TryGetValue(storeid, out dict))
            {
                dict = new Dictionary <DateTime, StoreDay>();
                _cellDiction[storeid] = dict;
            }

            if (!dict.TryGetValue(date, out day))
            {
                day = BuildStoreDay(storeid, date);

                if (day == null)
                {
                    throw new ArgumentNullException();
                }

                dict[date] = day;
            }

            return(day);
        }
Beispiel #3
0
        public static void DrawBackgroundWeekDayCell(long storeid, StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, long storeworldid, bool bFocused, int? long_absence_color)
        {
            Rectangle drawrect = Rectangle.Inflate(rect, 1, 1);
            if (bFocused)
            {
                Pen pen = cache.GetPen (Color.Black );
                cache.FillRectangle(Painters.FOCUSED_COLOR , drawrect);
                cache.DrawRectangle(pen, drawrect);
            }
            else
            {
                Color color = Color.White;
                if (storeday.Feast) color = Painters.FEAST_COLOR;
                if (storeday.ClosedDay) color = Painters.CLOSEDDAY_COLOR ;
                if (epd.CountDailyAdditionalCharges > 0) color = Painters.ADDITIONAL_CHARGES_COLOR;
                if (epd.StoreWorldId != storeworldid || epd.HasLongAbsence || !epd.HasRelation || storeid != epd.StoreId)
                {
                    color = Painters.DISABLE_COLOR;

                    if (epd.HasLongAbsence)
                    {
                        if (long_absence_color.HasValue)
                            color = Color.FromArgb(long_absence_color.Value);
                    }
                }
                cache.FillRectangle(color, drawrect);
            }
        }
        public bool Validate(StoreDay storeday1, EmployeePlanningDay employeeday)
        {
            if (employeeday.Date.DayOfWeek == DayOfWeek.Monday) return false;

            if (employeeday.WorkingTimeList == null ||
                    employeeday.WorkingTimeList.Count == 0)
                return false;

            DateTime prevDate = employeeday.Date.AddDays(-1);

            EmployeePlanningDay prevDay = employeeday.PlanningWeek.Days[prevDate];

            if (prevDay.WorkingTimeList == null ||
                    prevDay.WorkingTimeList.Count == 0)
                return false;

            short maxvalue = 0;
            short minvalue = 24 * 60;
            foreach (WorkingTimePlanning wtp in prevDay.WorkingTimeList)
                if (wtp.End > maxvalue) maxvalue = wtp.End;

            foreach (WorkingTimePlanning wtp in employeeday.WorkingTimeList)
                if (wtp.Begin < minvalue) minvalue = wtp.Begin;

            int diff = (Utills.MinutesInDay - maxvalue) + minvalue;

            int countHour = (int)(Value * 60);

            if (countHour > diff) return true;

            return false;
        }
Beispiel #5
0
        public static void ApplyEmployeeDayStyle(XRControl control, StoreDay storeDay, EmployeeDay employeeDay, long worldID, IRecordingContext context)
        {
            control.BackColor = Color.Transparent;

            ApplyStoreDayStyle(control, storeDay);

            if (employeeDay != null)
            {
                if (employeeDay.CountDailyAdditionalCharges > 0)
                {
                    control.BackColor = Color.Yellow;
                }
                else if (employeeDay.StoreWorldId != worldID || employeeDay.HasLongAbsence || !employeeDay.HasRelation)
                {
                    control.BackColor = Color.Gray;

                    if (employeeDay.HasLongAbsence)
                    {
                        int? color = context.LongAbsences.GetColor(employeeDay.LongAbsenceId);
                        if (color.HasValue)
                            control.BackColor = Color.FromArgb(color.Value);
                        //control.ForeColor = Color.Black;
                    }
                }
            }
        }
Beispiel #6
0
        private void FillAllAsWorkingTime()
        {
            StoreDay storeday = Context.StoreDays[ViewDate];

            if (storeday.ClosedDay || storeday.CloseTime == 0)
            {
                return;
            }
            int beginIndex = storeday.OpenTime / 15;
            int endIndex   = storeday.CloseTime / 15;

            foreach (EmployeeDayView edv in m_dailyView.Values)
            {
                for (int i = beginIndex; i < endIndex; i++)
                {
                    if (!edv.IsAbsenceTime(i))
                    {
                        edv.SetAsWorkingTimeIfEmpty(i);
                    }
                }
                if (edv.Modified)
                {
                    Context.Modified = true;
                }
            }

            UpdateEmployeePlanningDays();
        }
Beispiel #7
0
        public bool Validate(StoreDay storeday1, EmployeePlanningDay employeeday)
        {
            if (employeeday.Date.DayOfWeek == DayOfWeek.Monday)
            {
                return(false);
            }

            if (employeeday.WorkingTimeList == null ||
                employeeday.WorkingTimeList.Count == 0)
            {
                return(false);
            }

            DateTime prevDate = employeeday.Date.AddDays(-1);

            EmployeePlanningDay prevDay = employeeday.PlanningWeek.Days[prevDate];

            if (prevDay.WorkingTimeList == null ||
                prevDay.WorkingTimeList.Count == 0)
            {
                return(false);
            }

            short maxvalue = 0;
            short minvalue = 24 * 60;

            foreach (WorkingTimePlanning wtp in prevDay.WorkingTimeList)
            {
                if (wtp.End > maxvalue)
                {
                    maxvalue = wtp.End;
                }
            }

            foreach (WorkingTimePlanning wtp in employeeday.WorkingTimeList)
            {
                if (wtp.Begin < minvalue)
                {
                    minvalue = wtp.Begin;
                }
            }


            int diff = (Utills.MinutesInDay - maxvalue) + minvalue;

            int countHour = (int)(Value * 60);

            if (countHour > diff)
            {
                return(true);
            }


            return(false);
        }
Beispiel #8
0
        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;
        }
Beispiel #9
0
 public static void ApplyStoreDayStyle(XRControl control, StoreDay storeDay)
 {
     if (storeDay == null || storeDay.ClosedDay)
     {
         control.BackColor = Color.LightGray;
     }
     else if (storeDay.Feast)
     {
         control.BackColor = Color.LightGreen;
     }
 }
 private void SetCaptions()
 {
     foreach (XRTableCell cell in _captionTable.Rows.FirstRow.Cells)
     {
         if (cell.Tag is DateTime)
         {
             StoreDay storeDay = _planningContext.StoreDays[(DateTime)cell.Tag];
             cell.Text = String.Format("{0}{3}{2}{3}{1}{3}", Localizer.GetLocalized(storeDay.Date.DayOfWeek.ToString()), DateTimeHelper.ShortTimeRangeToStr(storeDay.OpenTime, storeDay.CloseTime), storeDay.Date.ToShortDateString(), System.Environment.NewLine);
         }
     }
 }
Beispiel #11
0
        public bool ValidateNew(StoreDay storeday1, EmployeeDay employeeday)
        {
            if (employeeday.Date.DayOfWeek == DayOfWeek.Monday)
            {
                return(false);
            }

            if (employeeday.TimeList == null ||
                employeeday.TimeList.Count == 0)
            {
                return(false);
            }

            DateTime prevDate = employeeday.Date.AddDays(-1);

            EmployeeDay prevDay = Owner.EmployeeWeek.GetDay(prevDate);

            if (prevDay.TimeList == null ||
                prevDay.TimeList.Count == 0)
            {
                return(false);
            }

            short maxvalue = 0;
            short minvalue = Utills.MinutesInDay;

            foreach (EmployeeTimeRange wtp in prevDay.TimeList)
            {
                if ((wtp.AbsenceID <= 0) && (wtp.End > maxvalue))
                {
                    maxvalue = wtp.End;
                }
            }
            foreach (EmployeeTimeRange wtp in employeeday.TimeList)
            {
                if ((wtp.AbsenceID <= 0) && (wtp.Begin < minvalue))
                {
                    minvalue = wtp.Begin;
                }
            }

            int diff = (Utills.MinutesInDay - maxvalue) + minvalue;

            int countHour = (int)(Value * 60);

            if (countHour > diff)
            {
                return(true);
            }


            return(false);
        }
        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);
        }
Beispiel #13
0
        private void mi_Absence_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())
                {
                    ProcessNewAbsence(formSelectAbsence.SelectedAbsence);
                    UpdateEmployeePlanningDays();
                }
            }
        }
Beispiel #14
0
        public static void ApplyEmployeePlanningDayStyle(XRControl control, StoreDay storeDay, EmployeePlanningDay employeeDay, long worldID)
        {
            control.BackColor = Color.Transparent;

            ApplyStoreDayStyle(control, storeDay);

            if (employeeDay != null)
            {
                if (employeeDay.CountDailyAdditionalCharges > 0)
                {
                    control.BackColor = Color.Yellow ;
                }
                else if (employeeDay.WorldId != worldID || employeeDay.HasLongAbsence)
                {
                    control.BackColor = Color.Gray;
                }
            }
        }
Beispiel #15
0
        public static void ApplyEmployeePlanningDayStyle(XRControl control, StoreDay storeDay, EmployeePlanningDay employeeDay, long worldID)
        {
            control.BackColor = Color.Transparent;

            ApplyStoreDayStyle(control, storeDay);

            if (employeeDay != null)
            {
                if (employeeDay.CountDailyAdditionalCharges > 0)
                {
                    control.BackColor = Color.Yellow;
                }
                else if (employeeDay.WorldId != worldID || employeeDay.HasLongAbsence)
                {
                    control.BackColor = Color.Gray;
                }
            }
        }
Beispiel #16
0
 void MakeVisibleFirstThreeHours()
 {
     if (Context != null && Context.StoreDays != null)
     {
         StoreDay day = Context.StoreDays[ViewDate];
         if (m_columnsInfo != null)
         {
             gridView.FocusedColumn = m_columnsDiction[m_columnsInfo[m_columnsInfo.Length - 1]];
             for (int i = 0; i < m_columnsInfo.Length; i++)
             {
                 if (m_columnsInfo[i].FromTime <= day.OpenTime && day.OpenTime <= m_columnsInfo[i].FromTime)
                 {
                     gridView.FocusedColumn = m_columnsDiction[m_columnsInfo[i]];//.Column;
                     return;
                 }
             }
         }
     }
 }
Beispiel #17
0
        private StoreDay BuildStoreDay(long storeid, DateTime date)
        {
            bool     feast  = false;
            bool     closed = false;
            StoreDay day    = null;

            feast = _feast_manager.IsFeast(date);

            closed = _closeday_manager.IsClosedDay(date);


            List <StoreWorkingTime> lst = null;

            if (_diction.TryGetValue(storeid, out lst))
            {
                if (lst != null)
                {
                    foreach (StoreWorkingTime swt in lst)
                    {
                        if (swt.BeginTime <= date && date <= swt.EndTime)
                        {
                            day           = new StoreDay(date);
                            day.Feast     = feast;
                            day.ClosedDay = closed;
                            if (swt.StoreWTWeekdays != null)
                            {
                                foreach (StoreWTWeekday weekday in swt.StoreWTWeekdays)
                                {
                                    if (weekday.Weekday == (byte)date.DayOfWeek)
                                    {
                                        day.OpenTime  = weekday.Opentime;
                                        day.CloseTime = weekday.Closetime;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(day);
        }
Beispiel #18
0
        public static void DrawCell(long storeid, IRecordingContext context, EmployeeDay epd, GraphicsCache cache, Rectangle rect, bool bFocused)
        {
            if (context == null)
            {
                return;
            }
            if (epd == null)
            {
                return;
            }
            if (cache == null)
            {
                return;
            }

            StoreDay sd = context.StoreDays[epd.Date];

            DrawBackgroundWeekDayCell(storeid, sd, epd, cache, rect, context.StoreWorldId, bFocused, context.LongAbsences.GetColor(epd.LongAbsenceId));
            DrawWeekDayContent(sd, epd, cache, rect, context);
        }
        private void PrintPlannedDayCell(XRTableCell cell)
        {
            XRPanel panel = ReportPainter.GetPanelControl(cell);

            panel.Width = cell.Width;
            panel.Dock  = XRDockStyle.Fill;
            panel.Controls.Clear();

            EmployeeDay      employeeDay  = null;
            EmployeeWeekView employeeWeek = GetCurrentWeekView();
            StoreDay         storeDay     = _recordingContext.StoreDays[(DateTime)cell.Tag];

            if (employeeWeek != null && storeDay != null && employeeWeek.PlanningWeek != null)
            {
                employeeDay = employeeWeek.PlanningWeek.GetDay(storeDay.Date);
            }

            ReportPainter.ApplyEmployeeDayStyle(cell, storeDay, employeeDay, StoreToWorldID, _recordingContext);

            ReportPainter.PrintDayCellValues(panel, employeeDay, _recordingContext);
        }
Beispiel #20
0
        public static void DrawBackgroundWeekDayCell(long storeid, StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, long storeworldid, bool bFocused, int?long_absence_color)
        {
            Rectangle drawrect = Rectangle.Inflate(rect, 1, 1);

            if (bFocused)
            {
                Pen pen = cache.GetPen(Color.Black);
                cache.FillRectangle(Painters.FOCUSED_COLOR, drawrect);
                cache.DrawRectangle(pen, drawrect);
            }
            else
            {
                Color color = Color.White;
                if (storeday.Feast)
                {
                    color = Painters.FEAST_COLOR;
                }
                if (storeday.ClosedDay)
                {
                    color = Painters.CLOSEDDAY_COLOR;
                }
                if (epd.CountDailyAdditionalCharges > 0)
                {
                    color = Painters.ADDITIONAL_CHARGES_COLOR;
                }
                if (epd.StoreWorldId != storeworldid || epd.HasLongAbsence || !epd.HasRelation || storeid != epd.StoreId)
                {
                    color = Painters.DISABLE_COLOR;

                    if (epd.HasLongAbsence)
                    {
                        if (long_absence_color.HasValue)
                        {
                            color = Color.FromArgb(long_absence_color.Value);
                        }
                    }
                }
                cache.FillRectangle(color, drawrect);
            }
        }
Beispiel #21
0
        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);
            }
        }
Beispiel #22
0
        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();
                        }
                    }
                }
            }
        }
Beispiel #23
0
        void PrepareColumnsView()
        {
            if (Context != null &&
                Context.StoreDays != null &&
                Context.StoreDays.ContainsKey(ViewDate))
            {
                StoreDay day = Context.StoreDays[ViewDate];

                if (m_columnsInfo != null)
                {
                    for (int i = 0; i < m_columnsInfo.Length; i++)
                    {
                        if (m_columnsInfo[i].FromTime < (int)day.OpenTime || (int)day.CloseTime <= m_columnsInfo[i].FromTime)
                        {
                            m_columnsInfo[i].IsOpening = false;
                            m_columnsDiction[m_columnsInfo[i]].AppearanceCell.BackColor = Color.LightGray;
                        }
                    }
                }
            }
            MakeVisibleFirstThreeHours();
        }
        private void PrintPlannedCell(object sender, PrintEventArgs e)
        {
            XRTableCell cell = (XRTableCell)sender;

            if (_plannedDayView == null)
            {
                return;
            }
            StoreDay storeDay = _recordingContext.StoreDays[_recordingContext.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 = _plannedDayView.GetColorByTime(currentTime);
                    if (workingTimeColor != Color.White)
                    {
                        color = workingTimeColor;
                    }
                }

                ReportPainter.AcceptShape(shape, cell, color);
            }
        }
Beispiel #25
0
        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);
        }
Beispiel #26
0
        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();
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #27
0
 public void AddStoreDay(StoreDay storeDay)
 {
     storeDayList.Add(storeDay);
 }
Beispiel #28
0
        public static void DrawWeekDayContent(StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, IRecordingContext context)
        {
            Font cellfont = _cellFont;
            Rectangle cellBound = Rectangle.Inflate(rect, -1, -1);
            Brush cellbrush = Brushes.Black ;
            StringFormat sformat = null;
            if (epd.HasLongAbsence)
            {
                string s = context.LongAbsences.GetAbbreviation(epd.LongAbsenceId);
                if (String.IsNullOrEmpty(s)) return;
                sformat = new StringFormat ();
                sformat.Alignment = StringAlignment.Center;
                sformat.LineAlignment = StringAlignment.Center;
                cache.DrawString(s, cellfont, cellbrush, cellBound, sformat);
            }
            else
            {
                List<string> lstValues = new List<string>();

                List<EmployeeTimeRange> lst = epd.TimeList;

                if (lst != null && lst.Count > 0)
                {
                    sformat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces |
                                            StringFormatFlags.NoWrap);
                    //sformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces |
                    //                        StringFormatFlags.NoWrap;

                    //cellbrush = Brushes.Black ;
                    Brush absenceBrush = null;
                    string str = String.Empty;
                    int heightCell = (int)(cellBound.Height);// / 2);
                    foreach (EmployeeTimeRange range in lst)
                    {
                        str = range.ToString();//TextParser.EmployeeTimeToString(range);

                        Size sf = cache.CalcTextSize(str, cellfont, sformat, 10000).ToSize ();

                        if (range.Absence == null)
                        {
                            cache.DrawString(str, cellfont, cellbrush, cellBound, sformat);
                        }
                        else
                        {
                            absenceBrush = cache.GetSolidBrush(Color.FromArgb(range.Absence.Color));
                            cache.DrawString(str, cellfont, absenceBrush, cellBound, sformat);

                        }

                        cellBound.Y += sf.Height + 2;
                        heightCell -= (sf.Height + 2);
                        if ((heightCell < 0)) break;//  - (sf.Height + 2)) < 0) break;
                        //if ((cellBound.Y + sf.Height) > (rect.Y + rect.Width)) break;
                    }

                }
            }
        }
Beispiel #29
0
        public static void DrawWeekDayContent(StoreDay storeday, EmployeeDay epd, GraphicsCache cache, Rectangle rect, IRecordingContext context)
        {
            Font         cellfont  = _cellFont;
            Rectangle    cellBound = Rectangle.Inflate(rect, -1, -1);
            Brush        cellbrush = Brushes.Black;
            StringFormat sformat   = null;

            if (epd.HasLongAbsence)
            {
                string s = context.LongAbsences.GetAbbreviation(epd.LongAbsenceId);
                if (String.IsNullOrEmpty(s))
                {
                    return;
                }
                sformat               = new StringFormat();
                sformat.Alignment     = StringAlignment.Center;
                sformat.LineAlignment = StringAlignment.Center;
                cache.DrawString(s, cellfont, cellbrush, cellBound, sformat);
            }
            else
            {
                List <string> lstValues = new List <string>();

                List <EmployeeTimeRange> lst = epd.TimeList;

                if (lst != null && lst.Count > 0)
                {
                    sformat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces |
                                               StringFormatFlags.NoWrap);
                    //sformat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces |
                    //                        StringFormatFlags.NoWrap;

                    //cellbrush = Brushes.Black ;
                    Brush  absenceBrush = null;
                    string str          = String.Empty;
                    int    heightCell   = (int)(cellBound.Height);// / 2);
                    foreach (EmployeeTimeRange range in lst)
                    {
                        str = range.ToString();//TextParser.EmployeeTimeToString(range);

                        Size sf = cache.CalcTextSize(str, cellfont, sformat, 10000).ToSize();

                        if (range.Absence == null)
                        {
                            cache.DrawString(str, cellfont, cellbrush, cellBound, sformat);
                        }
                        else
                        {
                            absenceBrush = cache.GetSolidBrush(Color.FromArgb(range.Absence.Color));
                            cache.DrawString(str, cellfont, absenceBrush, cellBound, sformat);
                        }

                        cellBound.Y += sf.Height + 2;
                        heightCell  -= (sf.Height + 2);
                        if ((heightCell < 0))
                        {
                            break;                  //  - (sf.Height + 2)) < 0) break;
                        }
                        //if ((cellBound.Y + sf.Height) > (rect.Y + rect.Width)) break;
                    }
                }
            }
        }
Beispiel #30
0
        private void DrawBackgroundWeekDayCell(StoreDay storeday, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            //if (IsFocusedCell(e.RowHandle, e.Column))
            //{
            //    Pen focusedRectangleLine = e.Cache.GetPen(Color.Black);
            //    e.Cache.FillRectangle(Painters.FOCUSED_COLOR, Rectangle.Inflate(e.Bounds, 1, 1));
            //    e.Cache.DrawRectangle(focusedRectangleLine, Rectangle.Inflate(e.Bounds, 1, 1));
            //}
            //else
            {
                Color color = Painters.EMPTY_COLOR;
                if (storeday.Feast) color = Painters.FEAST_COLOR;
                if (storeday.ClosedDay) color = Painters.CLOSEDDAY_COLOR;
                e.Cache.FillRectangle(color, Rectangle.Inflate(e.Bounds, 1, 1));
            }

        }
Beispiel #31
0
        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;
        }
        public bool ValidateNew(StoreDay storeday1, EmployeeDay employeeday)
        {
            if (employeeday.Date.DayOfWeek == DayOfWeek.Monday) return false;

            if (employeeday.TimeList  == null ||
                    employeeday.TimeList.Count == 0)
                return false;

            DateTime prevDate = employeeday.Date.AddDays(-1);

            EmployeeDay prevDay = Owner.EmployeeWeek.GetDay(prevDate);

            if (prevDay.TimeList == null ||
                    prevDay.TimeList.Count == 0)
                return false;

            short maxvalue = 0;
            short minvalue = Utills.MinutesInDay;
            foreach (EmployeeTimeRange wtp in prevDay.TimeList)
            {
                if ((wtp.AbsenceID <= 0) && (wtp.End > maxvalue)) maxvalue = wtp.End;
            }
            foreach (EmployeeTimeRange wtp in employeeday.TimeList)
            {
                if ((wtp.AbsenceID <= 0) && (wtp.Begin < minvalue )) minvalue = wtp.Begin;
            }

            int diff = (Utills.MinutesInDay - maxvalue) + minvalue;

            int countHour = (int)(Value * 60);

            if (countHour > diff) return true;

            return false;
        }
        private StoreDay BuildStoreDay(long storeid, DateTime date)
        {
            bool feast = false;
            bool closed = false;
            StoreDay day = null;

            feast = _feast_manager.IsFeast(date);

            closed = _closeday_manager.IsClosedDay (date);

            List<StoreWorkingTime > lst = null;
            if (_diction.TryGetValue(storeid, out lst))
            {
                if (lst != null)
                {
                    foreach (StoreWorkingTime swt in lst)
                    {
                        if (swt.BeginTime <= date && date <= swt.EndTime)
                        {
                            day = new StoreDay(date);
                            day.Feast = feast;
                            day.ClosedDay = closed;
                            if (swt.StoreWTWeekdays != null)
                            {
                                foreach (StoreWTWeekday weekday in swt.StoreWTWeekdays)
                                {
                                    if (weekday.Weekday == (byte)date.DayOfWeek)
                                    {
                                        day.OpenTime = weekday.Opentime;
                                        day.CloseTime = weekday.Closetime;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return day;
        }
Beispiel #34
0
 public static void ApplyStoreDayStyle(XRControl control, StoreDay storeDay)
 {
     if (storeDay == null || storeDay.ClosedDay)
     {
         control.BackColor = Color.LightGray;
     }
     else if (storeDay.Feast)
     {
         control.BackColor = Color.LightGreen;
     }
 }