public bool ValidateNew(EmployeeDay employeeday)
        {
            if (employeeday.HasRelation && employeeday.HasContract)
            {
                CountMinutes = 0;

                if (employeeday.CountDailyWorkingHours == 0) return false;

                short openTime = employeeday.StoreDay.OpenTime;
                short closeTime = employeeday.StoreDay.CloseTime;

                foreach (EmployeeTimeRange wtp in employeeday.TimeList)
                {
                    if (wtp.AbsenceID <= 0)
                    {
                        for (short start = wtp.Begin; start <= wtp.End; start += 15)
                        {
                            if (openTime <= start && start <= closeTime) continue;

                            CountMinutes += 15;
                        }
                    }
                }

                if (CountMinutes > 0)
                {
                    Owner.Hours = CountMinutes;

                    return true;
                }
            }

            return false;
        }
Example #2
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;
                    }
                }
            }
        }
Example #3
0
        public static void FillEmployeeWeeks(List <EmployeeWeek> lstWeeks, List <WorkingTimeRecording> worksList, List <AbsenceTimeRecording> absenceList)
        {
            List <EmployeeTimeRange> ranges = GetTimeRanges(worksList, absenceList);

            if (ranges.Count > 0 && lstWeeks != null && lstWeeks.Count > 0)
            {
                foreach (EmployeeTimeRange range in ranges)
                {
                    foreach (EmployeeWeek week in lstWeeks)
                    {
                        if (range.EmployeeID == week.EmployeeId)
                        {
                            if (DateTimeHelper.Between(range.Date, week.BeginDate, week.EndDate))
                            {
                                EmployeeDay day = week.GetDay(range.Date);

                                if (day.TimeList == null)
                                {
                                    day.TimeList = new List <EmployeeTimeRange>();
                                }

                                day.TimeList.Add(range);
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        public void AssignRecordingDay(EmployeeDay recday)
        {
            ClearRecording();
            if (recday != null)
            {
                List <EmployeeTimeRange> timeList = recday.TimeList;

                if (timeList != null)
                {
                    int index = 0;
                    foreach (EmployeeTimeRange var in timeList)
                    {
                        index = var.Begin / 15;
                        for (int i = var.Begin; i < var.End; i += 15, index++)
                        {
                            if (var.Absence == null)
                            {
                                _recordingTimes[index].Worked = true;
                            }
                            else
                            {
                                _recordingTimes[index].AbsenceEntity = var.Absence;
                            }
                        }
                    }
                }
            }
            else
            {
                ClearRecording();
            }
            Modified = false;
        }
        public bool ValidateNew(EmployeeDay employeeday)
        {
            CountMinutes = 0;
            if (WeekDayMasks == WeeksDayMask.Empty)
                return false;
            if (employeeday.CountDailyWorkingHours == 0)
                return false;
            DayOfWeek dayofweek = employeeday.Date.DayOfWeek;
            WeeksDayMask currentDayMask = WeeksDayMask.Empty;
            switch (dayofweek)
            {
                case DayOfWeek.Monday: currentDayMask = WeeksDayMask.Monday; break;
                case DayOfWeek.Tuesday: currentDayMask = WeeksDayMask.Tuesday; break;
                case DayOfWeek.Wednesday: currentDayMask = WeeksDayMask.Wednesday; break;
                case DayOfWeek.Thursday: currentDayMask = WeeksDayMask.Thursday; break;
                case DayOfWeek.Friday: currentDayMask = WeeksDayMask.Friday; break;
                case DayOfWeek.Saturday: currentDayMask = WeeksDayMask.Saturday; break;
                case DayOfWeek.Sunday: currentDayMask = WeeksDayMask.Sunday; break;
            }

            if ((WeekDayMasks & currentDayMask) != WeeksDayMask.Empty)
            {
                CountMinutes = employeeday.CountDailyWorkingHours;

                //if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                Owner.Hours = CountMinutes;
                return true;
            }
            else return false;
        }
Example #6
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);
            }
        }
Example #7
0
 public static bool IsEqual(EmployeeDayStateRecording entity, EmployeeDay day)
 {
     return((entity.EmployeeID == day.EmployeeId) &&
            (entity.Date == day.Date) &&
            (entity.SumOfAddHours == day.CountDailyAdditionalCharges) &&
            (entity.AllreadyPlannedHours == day.CountDailyPlannedWorkingHours) &&
            (entity.WorkingHours == day.CountDailyWorkingHours) &&
            (entity.StoreWorldId == day.StoreWorldId));
 }
Example #8
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);
        }
Example #9
0
        public static bool IsNeedSave(EmployeeDay employeeday)
        {
            if (employeeday == null)
            {
                return(false);
            }


            return(employeeday.HasRelation & employeeday.HasContract & !employeeday.HasLongAbsence);
        }
Example #10
0
 public static EmployeeDay AssignDay(EmployeeDayStateRecording entity, EmployeeDay day)
 {
     //day.ID = entity.ID;
     day.EmployeeId = entity.EmployeeID;
     day.Date       = entity.Date;
     day.CountDailyAdditionalCharges   = entity.SumOfAddHours;
     day.CountDailyPlannedWorkingHours = entity.AllreadyPlannedHours;
     day.CountDailyWorkingHours        = entity.WorkingHours;
     day.StoreWorldId = entity.StoreWorldId;
     return(day);
 }
Example #11
0
        public bool ValidateNew(EmployeeDay employeeday)
        {
            if (employeeday.HasRelation && employeeday.HasContract)
            {
                if (employeeday.StoreDay.Feast && employeeday.CountDailyWorkingHours > 0)
                {
                    Owner.Hours = employeeday.CountDailyWorkingHours;
                    return true;
                }
            }

            return false;
        }
Example #12
0
        public bool CopyFromPlannedToActual(DateTime minDate, DateTime maxDate)
        {
            if (PlanningWeek == null || ActualWeek == null)
            {
                return(false);
            }
            EmployeeDay actualDay = null;
            bool        bModified = false;

            foreach (EmployeeDay emplday in PlanningWeek.DaysList)
            {
                if (emplday.Date <= minDate)
                {
                    continue;
                }
                if (emplday.Date >= maxDate)
                {
                    continue;
                }


                actualDay = ActualWeek.GetDay(emplday.Date);

                if (actualDay == null)
                {
                    throw new ArgumentException();
                }


                if (!EmployeeTimeRangeHelper.CompareTwoList(actualDay.TimeList, emplday.TimeList))
                {
                    actualDay.TimeList = new List <EmployeeTimeRange>();

                    if (emplday.TimeList != null)
                    {
                        //EmployeeTimeRange newrange = null;
                        foreach (EmployeeTimeRange range in emplday.TimeList)
                        {
                            actualDay.TimeList.Add(new EmployeeTimeRange(range));
                        }
                    }
                    actualDay.Modified = true;
                    bModified          = true;
                }
            }

            return(bModified);
        }
Example #13
0
        public RecordingDayRow(EmployeeWeek week, RecordingDayView dayview,
            EmployeeWeek actualweek, RecordingDayView actualdayview, long orderHwgr)
        {
            _plannedWeek = week;
            _plannedDayView = dayview;

            _actualWeek = actualweek;
            _actualDayView = actualdayview;

            if (_plannedDayView != null)
                _plannedDay = _plannedDayView.RecordingDay;

            if (_actualDayView != null)
                _actualDay = _actualDayView.RecordingDay;

            if (_plannedWeek.FullName != null)
                _fullname = _plannedWeek.FullName;

            _OrderHWGR = orderHwgr;
        }
Example #14
0
 public static EmployeeDay CreateDay(EmployeeDayStateRecording entity)
 {
     EmployeeDay day = new EmployeeDay();
     return AssignDay(entity, day);
 }
Example #15
0
 public static EmployeeDayStateRecording CreateRecordingEntity(EmployeeDay day)
 {
     EmployeeDayStateRecording entity = new EmployeeDayStateRecording();
     return AssignToRecording(entity, day);
 }
Example #16
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;
                    }

                }
            }
        }
Example #17
0
        public bool IsHasWorldByDate(long worldid, DateTime date)
        {
            EmployeeDay epd = GetDay(date);

            return(epd.StoreWorldId == worldid);
        }
Example #18
0
        public static EmployeeDayStateRecording CreateRecordingEntity(EmployeeDay day)
        {
            EmployeeDayStateRecording entity = new EmployeeDayStateRecording();

            return(AssignToRecording(entity, day));
        }
Example #19
0
        public static void PrintDayCellValues(XRControl container, EmployeeDay employeeDay, IRecordingContext recordingContext)
        {
            if (employeeDay != null)
            {
                if (employeeDay.HasLongAbsence)
                {
                    string s = recordingContext.LongAbsences.GetAbbreviation(employeeDay.LongAbsenceId);
                    if (!String.IsNullOrEmpty(s))
                    {
                        XRLabel label = AddLabelLine(container, s, Color.Black, 0, false);
                        label.TextAlignment = TextAlignment.MiddleCenter;
                    }
                    return;
                }

                if(employeeDay.TimeList != null)
                {
                    int y = 0;

                    foreach (EmployeeTimeRange range in employeeDay.TimeList)
                    {
                        XRLabel label = AddLabelLine(container, TextParser.EmployeeTimeToString(range), range.Absence == null ? Color.Black : Color.FromArgb(range.Absence.Color), y, false);
                        y = y + label.Height + 1;
                    }
                }
            }
        }
Example #20
0
        public static bool IsNeedSave(EmployeeDay employeeday)
        {
            if (employeeday == null) return false;

            return employeeday.HasRelation & employeeday.HasContract & !employeeday.HasLongAbsence;
        }
Example #21
0
 public static EmployeeDayStateRecording AssignToRecording(EmployeeDayStateRecording entity, EmployeeDay day)
 {
     //entity.ID = day.ID;
     entity.EmployeeID = day.EmployeeId;
     entity.Date = day.Date;
     entity.SumOfAddHours = day.CountDailyAdditionalCharges;
     entity.AllreadyPlannedHours = day.CountDailyPlannedWorkingHours;
     entity.WorkingHours = day.CountDailyWorkingHours;
     entity.StoreWorldId = day.StoreWorldId;
     return entity;
 }
        public bool ValidateNew(EmployeeDay employeeday)
        {
            CountMinutes = 0;
            if (employeeday.TimeList == null || employeeday.TimeList.Count == 0) return false;

            short minutes = (short)(Value * 60);

            foreach (EmployeeTimeRange wtp in employeeday.TimeList)
            {
                if (wtp.AbsenceID <= 0)// not absence range
                {
                    if (LessThan)
                    {
                        if (wtp.Time < minutes)
                        {
                            CountMinutes = wtp.Time;
                            if (Owner.Hours > CountMinutes || Owner.Hours == -1)
                                Owner.Hours = CountMinutes;
                            return true;
                        }
                    }
                    else
                    {
                        if (wtp.Time > minutes)
                        {
                            CountMinutes = wtp.Time - minutes;
                            if (Owner.Hours > CountMinutes || Owner.Hours == -1)
                                Owner.Hours = CountMinutes;
                            return true;
                        }
                    }
                }
            }

            return false;
        }
Example #23
0
 public void FillEmployeeDay(EmployeeDay emplday)
 {
     if (emplday != null && emplday.TimeList != null)
     {
         for (int i = 0; i < emplday.TimeList.Count; i++)
         {
             if (emplday.TimeList[i].AbsenceID > 0)
             {
                 emplday.TimeList[i].Absence = GetById(emplday.TimeList[i].AbsenceID);
             }
         }
     }
 }
 private int GetWorkingMinutes(EmployeeDay day)
 {
     int result = 0;
     if (day.TimeList != null && day.TimeList.Count > 0)
     {
         foreach (EmployeeTimeRange r in day.TimeList)
             if (r.AbsenceID == 0)
                 result += r.Time;
     }
     return result;
 }
Example #25
0
        public static EmployeeDay CreateDay(EmployeeDayStateRecording entity)
        {
            EmployeeDay day = new EmployeeDay();

            return(AssignDay(entity, day));
        }
        public bool ValidateNew(EmployeeDay employeeday)
        {
            throw new Exception();
            //int count = 0;
            //IBaumaxEmployeeWeek week = Owner.EmployeeWeek;

            //DateTime currentDate = week.BeginDate;
            //count = week.CountWorkDaysBefore;
            ////if (employeeday.Date.AddDays(-Value) < week.BeginDate) return false;

            //while (currentDate <= employeeday.Date)
            //{
            //    if (week.GetDay(currentDate).CountDailyWorkingHours > 0) count++;
            //    else count = 0;

            //    if (count > Value) return true;

            //    currentDate = currentDate.AddDays(1);
            //}

            //return false;
        }
Example #27
0
        public static bool InsertTimeRange(EmployeeDay day, EmployeeTimeRange newrange)
        {
            List <IEmployeeTimeRange> ranges = new List <IEmployeeTimeRange>();

            if (day.TimeList != null)
            {
                foreach (EmployeeTimeRange r in day.TimeList)
                {
                    ranges.Add(r);
                }
            }
            ranges.Sort();
            // if newrange is part of exists range - return
            foreach (IEmployeeTimeRange range in ranges)
            {
                if (range.AbsenceID == newrange.AbsenceID && range.Begin <= newrange.Begin && newrange.End <= range.End)
                {
                    return(false);
                }
            }
            //ranges.Add(newrange);
            ranges.Sort();


            foreach (IEmployeeTimeRange range in ranges)
            {
                if (DateTimeHelper.IsIntersectInc(range.Begin, range.End, newrange.Begin, newrange.End))
                {
                    // if old range part of new range - mark as delete
                    if (newrange.Begin <= range.Begin && range.End <= newrange.End)
                    {
                        range.Begin = range.End;
                    }
                    else if (range.Begin <= newrange.Begin && newrange.Begin <= range.End)
                    {
                        range.End = (short)(newrange.Begin - 1);
                    }
                    else if (range.Begin <= newrange.End && newrange.End <= range.End)
                    {
                        range.Begin = (short)(newrange.End + 1);
                    }
                }
            }
            if (day.TimeList == null)
            {
                day.TimeList = new List <EmployeeTimeRange>(1);
            }
            if (day.TimeList != null)
            {
                day.TimeList.Add(newrange);
            }

            day.TimeList.Sort();
            for (int i = day.TimeList.Count - 1; i >= 0; i--)
            {
                if (day.TimeList[i].Begin >= day.TimeList[i].End)
                {
                    day.TimeList.RemoveAt(i);
                }
            }

            for (int i = day.TimeList.Count - 1; i >= 1; i--)
            {
                if (day.TimeList[i].AbsenceID == day.TimeList[i - 1].AbsenceID &&
                    day.TimeList[i].Begin - 1 == day.TimeList[i - 1].End)
                {
                    day.TimeList[i - 1].End = day.TimeList[i].End;
                    day.TimeList.RemoveAt(i);
                }
            }
            return(true);
        }
        public bool ValidateNew(EmployeeDay employeeday)
        {
            CountMinutes = 0;

            if (employeeday.CountDailyWorkingHours == 0) return false;

            if (employeeday.TimeList != null)
            {
                foreach (EmployeeTimeRange wtp in employeeday.TimeList)
                {
                    if (wtp.AbsenceID <= 0)
                    {
                        for (short start = wtp.Begin; start < wtp.End; start += 15)
                        {
                            if (BeginTime <= start && start < EndTime) //continue;
                                CountMinutes += 15;
                        }
                    }
                }

                if (CountMinutes > 0)
                {
                    //if (Wrapper.Hours > CountMinutes || Wrapper.Hours == -1)
                    Owner.Hours = CountMinutes;

                    return true;
                }
            }
            return false;
        }
Example #29
0
 public static bool IsEqual(EmployeeDayStateRecording entity, EmployeeDay day)
 {
     return (entity.EmployeeID == day.EmployeeId) &&
         (entity.Date == day.Date) &&
         (entity.SumOfAddHours == day.CountDailyAdditionalCharges) &&
         (entity.AllreadyPlannedHours == day.CountDailyPlannedWorkingHours) &&
         (entity.WorkingHours == day.CountDailyWorkingHours) &&
         (entity.StoreWorldId == day.StoreWorldId);
 }
        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;
        }
Example #31
0
 public static EmployeeDayStateRecording AssignToRecording(EmployeeDayStateRecording entity, EmployeeDay day)
 {
     //entity.ID = day.ID;
     entity.EmployeeID           = day.EmployeeId;
     entity.Date                 = day.Date;
     entity.SumOfAddHours        = day.CountDailyAdditionalCharges;
     entity.AllreadyPlannedHours = day.CountDailyPlannedWorkingHours;
     entity.WorkingHours         = day.CountDailyWorkingHours;
     entity.StoreWorldId         = day.StoreWorldId;
     return(entity);
 }
Example #32
0
        public void AssignRecordingDay(EmployeeDay recday)
        {
            ClearRecording();
            if (recday != null)
            {
                List<EmployeeTimeRange> timeList = recday.TimeList;

                if (timeList != null)
                {
                    int index = 0;
                    foreach (EmployeeTimeRange var in timeList)
                    {
                        index = var.Begin / 15;
                        for (int i = var.Begin; i < var.End; i += 15, index++)
                        {
                            if (var.Absence == null)
                                _recordingTimes[index].Worked = true;
                            else
                                _recordingTimes[index].AbsenceEntity = var.Absence;
                        }
                    }
                }
            }
            else
            {
                ClearRecording();
            }
            Modified = false;
        }
Example #33
0
 public static EmployeeDay AssignDay(EmployeeDayStateRecording entity, EmployeeDay day)
 {
     //day.ID = entity.ID;
     day.EmployeeId = entity.EmployeeID;
     day.Date = entity.Date;
     day.CountDailyAdditionalCharges = entity.SumOfAddHours;
     day.CountDailyPlannedWorkingHours = entity.AllreadyPlannedHours;
     day.CountDailyWorkingHours = entity.WorkingHours;
     day.StoreWorldId = entity.StoreWorldId;
     return day;
 }