Example #1
0
        public 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);
        }
Example #2
0
File: Form1.cs Project: oggiepl/Sky
        private void btnPrintWk_Click(object sender, EventArgs e)
        {
            Person employee = Business.Employees.Find(person => person.Id == (int)cbxIds.SelectedItem);

            if (employee == null)
            {
                MessageBox.Show("Id: " + cbxIds.SelectedItem + " does not exist");
            }
            PayStub payStub = employee.GetWork((new DateTime(2012, 6, 10)), DateTime.Now);

            txtOutput.Text  = payStub.Summary + Environment.NewLine;
            txtOutput.Text += "Total Hours: " + Math.Round(payStub.TotalHours, 2) + "\t$" +
                              payStub.GetPay(Business.PayRate[employee.Id - 1]);
        }
Example #3
0
        private void btnPrintWk_Click(object sender, EventArgs e)
        {
            Person employee = Business.Employees.Find(person => person.Id == (int)cbxIds.SelectedItem);

            if (employee == null)
            {
                MessageBox.Show("Id: " + cbxIds.SelectedItem + " does not exist");
            }

            DateTime dt    = dateTimePicker1.Value;
            DateTime start = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);

            dt = dateTimePicker2.Value;
            DateTime end = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);

            PayStub payStub = employee.GetWork(start, end);

            txtOutput.Text  = payStub.Summary + Environment.NewLine;
            txtOutput.Text += "Total Hours: " + Math.Round(payStub.TotalHours, 2) + "\t$" +
                              payStub.GetPay(Business.PayRate[employee.Id - 1]);
        }
Example #4
0
        public 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;
        }