public void Show(Person employee)
        {
            string chosenBareName;

            _Employee = employee;
            List <string> bareTimeNames = Times.BareNames(_Employee.FolderName);

            this.Text = "Employee Times For " + _Employee.FullName.GetValue;
            if (bareTimeNames.Count == 1)
            {
                chosenBareName = bareTimeNames[0];
            }
            else
            {
                using (ChooseTimeFileForm chooseFrm = new ChooseTimeFileForm())
                {
                    chosenBareName = chooseFrm.ChooseFile(bareTimeNames, _Employee.FolderName);
                    if (chosenBareName == null)
                    {
                        return;
                    }
                }
            }
            _ReadOnly = !chosenBareName.Equals(Times.StdBareName, StringComparison.InvariantCultureIgnoreCase);
            _Times    = Times.Load(_Employee.FolderName, chosenBareName);
            _Period   = PayrollStatic.Settings.CurrentPeriod;
            this.ShowDialog();
        }
Beispiel #2
0
        public void ConfigureForDate()
        {
            double fullPeriodsInPast = Math.Floor(DateTime.Today.Date.Subtract(
                                                      _FirstPeriodStart).TotalDays / _DaysInPeriod);
            DateTime startDate = _FirstPeriodStart.AddDays(fullPeriodsInPast * _DaysInPeriod);

            _CurrentPeriod = new PayrollPeriod(startDate);
            DateTime nextDate = startDate.AddDays(-_DaysInPeriod);

            _LastPeriod = new PayrollPeriod(nextDate);
            if (!IsPeriodStart(_CurrentPeriod.StartDate))
            {
                throw new InvalidOperationException("Invalid current period start");
            }
            if (!IsPeriodStart(_LastPeriod.StartDate))
            {
                throw new InvalidOperationException("Invalid last period start");
            }
            _RecentPeriods = new List <PayrollPeriod>();
            _RecentPeriods.Add(_CurrentPeriod);
            _RecentPeriods.Add(_LastPeriod);
            DateTime cutoffDate = DateTime.Now.Date.AddDays(365.0 * -2.0);

            for (; ;)
            {
                nextDate = nextDate.AddDays(-PayrollStatic.Settings.DaysInPeriod);
                if (nextDate.CompareTo(cutoffDate) < 0)
                {
                    break;
                }
                PayrollPeriod period = new PayrollPeriod(nextDate);
                _RecentPeriods.Add(period);
            }
        }
Beispiel #3
0
        private double ComputeOvertime(PayrollPeriod period, List <TimePair> timePairs)
        {
            double week1Hours = 0.0;
            double week2Hours = 0.0;

            foreach (TimePair pair in timePairs)
            {
                if (!pair.IsOpen)
                {
                    if (pair.StartEvent.InOutDateTime.Subtract(period.StartDate).TotalDays < 7.0)
                    {
                        week1Hours += pair.Length.TotalHours;
                    }
                    else
                    {
                        week2Hours += pair.Length.TotalHours;
                    }
                }
            }
            double overtimeHours = 0.0;

            if (week1Hours > 40.0)
            {
                overtimeHours += (week1Hours - 40.0);
            }
            if (week2Hours > 40.0)
            {
                overtimeHours += (week2Hours - 40.0);
            }
            return(overtimeHours);
        }
Beispiel #4
0
 public void Show(PayrollPeriod period, bool privilegedMode)
 {
     _Period                    = period;
     _PrivilegedMode            = privilegedMode;
     btnExport.Visible          = _PrivilegedMode;
     btnClipboardExport.Visible = _PrivilegedMode;
     AddDayColumns();
     ShowEmployees();
     ShowDialog();
 }
Beispiel #5
0
        private void btnTimecardsSelected_Click(object sender, EventArgs e)
        {
            PayrollPeriod period = (PayrollPeriod)cboEndDate.SelectedItem;

            if (period == null)
            {
                MessageBox.Show("Please select period end date.");
                return;
            }
            ShowTimecardReport(period);
        }
Beispiel #6
0
        public void Get(PayrollPeriod period, out List <TimePair> timePairs, out double overtimeHours, out List <TimePair> absentPairs)
        {
            timePairs   = new List <TimePair>();
            absentPairs = new List <TimePair>();
            ClockEvent        startEvent     = null;
            List <ClockEvent> eventsInPeriod = new List <ClockEvent>();

            foreach (ClockEvent clockEvent in _Events)
            {
                if (clockEvent.InOutDateTime.Date >= period.StartDate &&
                    clockEvent.InOutDateTime.Date <= period.EndDate &&
                    clockEvent.Status != EventStatus.Deleted)
                {
                    eventsInPeriod.Add(clockEvent);
                }
            }
            eventsInPeriod.Sort(delegate(ClockEvent event1, ClockEvent event2)
            {
                return(event1.InOutDateTime.CompareTo(event2.InOutDateTime));
            });
            foreach (ClockEvent clockEvent in eventsInPeriod)
            {
                if (startEvent == null)
                {
                    startEvent = clockEvent;
                }
                else
                {
                    if (startEvent.InOutDateTime.Date == clockEvent.InOutDateTime.Date)
                    {
                        AddPair(timePairs, absentPairs, startEvent, clockEvent);
                        startEvent = null;
                    }
                    else
                    {
                        // pair cross a date boundary, so leave an open pair in the old date and start a new pair.
                        AddPair(timePairs, absentPairs, startEvent, null);
                        startEvent = clockEvent;
                    }
                }
            }
            if (startEvent != null)
            {
                AddPair(timePairs, absentPairs, startEvent, null);
            }
            overtimeHours = ComputeOvertime(period, timePairs);
        }
 private void btnLastPeriod_Click(object sender, EventArgs e)
 {
     _Period = PayrollStatic.Settings.LastPeriod;
     ShowTimeCard();
     btnClockNow.Enabled = false;
 }
 private void btnCurrentPeriod_Click(object sender, EventArgs e)
 {
     _Period = PayrollStatic.Settings.CurrentPeriod;
     ShowTimeCard();
     btnClockNow.Enabled = !_ReadOnly;
 }
Beispiel #9
0
        private void ShowTimecardReport(PayrollPeriod period)
        {
            TimecardReportForm reportFrm = new TimecardReportForm();

            reportFrm.Show(period, _PrivilegedMode);
        }