Пример #1
0
        public ActionResult EditTimeClockEntry(int guid)
        {
            TimeClockEntry       model      = CarraraSQL.TimeClockEntries.Find(guid);
            RouteValueDictionary parameters = Request.QueryString.ToRouteValues();

            if (model == null)
            {
                return(Content(string.Concat("Whoops…Unable to Locate Time Clock Entry with Id ", guid.ToString(), "!"), "text/plain"));
            }
            return(PartialView("_TimeClockEntry", model));
        }
Пример #2
0
 public ActionResult AddTimeClockEntry(TimeClockEntry model)
 {
     try
     {
         CarraraSQL.TimeClockEntries.Add(model);
         CarraraSQL.SaveChanges();
         return(Content("OK", "text/plain"));
     }
     catch (Exception ex)
     {
         string message = ex.Message;
         if (ex.InnerException != null)
         {
             message = ex.InnerException.Message;
         }
         return(Content(string.Concat("Whoops…", message), "text/plain"));
     }
 }
Пример #3
0
 public ActionResult EditTimeClockEntry(TimeClockEntry model)
 {
     if (ModelState.IsValid)
     {
         TimeClockEntry entity = CarraraSQL.TimeClockEntries.Find(model.TimeClockEntryID);
         if (!entity.Approved && model.Approved)
         {
             entity.ApprovedBy       = AspNetUser.FullName;
             entity.ApprovedDateTime = DateTime.Now;
         }
         else if (!model.Approved)
         {
             entity.ApprovedBy       = string.Empty;
             entity.ApprovedDateTime = null;
         }
         try
         {
             string   converted     = model.ClockInDate.Value.ToString("MM/dd/yy") + " " + model.ClockInTime.Value.ToString("h:mm:ss tt");
             DateTime convertedDate = Convert.ToDateTime(converted);
             entity.ClockIn = convertedDate;
         }
         catch { }
         try
         {
             string   converted     = model.ClockOutDate.Value.ToString("MM/dd/yy") + " " + model.ClockOutDate.Value.ToString("h:mm:ss tt");
             DateTime convertedDate = Convert.ToDateTime(converted);
             entity.ClockOut = convertedDate;
         }
         catch { }
         entity.HoursWorked     = model.HoursWorked;
         entity.CostCenterID    = model.CostCenterID;
         entity.DrivenVehicleID = model.DrivenVehicleID;
         entity.Lunch           = model.Lunch;
         entity.Notes           = model.Notes;
         CarraraSQL.SaveChanges();
         return(Content(string.Concat(
                            "<td>", entity.Employee.LastName, ", ", entity.Employee.FirstName, "</td>",
                            "<td class=\"numeric\">", entity.StartTime.HasValue ? entity.StartTime.Value.ToShortTimeString() : string.Empty, "</td>",
                            "<td class=\"numeric\">", entity.DayOfWeek, "</td>",
                            "<td class=\"numeric\">", entity.ClockIn, "</td>",
                            "<td class=\"numeric\">", entity.OriginalClockIn, "</td>",
                            "<td class=\"numeric\">",
                            entity.Lunch ?
                            string.Concat("<input checked=\"checked\" id=\"lunch_", entity.TimeClockEntryID, "\" name=\"lunch_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />") :
                            string.Concat("<input id=\"lunch_", entity.TimeClockEntryID, "\" name=\"lunch_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />"),
                            "</td>",
                            "<td class=\"numeric\">", entity.ClockOut, "</td>",
                            "<td class=\"numeric\">", entity.OriginalClockOut, "</td>",
                            "<td class=\"numeric\">", entity.HoursWorked.HasValue ? entity.HoursWorked.Value.ToString("F2") : string.Empty, "</td>",
                            "<td>", entity.Employee.DepartmentID.HasValue ? entity.Employee.Department.DepartmentName : string.Empty, " - ", entity.CostCenterID, "</td>",
                            "<td>", entity.DrivenVehicleID.HasValue ? entity.Vehicle.VehicleCode : string.Empty, "</td>",
                            "<td class=\"numeric\">",
                            entity.ApprovedDateTime.HasValue ?
                            string.Concat("<input checked=\"checked\" id=\"approved_", entity.TimeClockEntryID, "\" name=\"approved_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />") :
                            string.Concat("<input id=\"approved_", entity.TimeClockEntryID, "\" name=\"approved_", entity.TimeClockEntryID, "\" readonly=\"readonly\" type=\"checkbox\" />"),
                            "</td>",
                            "<td class=\"numeric\">", entity.ApprovedDateTime, "</td>",
                            "<td>", entity.ApprovedBy, "</td>",
                            "<td class=\"numeric\">", entity.Notes, "</td>",
                            "<td class=\"numeric error\">", entity.Status, "</td>"
                            ), "text/plain"));
     }
     return(ReturnError());
 }