예제 #1
0
        private void calcCumulMins(work_period p)
        {
            //  If date modified is more than 35 days ago, do nothing
            DateTime day = p.Date;

            if (day < DateTime.Now.AddDays(-DAY_CUTOFF))
            {
                return;
            }

            //  Calculate extra minutes
            TimeSpan diff = ShiftInformation.CalcExtraTime(p.StartTime, p.EndTime, settings.RoundOT);

            diff = diff < TimeSpan.Zero ? TimeSpan.Zero : diff;

            //  Find cumulative minutes from before
            TimeSpan cumulMins = diff.Add(findCarryMins(wp, p.Date, DAY_CUTOFF));

            //  Set flag and reset minutes if >15
            if (cumulMins.TotalMinutes >= 15)
            {
                p.AddCumulativeOT = true;
                cumulMins         = cumulMins.Subtract(new TimeSpan(0, 15, 0));
            }
            else
            {
                p.AddCumulativeOT = false;
            }

            p.CumulativeMins = cumulMins;
        }
예제 #2
0
        private void printMinutes(ref TextBox[,] grid, int dayNum, DateTime tStart)
        {
            //This work period is wrong
            int srchResult = workPeriods.BinarySearch(new work_period(tStart.AddDays(dayNum)),
                                                      work_period.CompareByDate());

            int         index = srchResult < 0 ? ~srchResult - 1 : srchResult;
            work_period p     = workPeriods[index];

            TimeSpan cumulMins = p != null ? p.CumulativeMins : TimeSpan.Zero;

            TimeSpan extraMins;

            if (srchResult >= 0 && p.IsValid())
            {
                extraMins = ShiftInformation.CalcExtraTime(p.StartTime, p.EndTime, settings.RoundOT);
            }
            else
            {
                extraMins = TimeSpan.Zero;
            }

            int column = dayNum * 2;

            grid[PhoenixOTSheetDims.RowsPerGrid - 2, column].Text =
                "+" + extraMins.TotalMinutes.ToString();
            grid[PhoenixOTSheetDims.RowsPerGrid - 2, column + 1].Text = "Extra mins";
            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column].Font     = new Font("Arial", STANDARD_FONT_SIZE, FontStyle.Bold);

            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column].Text     = cumulMins.TotalMinutes.ToString();
            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column + 1].Font = new Font("Arial", STANDARD_FONT_SIZE, FontStyle.Bold);
            grid[PhoenixOTSheetDims.RowsPerGrid - 1, column + 1].Text = "Total mins";
        }
예제 #3
0
        private TimeSpan findCarryMins(List <work_period> startData, DateTime day, int dayCutOff)
        {
            DateTime cutDate = DateTime.Now.AddDays(-dayCutOff);

            //Assume that the array is sorted by date -- may need to sort here
            work_period prevDay = searchForPrevDay(startData, day);

            if (prevDay != null)
            {
                if (prevDay.Date >= cutDate)
                {
                    return(prevDay.CumulativeMins);
                }
                else
                {
                    return(TimeSpan.Zero);
                }
            }

            List <work_period> prevYr = loadPeriodsByYear(day.Year - 1);

            //Search for day in previous year
            prevDay = searchForPrevDay(prevYr, new DateTime(this.currentYear - 1, 12, 31));

            if (prevDay == null || prevDay.Date < cutDate)
            {
                return(TimeSpan.Zero);
            }
            else
            {
                return(prevDay.CumulativeMins);
            }
        }
예제 #4
0
        private void initRows()
        {
            int daysInMonth = DateTime.DaysInMonth(year, month);

            //Debug.WriteLine("ACTUAL DATE: " + periods[periods.Count - 1]);
            for (int n = 0; n < daysInMonth; ++n)
            {
                DateTime day = new DateTime(year, month, n + 1);

                //Check if work period exists already
                //  Init row with period if it exists already, or create a new period
                int periodIndex = workPeriodData.BinarySearch(new work_period(day), work_period.CompareByDate());

                if (periodIndex >= 0)
                {
                    work_period p = workPeriodData[periodIndex];
                    //periods.Add(p);
                    row_interface ri = new row_interface(p);
                    ri.ApplySettings(ref settings);
                    rowList.Add(ri);
                }
                else if (workPeriodData.Count > 0)
                {
                    int         indexComplement = ~periodIndex - 1;
                    work_period p = new work_period(day);
                    p.CumulativeMins = workPeriodData[indexComplement].CumulativeMins;
                    workPeriodData.Add(p);
                    row_interface ri = new row_interface(workPeriodData[workPeriodData.Count - 1]);
                    ri.ApplySettings(ref settings);
                    rowList.Add(ri);
                }
                else
                {
                    work_period p = new work_period(day);
                    workPeriodData.Add(p);
                    row_interface ri = new row_interface(workPeriodData[workPeriodData.Count - 1]);
                    ri.ApplySettings(ref settings);
                    rowList.Add(ri);
                }
                workPeriodData.Sort(work_period.CompareByDate());
                //Set row properties and events
                //rowList[n].KeyDownEvent += row_interface_group_KeyDown;
                rowList[n].Location           = new Point(0, n * row_interface.rowHeight);
                rowList[n].VerticalArrowDown += ControlVerticalArrowPressed;
                rowList[n].InputRowSelected  += inputRowSelected;
                rowList[n].LeaveTimeBoxEvent += onLeaveTimeBox;
                panel1.Controls.Add(rowList[n]);
            }
        }
예제 #5
0
        public static bool TryParse(string s, out work_period result)
        {
            WordParser scanner = new WordParser(s, ',');

            DateTime fixedDate;
            DateTime start;
            DateTime end;
            TimeSpan ot;
            TimeSpan premium;
            TimeSpan wash;
            TimeSpan cmMins;
            bool     cmOT;
            string   comment;

            bool check = true;

            check = DateTime.TryParse(scanner.NextWord(), out fixedDate) ? check : false;
            check = DateTime.TryParse(scanner.NextWord(), out start) ? check : false;
            check = DateTime.TryParse(scanner.NextWord(), out end) ? check : false;
            check = TimeSpan.TryParse(scanner.NextWord(), out ot) ? check : false;
            check = TimeSpan.TryParse(scanner.NextWord(), out premium) ? check : false;
            check = TimeSpan.TryParse(scanner.NextWord(), out wash) ? check : false;

            string str = scanner.NextWord();

            if (TimeSpan.TryParse(str, out cmMins) && bool.TryParse(scanner.NextWord(), out cmOT))
            {
                comment = scanner.NextWord();
            }
            else
            {
                comment = str;
                cmMins  = TimeSpan.Zero;
                cmOT    = false;
            }

            if (!check)
            {
                Debug.WriteLine("Parse Fail");
                result = null;
                return(false);
            }

            //Need another constructor to handle extra mins
            work_period period = new work_period(fixedDate, start, end, ot, premium, wash, cmMins, cmOT, comment);

            result = period;
            return(true);
        }
예제 #6
0
        public row_interface(work_period p)
        {
            ++RowID;
            this.Date = p.Date;
            InitializeComponent();
            this.MouseWheel += row_interface_MouseWheel;
            nud_overtime.MouseWheel += nud_MouseWheel;
            nud_premiums.MouseWheel += nud_MouseWheel;
            this.HorizontalArrowDown += Parent_KeyDown;
            currentControl = new List<Control>();
            initControlsList();

            period = p;
            DateTime date = period.Date;
            if (period.StartTime > DateTime.MinValue && period.EndTime > DateTime.MinValue)
            {
                changeStartTime(period.StartTime);
                changeEndTime(period.EndTime);
            }

            l_DayOfWeek.Text = date.DayOfWeek.ToString();

            DateTime min = DateTime.MinValue;
            if (p.StartTime == min || p.EndTime == min)
            {
                showNuds(false);
            }
            else
            {
                showNuds(true);
            }
            applyWeekNum();

            this.nud_overtime.Value = new decimal(p.Overtime.TotalHours);
            this.nud_premiums.Value = new decimal(p.ShiftPremiums.TotalHours);
            this.cb_Washup.Checked = p.WashupTime > TimeSpan.Zero;
            this.rtb_Comment.Text = p.Comment;

            if (p.Date.DayOfWeek == DayOfWeek.Sunday)
            {
                this.BackColor = this.sundayColor;
            }
            else
            {
                this.BackColor = this.weekDayColor;
            }
        }
예제 #7
0
            public List <PremiumCode> GenerateCodes(List <work_period> wp, Settings settings)
            {
                List <PremiumCode> outputCodes = new List <PremiumCode>();

                for (int n = 0; n < wp.Count; ++n)
                {
                    work_period p = wp[n];

                    DateTime nextDay = p.Date.AddDays(1.0);
                    nextDay = new DateTime(nextDay.Year, nextDay.Month, nextDay.Day, 0, 0, 0);

                    PremiumCode pc = new PremiumCode(DEFAULT_CODE, p.Date);

                    if (p.Overtime <= TimeSpan.Zero)
                    {
                        continue;
                    }
                    else if ((nextDay.DayOfWeek == DayOfWeek.Sunday) &&
                             p.EndTime.Date == nextDay.Date)
                    {
                        pc.Hours = ShiftInformation.LockTimeToInterval(
                            ShiftInformation.CalcOvertime(p.StartTime,
                                                          nextDay), settings.RoundOT);

                        PremiumCode holidayOT = new PremiumCode(DEFAULT_CODE, nextDay);
                        holidayOT.Hours = ShiftInformation.LockTimeToInterval(
                            ShiftInformation.CalcHoursWorked(p.StartTime, p.EndTime,
                                                             ShiftInformation.LunchLength).Subtract(pc.Hours), settings.RoundOT);
                        findAndAddHours(holidayOT, outputCodes);
                    }
                    else
                    {
                        pc.Hours = p.Overtime;
                    }

                    if (pc.Hours > TimeSpan.Zero)
                    {
                        findAndAddHours(pc, outputCodes);
                    }
                }

                return(outputCodes);
            }
예제 #8
0
        private void calculateMinutes(work_period period)
        {
            int index = wp.BinarySearch(period, work_period.CompareByDate());

            if (index < 0)
            {
                throw (PeriodNotFoundException);
            }

            work_period p = wp[index];

            while (index < wp.Count && p.Date < DateTime.Now.AddDays(DAY_CUTOFF))
            {
                p = wp[index];
                calcCumulMins(p);
                ++index;
            }
            calcCumulMins(period);
        }
예제 #9
0
        private List <work_period> getRange(DateTime rangeStart, int numDays)
        {
            List <work_period> outputRange = new List <work_period>();

            for (int n = 0; n < numDays; ++n)
            {
                DateTime d = rangeStart.AddDays(n);

                work_period dateToFind = new work_period(d);
                int         dateIndex  = wp.BinarySearch(dateToFind, work_period.CompareByDate());

                if (dateIndex < 0)
                {
                    outputRange.Add(new work_period(d));
                }
                else
                {
                    outputRange.Add(wp[dateIndex]);
                }
            }

            return(outputRange);
        }
예제 #10
0
 public RowInterfaceEventArgs(work_period p)
 {
     Period = p;
 }
예제 #11
0
        private void setup(work_period p, ref Settings s)
        {

        }