コード例 #1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     try {
         TimeAdjustCur.TimeEntry = DateTime.Parse(textTimeEntry.Text);
     }
     catch {
         MsgBox.Show(this, "Please enter a valid date and time.");
         return;
     }
     if (textHours.errorProvider1.GetError(textHours) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (checkOvertime.Checked)
     {
         TimeAdjustCur.RegHours   = TimeSpan.FromHours(-PIn.PDouble(textHours.Text));
         TimeAdjustCur.OTimeHours = TimeSpan.FromHours(PIn.PDouble(textHours.Text));
     }
     else
     {
         TimeAdjustCur.RegHours   = TimeSpan.FromHours(PIn.PDouble(textHours.Text));
         TimeAdjustCur.OTimeHours = TimeSpan.FromHours(0);
     }
     TimeAdjustCur.Note = textNote.Text;
     if (IsNew)
     {
         TimeAdjusts.Insert(TimeAdjustCur);
     }
     else
     {
         TimeAdjusts.Update(TimeAdjustCur);
     }
     DialogResult = DialogResult.OK;
 }
コード例 #2
0
        ///<summary>Used in the timecard to track hours worked per week when the week started in a previous time period.  This gets all the hours of the first week before the date listed.  Also adds in any adjustments for that week.</summary>
        public static TimeSpan GetWeekTotal(int empNum, DateTime date)
        {
            ClockEvent[] events = Refresh(empNum, date.AddDays(-6), date.AddDays(-1), false, false);
            //eg, if this is Thursday, then we are getting last Friday through this Wed.
            TimeSpan retVal = new TimeSpan(0);

            for (int i = 0; i < events.Length; i++)
            {
                if (events[i].TimeDisplayed.DayOfWeek > date.DayOfWeek)                //eg, Friday > Thursday, so ignore
                {
                    continue;
                }
                if (i > 0 && !events[i].ClockIn)
                {
                    retVal += events[i].TimeDisplayed - events[i - 1].TimeDisplayed;
                }
            }
            //now, adjustments
            TimeAdjust[] TimeAdjustList = TimeAdjusts.Refresh(empNum, date.AddDays(-6), date.AddDays(-1));
            for (int i = 0; i < TimeAdjustList.Length; i++)
            {
                if (TimeAdjustList[i].TimeEntry.DayOfWeek > date.DayOfWeek)                 //eg, Friday > Thursday, so ignore
                {
                    continue;
                }
                retVal += TimeAdjustList[i].RegHours;
            }
            return(retVal);
        }
コード例 #3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            try {
                DateTime.Parse(textTimeEntry.Text);
            }
            catch {
                MsgBox.Show(this, "Please enter a valid Date/Time.");
                return;
            }
            try{
                if (textHours.Text.Contains(":"))
                {
                    TimeSpan.Parse(textHours.Text);
                }
                else
                {
                    Double.Parse(textHours.Text);
                }
            }
            catch {
                MsgBox.Show(this, "Please enter valid Hours and Minutes.");
                return;
            }
            //end of validation
            TimeAdjustCur.IsAuto    = radioAuto.Checked;
            TimeAdjustCur.TimeEntry = DateTime.Parse(textTimeEntry.Text);
            TimeSpan hoursEntered;

            if (textHours.Text.Contains(":"))
            {
                hoursEntered = TimeSpan.Parse(textHours.Text);
            }
            else
            {
                hoursEntered = TimeSpan.FromHours(Double.Parse(textHours.Text));
            }
            if (checkOvertime.Checked)
            {
                TimeAdjustCur.RegHours   = -hoursEntered;
                TimeAdjustCur.OTimeHours = hoursEntered;
            }
            else
            {
                TimeAdjustCur.RegHours   = hoursEntered;
                TimeAdjustCur.OTimeHours = TimeSpan.FromHours(0);
            }
            TimeAdjustCur.Note = textNote.Text;
            if (IsNew)
            {
                TimeAdjusts.Insert(TimeAdjustCur);
            }
            else
            {
                TimeAdjusts.Update(TimeAdjustCur);
            }
            DialogResult = DialogResult.OK;
        }
コード例 #4
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     TimeAdjusts.Delete(TimeAdjustCur);
     DialogResult = DialogResult.OK;
 }
コード例 #5
0
        private void butCompute_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.TimecardsEditAll))
            {
                return;
            }
            //first, delete all existing overtime entries
            for (int i = 0; i < TimeAdjustList.Length; i++)
            {
                if (TimeAdjustList[i].OTimeHours.TotalHours != 0)
                {
                    TimeAdjusts.Delete(TimeAdjustList[i]);
                }
            }
            //then, fill grid
            FillMain(true);
            Calendar         cal  = CultureInfo.CurrentCulture.Calendar;
            CalendarWeekRule rule = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;

            //loop through all rows
            for (int i = 0; i < mergedAL.Count; i++)
            {
                //ignore rows that aren't weekly totals
                if (i < mergedAL.Count - 1           //if not the last row
                    //if the next row has the same week as this row
                    && cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)
                    == cal.GetWeekOfYear(GetDateForRow(i), rule, DayOfWeek.Sunday))
                {
                    continue;
                }
                if (WeeklyTotals[i] <= TimeSpan.FromHours(40))
                {
                    continue;
                }
                //found a weekly total over 40 hours
                TimeAdjust adjust = new TimeAdjust();
                adjust.EmployeeNum = EmployeeCur.EmployeeNum;
                adjust.TimeEntry   = GetDateForRow(i).AddHours(20);            //puts it at 8pm on the same day.
                adjust.OTimeHours  = WeeklyTotals[i] - TimeSpan.FromHours(40);
                adjust.RegHours    = -adjust.OTimeHours;
                TimeAdjusts.Insert(adjust);
            }
            FillMain(true);
        }
コード例 #6
0
        ///<summary>fromDB is set to false when it is refreshing every second so that there will be no extra network traffic.</summary>
        private void FillMain(bool fromDB)
        {
            if (fromDB)
            {
                ClockEventList = ClockEvents.Refresh(EmployeeCur.EmployeeNum, PIn.PDate(textDateStart.Text),
                                                     PIn.PDate(textDateStop.Text), false, IsBreaks);
                if (IsBreaks)
                {
                    TimeAdjustList = new TimeAdjust[0];
                }
                else
                {
                    TimeAdjustList = TimeAdjusts.Refresh(EmployeeCur.EmployeeNum, PIn.PDate(textDateStart.Text),
                                                         PIn.PDate(textDateStop.Text));
                }
            }
            mergedAL = new ArrayList();
            for (int i = 0; i < ClockEventList.Length; i++)
            {
                mergedAL.Add(ClockEventList[i]);
            }
            for (int i = 0; i < TimeAdjustList.Length; i++)
            {
                mergedAL.Add(TimeAdjustList[i]);
            }
            IComparer myComparer = new ObjectDateComparer();

            mergedAL.Sort(myComparer);
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Date"), 70);

            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Weekday"), 70);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Altered"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Status"), 50);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "In/Out"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Time"), 60, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            if (IsBreaks)
            {
                col = new ODGridColumn(Lan.g(this, "Minutes"), 50, HorizontalAlignment.Right);
            }
            else
            {
                col = new ODGridColumn(Lan.g(this, "Hours"), 50, HorizontalAlignment.Right);
            }
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Overtime"), 55, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Daily"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Weekly"), 50, HorizontalAlignment.Right);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Note"), 5);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            //TimeSpan weeklyTotalPrevious=
            WeeklyTotals = new TimeSpan[mergedAL.Count];
            TimeSpan   alteredSpan = new TimeSpan(0); //used to display altered times
            TimeSpan   pairSpan    = new TimeSpan(0); //used to sum one pair of clockevents
            ClockEvent pairFirst   = null;            //the first of a pair of clockevents
            TimeSpan   daySpan     = new TimeSpan(0); //used for daily totals.
            TimeSpan   weekSpan    = new TimeSpan(0); //used for weekly totals.

            if (mergedAL.Count > 0)
            {
                weekSpan = ClockEvents.GetWeekTotal(EmployeeCur.EmployeeNum, GetDateForRow(0));
            }
            //MessageBox.Show(weekSpan.TotalHours.ToString());
            TimeSpan         periodSpan   = new TimeSpan(0); //used to add up totals for entire page.
            TimeSpan         otspan       = new TimeSpan(0); //overtime for the entire period
            Calendar         cal          = CultureInfo.CurrentCulture.Calendar;
            CalendarWeekRule rule         = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
            DateTime         curDate      = DateTime.MinValue;
            DateTime         previousDate = DateTime.MinValue;
            Type             type;
            ClockEvent       clock;
            TimeAdjust       adjust;

            for (int i = 0; i < mergedAL.Count; i++)
            {
                row          = new ODGridRow();
                type         = mergedAL[i].GetType();
                row.Tag      = mergedAL[i];
                previousDate = curDate;
                //clock event row---------------------------------------------------------------------------------------------
                if (type == typeof(ClockEvent))
                {
                    clock   = (ClockEvent)mergedAL[i];
                    curDate = clock.TimeDisplayed.Date;
                    if (curDate == previousDate)
                    {
                        row.Cells.Add("");
                        row.Cells.Add("");
                    }
                    else
                    {
                        row.Cells.Add(curDate.ToShortDateString());
                        row.Cells.Add(curDate.DayOfWeek.ToString());
                    }
                    //altered--------------------------------------
                    if (clock.TimeEntered != clock.TimeDisplayed)
                    {
                        alteredSpan = clock.TimeDisplayed - clock.TimeEntered;
                        if (IsBreaks)
                        {
                            row.Cells.Add(alteredSpan.TotalMinutes.ToString("n"));
                        }
                        else
                        {
                            row.Cells.Add(alteredSpan.TotalHours.ToString("n"));
                        }
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //status--------------------------------------
                    row.Cells.Add(clock.ClockStatus.ToString());
                    //in/out------------------------------------------
                    if (clock.ClockIn)
                    {
                        row.Cells.Add(Lan.g(this, "In"));
                    }
                    else
                    {
                        row.Cells.Add(Lan.g(this, "Out"));
                    }
                    //time-----------------------------
                    row.Cells.Add(clock.TimeDisplayed.ToShortTimeString());
                    //minutes or hours-------------------------------
                    if (IsBreaks)                     //breaks
                    {
                        if (!clock.ClockIn)           //clocking out
                        {
                            pairFirst = clock.Copy();
                            row.Cells.Add("");
                        }
                        else                         //clocking in
                        {
                            if (pairFirst == null)
                            {
                                row.Cells.Add("");
                            }
                            else
                            {
                                pairSpan = clock.TimeDisplayed - pairFirst.TimeDisplayed;
                                row.Cells.Add(pairSpan.TotalMinutes.ToString("n"));
                                daySpan += pairSpan;
                                //weekSpan+=pairSpan;
                                periodSpan += pairSpan;
                            }
                        }
                    }
                    else                     //regular hours
                    {
                        if (clock.ClockIn)   //clocking in
                        {
                            pairFirst = clock.Copy();
                            row.Cells.Add("");
                        }
                        else                         //clocking out
                        {
                            if (pairFirst == null)
                            {
                                row.Cells.Add("");
                            }
                            else
                            {
                                pairSpan = clock.TimeDisplayed - pairFirst.TimeDisplayed;
                                row.Cells.Add(pairSpan.TotalHours.ToString("n"));
                                daySpan    += pairSpan;
                                weekSpan   += pairSpan;
                                periodSpan += pairSpan;
                            }
                        }
                    }
                    //Overtime------------------------------
                    row.Cells.Add("");
                    //Daily-----------------------------------
                    //if this is the last entry for a given date
                    if (i == mergedAL.Count - 1 ||            //if this is the last row
                        GetDateForRow(i + 1) != curDate)                         //or the next row is a different date
                    {
                        if (IsBreaks)
                        {
                            if (!clock.ClockIn)                            //if they have not clocked back in yet from break
                            //display the timespan of pairSpan using current time as the other number.
                            {
                                pairSpan = DateTime.Now - clock.TimeDisplayed + TimeDelta;
                                row.Cells.Add(pairSpan.TotalMinutes.ToString("n"));
                                daySpan += pairSpan;
                            }
                            else
                            {
                                row.Cells.Add(daySpan.TotalMinutes.ToString("n"));
                            }
                        }
                        else
                        {
                            row.Cells.Add(daySpan.TotalHours.ToString("n"));
                        }
                        daySpan = new TimeSpan(0);
                    }
                    else                     //not the last entry for the day
                    {
                        row.Cells.Add("");
                    }
                    //Weekly-------------------------------------
                    WeeklyTotals[i] = weekSpan;
                    if (IsBreaks)
                    {
                        row.Cells.Add("");
                    }
                    //if this is the last entry for a given week
                    else if (i == mergedAL.Count - 1 ||            //if this is the last row
                             cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)                  //or the next row has a
                             != cal.GetWeekOfYear(clock.TimeDisplayed.Date, rule, DayOfWeek.Sunday))          //different week of year
                    {
                        row.Cells.Add(weekSpan.TotalHours.ToString("n"));
                        weekSpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Note-----------------------------------------
                    row.Cells.Add(clock.Note);
                }
                //adjustment row--------------------------------------------------------------------------------------
                else if (type == typeof(TimeAdjust))
                {
                    adjust  = (TimeAdjust)mergedAL[i];
                    curDate = adjust.TimeEntry.Date;
                    if (curDate == previousDate)
                    {
                        row.Cells.Add("");
                        row.Cells.Add("");
                    }
                    else
                    {
                        row.Cells.Add(curDate.ToShortDateString());
                        row.Cells.Add(curDate.DayOfWeek.ToString());
                    }
                    //altered--------------------------------------
                    row.Cells.Add("");                    //2
                    //status--------------------------------------
                    row.Cells.Add(Lan.g(this, "Adjust")); //3
                    row.ColorText = Color.Red;
                    //in/out------------------------------------------
                    row.Cells.Add("");                                   //4
                    //time-----------------------------
                    row.Cells.Add(adjust.TimeEntry.ToShortTimeString()); //5
                    //minutes or hours-------------------------------
                    if (adjust.RegHours.TotalHours == 0)
                    {
                        row.Cells.Add("");                        //6
                    }
                    else
                    {
                        daySpan    += adjust.RegHours;                   //might be negative
                        weekSpan   += adjust.RegHours;
                        periodSpan += adjust.RegHours;
                        row.Cells.Add(adjust.RegHours.TotalHours.ToString("n"));                        //6
                    }
                    //Overtime------------------------------
                    if (adjust.OTimeHours.TotalHours != 0)
                    {
                        otspan += adjust.OTimeHours;
                        row.Cells.Add(adjust.OTimeHours.TotalHours.ToString("n"));                        //7
                    }
                    else
                    {
                        row.Cells.Add("");                        //7
                    }
                    //Daily-----------------------------------
                    //if this is the last entry for a given date
                    if (i == mergedAL.Count - 1 ||            //if this is the last row
                        GetDateForRow(i + 1) != curDate)                         //or the next row is a different date
                    {
                        row.Cells.Add(daySpan.TotalHours.ToString("n"));         //8
                        daySpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Weekly-------------------------------------
                    WeeklyTotals[i] = weekSpan;
                    if (IsBreaks)
                    {
                        row.Cells.Add("");
                    }
                    //if this is the last entry for a given week
                    else if (i == mergedAL.Count - 1 ||            //if this is the last row
                             cal.GetWeekOfYear(GetDateForRow(i + 1), rule, DayOfWeek.Sunday)                  //or the next row has a
                             != cal.GetWeekOfYear(adjust.TimeEntry.Date, rule, DayOfWeek.Sunday))             //different week of year
                    {
                        ODGridCell cell = new ODGridCell(weekSpan.TotalHours.ToString("n"));
                        cell.ColorText = Color.Black;
                        row.Cells.Add(cell);
                        weekSpan = new TimeSpan(0);
                    }
                    else
                    {
                        row.Cells.Add("");
                    }
                    //Note-----------------------------------------
                    row.Cells.Add(adjust.Note);
                }
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            if (IsBreaks)
            {
                textTotal.Text = "";
            }
            else
            {
                textTotal.Text    = periodSpan.TotalHours.ToString("n");
                textOvertime.Text = otspan.TotalHours.ToString("n");
            }
        }
コード例 #7
0
        private void FillGridMain()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "LName"), 100));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "FName"), 100));
            gridMain.ListGridColumns.Add(new GridColumn(_monthT2.ToString("MMMM yyyy"), 100, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
            gridMain.ListGridColumns.Add(new GridColumn(_monthT1.ToString("MMMM yyyy"), 100, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
            if (!checkIgnore.Checked)
            {
                gridMain.ListGridColumns.Add(new GridColumn(_monthT0.ToString("MMMM yyyy"), 100, HorizontalAlignment.Right, GridSortingStrategy.AmountParse));
            }
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g(this, "Letter"), 100));
            gridMain.ListGridRows.Clear();
            List <Employee>   listEmpsAll        = Employees.GetDeepCopy(true).OrderBy(x => x.LName).ThenBy(x => x.FName).ToList();
            List <ClockEvent> listClockEventsAll = ClockEvents.GetAllForPeriod(_monthT2, _monthT2.AddMonths(3)); //get all three months of clock events

            listClockEventsAll.RemoveAll(x => x.ClockStatus == TimeClockStatus.Break);                           //remove breaks, they have already been acounted for on the clock events.
            listClockEventsAll.RemoveAll(x => x.TimeDisplayed2 <= x.TimeDisplayed1);                             //Remove all mal-formed entries with stop time before start time. (also if user has not clocked out.)
            listClockEventsAll.RemoveAll(x => x.TimeDisplayed1.Date != x.TimeDisplayed2.Date);                   //No one works over midnight at ODHQ. If they do, they know to split clock events @ midnight
            List <TimeAdjust> listTimeAdjustAll = TimeAdjusts.GetAllForPeriod(_monthT2, _monthT2.AddMonths(3));

            foreach (Employee empCur in listEmpsAll)
            {
                //Construct each row, then filter out if neccesary.
                GridRow row = new GridRow();
                //Name
                row.Cells.Add(empCur.LName);
                row.Cells.Add(empCur.FName);
                //Month T-2 (current month -2 months)
                TimeSpan ts2 = TimeSpan.FromTicks(listClockEventsAll
                                                  .FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                           x.TimeDisplayed1.Year == _monthT2.Year &&
                                                           x.TimeDisplayed1.Month == _monthT2.Month)
                                                  .Select(x => (x.TimeDisplayed2 - x.TimeDisplayed1) + (x.AdjustIsOverridden ? x.Adjust : x.AdjustAuto))
                                                  .Sum(x => x.Ticks));
                ts2.Add(TimeSpan.FromTicks(listTimeAdjustAll.FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                                     x.TimeEntry.Year == _monthT2.Year &&
                                                                     x.TimeEntry.Month == _monthT2.Month)
                                           .Sum(x => x.RegHours.Ticks)));
                row.Cells.Add(new GridCell(string.Format("{0:0.00}", Math.Round(ts2.TotalHours, 2, MidpointRounding.AwayFromZero)))
                {
                    ColorBackG = (ts2.TotalHours < 125 ? lightRed : Color.Empty)
                });
                //Month T-1
                TimeSpan ts1 = TimeSpan.FromTicks(listClockEventsAll
                                                  .FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                           x.TimeDisplayed1.Year == _monthT1.Year &&
                                                           x.TimeDisplayed1.Month == _monthT1.Month)
                                                  .Select(x => (x.TimeDisplayed2 - x.TimeDisplayed1) + (x.AdjustIsOverridden ? x.Adjust : x.AdjustAuto))
                                                  .Sum(x => x.Ticks));
                ts1.Add(TimeSpan.FromTicks(listTimeAdjustAll.FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                                     x.TimeEntry.Year == _monthT1.Year &&
                                                                     x.TimeEntry.Month == _monthT1.Month)
                                           .Select(x => x.RegHours)
                                           .Sum(x => x.Ticks)));
                row.Cells.Add(new GridCell(string.Format("{0:0.00}", Math.Round(ts1.TotalHours, 2, MidpointRounding.AwayFromZero)))
                {
                    ColorBackG = (ts1.TotalHours < 125 ? lightRed : Color.Empty)
                });
                //Month T-0
                TimeSpan ts0 = TimeSpan.FromTicks(listClockEventsAll
                                                  .FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                           x.TimeDisplayed1.Year == _monthT0.Year &&
                                                           x.TimeDisplayed1.Month == _monthT0.Month)
                                                  .Select(x => (x.TimeDisplayed2 - x.TimeDisplayed1) + (x.AdjustIsOverridden ? x.Adjust : x.AdjustAuto))
                                                  .Sum(x => x.Ticks));
                ts0.Add(TimeSpan.FromTicks(listTimeAdjustAll.FindAll(x => x.EmployeeNum == empCur.EmployeeNum &&
                                                                     x.TimeEntry.Year == _monthT0.Year &&
                                                                     x.TimeEntry.Month == _monthT0.Month)
                                           .Select(x => x.RegHours)
                                           .Sum(x => x.Ticks)));
                if (!checkIgnore.Checked)
                {
                    row.Cells.Add(new GridCell(string.Format("{0:0.00}", Math.Round(ts0.TotalHours, 2, MidpointRounding.AwayFromZero)))
                    {
                        ColorBackG = (ts0.TotalHours < 125 ? lightRed : Color.Empty)
                    });
                }
                //filter out rows that should not be displaying. Rows should not display only when the most recent month was less than 125 hours, regardless of status of previous months
                if (!checkShowAll.Checked)
                {
                    //Show all is not checked, therefore we must filter out rows with more than 125 hours on the most recent pay period.
                    if (!checkIgnore.Checked && ts0.TotalHours > 125)
                    {
                        //Not ignoring "current month" so check T0 for >125 hours
                        continue;
                    }
                    else if (checkIgnore.Checked && ts1.TotalHours > 125)
                    {
                        //Ignore current month (because it is probably only partially complete), check the previous months for >125 hours.
                        continue;
                    }
                }
                string letterNumber = "";
                if ((checkIgnore.Checked?ts2:ts0).TotalHours < 125 && ts1.TotalHours < 125)
                {
                    //the last two visible month were less than 125 hours. AKA "Send the Second letter"
                    letterNumber = "Second";
                }
                else if ((checkIgnore.Checked?ts1:ts0).TotalHours < 125)
                {
                    //the last visible month was less than 125 hours. AKA "Send the First letter"
                    letterNumber = "First";
                }
                row.Cells.Add(letterNumber);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }
コード例 #8
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            try {
                DateTime.Parse(textTimeEntry.Text);
            }
            catch {
                MsgBox.Show(this, "Please enter a valid Date/Time.");
                return;
            }
            TimeSpan hoursEntered = TimeSpan.FromHours(0);

            try {
                if (textHours.Text.Contains(":"))
                {
                    hoursEntered = ClockEvents.ParseHours(textHours.Text);
                }
                else
                {
                    hoursEntered = TimeSpan.FromHours(Double.Parse(textHours.Text));
                }
                if (hoursEntered == TimeSpan.FromHours(0))
                {
                    throw new ApplicationException("Invalid hoursEntered");
                }
            }
            catch {
                MsgBox.Show(this, "Please enter valid Hours and Minutes.");
                return;
            }
            if (checkOvertime.Checked && comboPTO.SelectedIndex != 0)
            {
                MsgBox.Show(this, "Overtime Adjustments must have PTO Type set to 'None'.\r\n"
                            + "Please select 'None' for PTO Type or uncheck Overtime Adjustment.");
                return;
            }
            //end of validation
            TimeAdjustCur.IsAuto    = radioAuto.Checked;
            TimeAdjustCur.TimeEntry = DateTime.Parse(textTimeEntry.Text);
            if (checkOvertime.Checked)
            {
                TimeAdjustCur.RegHours   = -hoursEntered;
                TimeAdjustCur.OTimeHours = hoursEntered;
                TimeAdjustCur.PtoHours   = TimeSpan.FromHours(0);
                TimeAdjustCur.PtoDefNum  = 0;
            }
            else if (comboPTO.SelectedIndex == 0)
            {
                TimeAdjustCur.RegHours   = hoursEntered;
                TimeAdjustCur.OTimeHours = TimeSpan.FromHours(0);
                TimeAdjustCur.PtoHours   = TimeSpan.FromHours(0);
                TimeAdjustCur.PtoDefNum  = 0;
            }
            else              //Is PTO
            {
                ODBoxItem <Def> item = (ODBoxItem <Def>)comboPTO.Items[comboPTO.SelectedIndex];
                TimeAdjustCur.RegHours   = TimeSpan.FromHours(0);
                TimeAdjustCur.OTimeHours = TimeSpan.FromHours(0);
                TimeAdjustCur.PtoHours   = hoursEntered;
                TimeAdjustCur.PtoDefNum  = ((Def)item.Tag).DefNum;
            }
            TimeAdjustCur.Note = textNote.Text;
            if (IsNew)
            {
                TimeAdjusts.Insert(TimeAdjustCur);
            }
            else
            {
                TimeAdjusts.Update(TimeAdjustCur);
            }
            DialogResult = DialogResult.OK;
        }