Exemplo n.º 1
0
 public void UpdateBalance(string empId, DateTime monthYearReport, int balance)
 {
     try
     {
         var report = dbContext.PTO_Reports.FirstOrDefault(p => p.EmployeeId == empId && p.MonthYearReport.Year == monthYearReport.Year &&
             p.MonthYearReport.Month == monthYearReport.Month);
         if (report != null)
         {
             report.CarriedForward = balance;
             report.UpdateDate = DateTime.Now;
             report.UpdatedBy = HttpContext.Current.User.Identity.Name;
         }
         else
         {
             //insert balance to the previous month -> carried forward
             report = new PTO_Report()
             {
                 EmployeeId = empId,
                 MonthYearReport = monthYearReport,
                 CarriedForward = balance,
                 CreateDate = DateTime.Now,
                 CreatedBy = HttpContext.Current.User.Identity.Name,
                 UpdateDate = DateTime.Now,
                 UpdatedBy = HttpContext.Current.User.Identity.Name
             };
             dbContext.PTO_Reports.InsertOnSubmit(report);
         }
         dbContext.SubmitChanges();
     }
     catch { }
 }
Exemplo n.º 2
0
 public void UpdateVacationSerinority(PTO_Report objUI,int vacationThisMonth)
 {
     PTO_Report objDb = GetByID(objUI.ID);
     if (objDb != null)
     {
         objDb.MonthlyVacation = vacationThisMonth;
         dbContext.SubmitChanges();
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Update a PTO Report
 /// </summary>
 /// <param name="holiday"></param>
 /// <returns></returns>
 public Message Update(PTO_Report report)
 {
     Message msg = null;
     try
     {
         PTO_Report reportDb = GetPTO(report.ID);
         //Another user has updated this holiday
         if (!reportDb.UpdateDate.ToString().Trim().Equals(report.UpdateDate.ToString().Trim()))
         {
             msg = new Message(MessageConstants.E0025, MessageType.Error, "EOM balance");
         }
         //Successful case
         else
         {
             reportDb.CarriedForward = report.CarriedForward;
             reportDb.MonthlyVacation = report.MonthlyVacation;
             reportDb.Comment = report.Comment;
             reportDb.UpdatedBy = report.UpdatedBy;
             reportDb.UpdateDate = DateTime.Now;
             dbContext.SubmitChanges();
             msg = new Message(MessageConstants.I0001, MessageType.Info,
                 "EOM balance of " + reportDb.EmployeeId + " - " + reportDb.Employee.FirstName + " " + reportDb.Employee.MiddleName + " " + reportDb.Employee.LastName, "updated");
         }
     }
     catch
     {
         msg = new Message(MessageConstants.E0007, MessageType.Error);
     }
     return msg;
 }