Beispiel #1
0
        /**Method to insert TimeSheet data into the TimeSheet data table**/
        public void InsertTimeSheet(TimeSheet sheet)
        {
            WeeklyReport weeklyReport = new WeeklyReport();

            db.TimeSheets.Add(sheet);
            db.SaveChanges();

            weeklyReport.getWeeklyReport(sheet.Banner_ID, sheet.WeekEnding.Trim());
        }
Beispiel #2
0
        /**Method to update TimeSheet data in the TimeSheet data table**/
        public void UpdateTimeSheet(TimeSheet sheet)
        {
            WeeklyReport weeklyReport = new WeeklyReport();

            Debug.WriteLine("in database save 1");
            Debug.WriteLine("******************************************************************************************************** " + sheet.LeaveId);
            Debug.WriteLine("With sheet id: " + sheet.Id + "]");

            string timeIn      = "";
            string outForLunch = "";
            string inFromLunch = "";
            string timeOut     = "";

            if (!String.IsNullOrEmpty(sheet.TimeIn.Trim()))
            {
                timeIn = sheet.TimeIn;
            }
            else
            {
                timeIn = "";
            }
            if (!String.IsNullOrEmpty(sheet.OutForLunch.Trim()))
            {
                outForLunch = sheet.OutForLunch;
            }
            else
            {
                outForLunch = "";
            }
            if (!String.IsNullOrEmpty(sheet.InFromLunch.Trim()))
            {
                inFromLunch = sheet.InFromLunch;
            }
            else
            {
                inFromLunch = "";
            }
            if (!String.IsNullOrEmpty(sheet.TimeOut.Trim()))
            {
                timeOut = sheet.TimeOut;
            }
            else
            {
                timeOut = "";
            }

            TimeSheet tsheet = (from tsheets in db.TimeSheets
                                where tsheets.Id == sheet.Id
                                select tsheets).Single();

            Debug.WriteLine("The sheet is: " + sheet.Note + "]");
            tsheet.Id                     = sheet.Id;
            tsheet.WeekEnding             = sheet.WeekEnding;
            tsheet.Date                   = sheet.Date;
            tsheet.TimeIn                 = timeIn;
            tsheet.OutForLunch            = outForLunch;
            tsheet.InFromLunch            = inFromLunch;
            tsheet.TimeOut                = timeOut;
            tsheet.LeaveId                = sheet.LeaveId;
            tsheet.LeaveHours             = sheet.LeaveHours;
            tsheet.AdditionalHours        = sheet.AdditionalHours;
            tsheet.TotalHoursWorked       = tsheet.CalculateTotalHoursWorked(sheet);
            tsheet.Submitted              = sheet.Submitted;
            tsheet.AuthorizedBySupervisor = sheet.AuthorizedBySupervisor;
            tsheet.Banner_ID              = sheet.Banner_ID;
            tsheet.Note                   = sheet.Note;
            Debug.WriteLine("The tsheet is :" + sheet.LeaveId + "55555555555555]");

            db.SaveChanges();

            weeklyReport.getWeeklyReport(sheet.Banner_ID, sheet.WeekEnding.Trim());
        }