コード例 #1
0
        // Will add OR update a timesheet for the employee
        public static void SaveTimeSheet(int employeeID
                                         , DateTime datetimeWeekOf
                                         , decimal sundayHours
                                         , decimal mondayHours
                                         , decimal tuesdayHours
                                         , decimal wednesdayHours
                                         , decimal thursdayHours
                                         , decimal fridayHours
                                         , decimal saturdayHours
                                         )
        {
            // TODO: Validat the input

            EightHundredEntities db   = new EightHundredEntities();
            var existingTimeSheetList = (from timeSheet in db.tbl_HR_TimeSheet
                                         where timeSheet.EmployeeID == employeeID &&
                                         timeSheet.WeekEndingDateOn == datetimeWeekOf
                                         select timeSheet)
                                        .ToList();

            if (existingTimeSheetList.Count > 0)
            {
                // update the existing timesheet
                var existingTimeSheet = existingTimeSheetList.First();

                existingTimeSheet.SundayHours    = sundayHours;
                existingTimeSheet.MondayHours    = mondayHours;
                existingTimeSheet.TuesdayHours   = tuesdayHours;
                existingTimeSheet.WednesdayHours = wednesdayHours;
                existingTimeSheet.ThursdayHours  = thursdayHours;
                existingTimeSheet.FridayHours    = fridayHours;
                existingTimeSheet.SaturdayHours  = saturdayHours;
            }
            else
            {
                // save a new timesheet
                tbl_HR_TimeSheet newTimeSheet = new tbl_HR_TimeSheet()
                {
                    EmployeeID       = employeeID,
                    WeekEndingDateOn = datetimeWeekOf,
                    SundayHours      = sundayHours,
                    MondayHours      = mondayHours,
                    TuesdayHours     = tuesdayHours,
                    WednesdayHours   = wednesdayHours,
                    ThursdayHours    = thursdayHours,
                    FridayHours      = fridayHours,
                    SaturdayHours    = saturdayHours
                };

                db.tbl_HR_TimeSheet.AddObject(newTimeSheet);
            }

            db.SaveChanges();
        }
コード例 #2
0
        private void GetHours(tbl_Employee employee, Payroll payrollToProcess, List <tbl_HR_TimeSheet> timeSheetList, ref double Sunday, ref double Monday, ref double Tuesday, ref double Wednesday, ref double Thursday, ref double Friday, ref double Saturday)
        {
            int employeeID = employee.EmployeeID;

            DateTime holdCurrentDate = Convert.ToDateTime("1/1/1900").Date;

            DateTime EndDate   = payrollToProcess.PayrollDate;
            DateTime StartDate = EndDate.AddDays(-7);
            DateTime holddate  = EndDate.AddDays(1);

            // Get the TimeSheet for the week for this employee
            // TODO: If there is NOT one, raise an alert or something...
            List <tbl_HR_TimeSheet> timeSheetForEmployeeList = (from ts in timeSheetList where ts.EmployeeID == employeeID select ts).ToList <tbl_HR_TimeSheet>();

            if (timeSheetForEmployeeList.Count == 0) // if no timesheet for this employee, don't bother
            {
                return;
            }
            tbl_HR_TimeSheet timeSheet = timeSheetForEmployeeList[0];

            Sunday    = (double)timeSheet.SundayHours;
            Monday    = (double)timeSheet.MondayHours;
            Tuesday   = (double)timeSheet.TuesdayHours;
            Wednesday = (double)timeSheet.WednesdayHours;
            Thursday  = (double)timeSheet.ThursdayHours;
            Friday    = (double)timeSheet.FridayHours;
            Saturday  = (double)timeSheet.SaturdayHours;

            // TODO: Remove old code, instead of getting them from timecard list, go straight off of HR_Timecard records

            /*
             * var timeClockReclist = (from t in timeClockReclistAll
             *                      where t.EmployeeID == employee.EmployeeID
             *                      orderby t.DateTimeStatusChanged ascending
             *                      select t);
             * foreach (var timeclockrec in timeClockReclist)
             * {
             *  var timeClockStatus =
             *      (from s in timeClockStatusList where s.TimeClockStatusID == timeclockrec.TimeClockStatusID select s).FirstOrDefault();
             *
             *  if (holdCurrentDate == Convert.ToDateTime("1/1/1900"))
             *  {
             *      holdCurrentDate = timeclockrec.DateTimeStatusChanged.Value;
             *      if (timeClockStatus.ClockedInYN)
             *      {
             *          holdClockedInTime = timeclockrec.DateTimeStatusChanged.Value;
             *      }
             *  }
             *  else if (holdCurrentDate < timeclockrec.DateTimeStatusChanged.Value.Date)
             *  {
             *      if (holdCurrentDate == EndDate.AddDays(-6))
             *      {
             *          Sunday = hours / 60;
             *      }
             *      else if (holdCurrentDate == EndDate.AddDays(-5))
             *      {
             *          Monday = hours / 60;
             *      }
             *      else if (holdCurrentDate == EndDate.AddDays(-4))
             *      {
             *          Tuesday = hours / 60;
             *      }
             *      else if (holdCurrentDate == EndDate.AddDays(-3))
             *      {
             *          Wednesday = hours / 60;
             *      }
             *      else if (holdCurrentDate == EndDate.AddDays(-2))
             *      {
             *          Thursday = hours / 60;
             *      }
             *      else if (holdCurrentDate == EndDate.AddDays(-1))
             *      {
             *          Friday = hours / 60;
             *      }
             *      else if (holdCurrentDate == EndDate)
             *      {
             *          Saturday = hours / 60;
             *      }
             *      hours = 0.0;
             *      holdCurrentDate = timeclockrec.DateTimeStatusChanged.Value;
             *      if (timeClockStatus.ClockedInYN)
             *      {
             *          holdClockedInTime = timeclockrec.DateTimeStatusChanged.Value;
             *      }
             *  }
             *  else
             *  {
             *
             *      if (timeClockStatus.ClockedInYN)
             *      {
             *          holdClockedInTime = timeclockrec.DateTimeStatusChanged.Value;
             *      }
             *      else
             *      {
             *          DateTime date1 = timeclockrec.DateTimeStatusChanged.Value;
             *          TimeSpan tsDiff = holdClockedInTime.Subtract(date1);
             *          var obj = new mod_common(this.UserKey);
             *          hours += obj.DateDiff(mod_common.DateInterval.Minute, holdClockedInTime, date1);
             *          //hours += tsDiff.Minutes;
             *          holdClockedInTime = timeclockrec.DateTimeStatusChanged.Value;
             *
             *      }
             *  }
             *
             * }
             *
             * string strhour = "";
             * if (holdCurrentDate.Date == EndDate.AddDays(-6).Date)
             * {
             *  Sunday = hours / 60;
             *  strhour = "Sunday" + Sunday;
             *
             * }
             * else if (holdCurrentDate.Date == EndDate.AddDays(-5).Date)
             * {
             *  Monday = hours / 60;
             *  strhour = "Monday" + Monday;
             * }
             * else if (holdCurrentDate.Date == EndDate.AddDays(-4).Date)
             * {
             *  Tuesday = hours / 60;
             *  strhour = "Tuesday" + Tuesday;
             * }
             * else if (holdCurrentDate.Date == EndDate.AddDays(-3).Date)
             * {
             *  Wednesday = hours / 60;
             *  strhour = "Wednesday" + Wednesday;
             * }
             * else if (holdCurrentDate.Date == EndDate.AddDays(-2).Date)
             * {
             *  Thursday = hours / 60;
             *  strhour = "Thursday" + Thursday;
             * }
             * else if (holdCurrentDate.Date == EndDate.AddDays(-1).Date)
             * {
             *  Friday = hours / 60;
             *  strhour = "Friday" + Friday;
             * }
             * else if (holdCurrentDate.Date == EndDate.Date)
             * {
             *  Saturday = hours / 60;
             *  strhour = "Saturday" + Saturday;
             * }
             * return strhour;
             *
             */
        }