Exemple #1
0
        public virtual PayStub GetWork(DateTime startTime, DateTime endTime)
        {
            string   result      = string.Format(header, Business.EmployeeNames[Id - 1]);
            DateTime currentDate = startTime;
            TimeSpan totalWork   = new TimeSpan(0);

            while (currentDate.CompareTo(endTime) < 0)
            {
                List <TimeEntry> clockIn = _timeEntries.FindAll(d =>
                                                                (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                                                                 d.DateTime.Year == currentDate.Year &&
                                                                 d.Mode == (int)Mode.IN));

                List <TimeEntry> clockOut = _timeEntries.FindAll(d =>
                                                                 (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                                                                  d.DateTime.Year == currentDate.Year &&
                                                                  d.Mode == (int)Mode.OUT));

                List <TimeEntry> lunchOut = _timeEntries.FindAll(d =>
                                                                 (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                                                                  d.DateTime.Year == currentDate.Year &&
                                                                  d.Mode == (int)Mode.LUNCH_OUT));

                List <TimeEntry> lunchIn = _timeEntries.FindAll(d =>
                                                                (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                                                                 d.DateTime.Year == currentDate.Year &&
                                                                 d.Mode == (int)Mode.LUNCH_IN));


                TimeSpan lunchTime = calcLunch(lunchOut, lunchIn);
                TimeSpan workTime  = calcWorkTime(clockIn, clockOut, lunchTime);
                totalWork = totalWork.Add(workTime);

                result += string.Format(formattedEntry,
                                        currentDate.ToString("M/d/yy"),
                                        currentDate.DayOfWeek.ToString(),
                                        printTime(clockIn, Mode.IN),
                                        Math.Round(lunchTime.TotalMinutes, 2),
                                        printTime(clockOut, Mode.OUT),
                                        Math.Round(workTime.TotalHours, 2));


                currentDate = currentDate.AddDays(1);
            }

            PayStub ps = new PayStub();

            ps.Summary    = result;
            ps.TotalHours = totalWork.TotalHours;

            return(ps);
        }
Exemple #2
0
        public virtual PayStub GetWork(DateTime startTime, DateTime endTime)
        {
            string result = string.Format(header, Business.EmployeeNames[Id-1]);
            DateTime currentDate = startTime;
            TimeSpan totalWork = new TimeSpan(0);

            while (currentDate.CompareTo(endTime) < 0)
            {
                List<TimeEntry> clockIn = _timeEntries.FindAll(d =>
                    (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                        d.DateTime.Year == currentDate.Year &&
                        d.Mode == (int)Mode.IN ) );

                List<TimeEntry> clockOut = _timeEntries.FindAll(d =>
                    (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                        d.DateTime.Year == currentDate.Year &&
                        d.Mode == (int)Mode.OUT));

                List<TimeEntry> lunchOut = _timeEntries.FindAll(d =>
                    (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                        d.DateTime.Year == currentDate.Year &&
                        d.Mode == (int)Mode.LUNCH_OUT));

                List<TimeEntry> lunchIn = _timeEntries.FindAll(d =>
                    (d.DateTime.DayOfYear == currentDate.DayOfYear &&
                        d.DateTime.Year == currentDate.Year &&
                        d.Mode == (int)Mode.LUNCH_IN));

                TimeSpan lunchTime = calcLunch(lunchOut, lunchIn);
                TimeSpan workTime = calcWorkTime( clockIn, clockOut, lunchTime);
                totalWork = totalWork.Add(workTime);

                result += string.Format(formattedEntry,
                                currentDate.ToString("M/d/yy"),
                                currentDate.DayOfWeek.ToString(),
                                printTime(clockIn, Mode.IN),
                                Math.Round(lunchTime.TotalMinutes,2),
                                printTime( clockOut, Mode.OUT),
                                Math.Round(workTime.TotalHours,2) );

                currentDate = currentDate.AddDays(1);
            }

            PayStub ps = new PayStub();
            ps.Summary = result;
            ps.TotalHours = totalWork.TotalHours;

            return ps;
        }