public ActionResult Create([Bind(Include = "JobCardAppID,DateCreated,DateStarted,DateEnded,JCTypeID,UserID,JobCardCriteria,CriteriaData,Status,TimeIn,TimeOut,WorkMin,Remarks,OtherValue,SupervisorID,StartTime,EndTime,EmpID,Justification")] Att_JobCardApp att_jobcardapp) { if (att_jobcardapp.EmpID == null) { ViewBag.error = "required field!"; } else { if (ModelState.IsValid) { if (att_jobcardapp.DateEnded != null) { att_jobcardapp.DateCreated = DateTime.Now; att_jobcardapp.StatusID = "Approved"; att_jobcardapp.StartTime = null; att_jobcardapp.EndTime = null; db.Att_JobCardApp.Add(att_jobcardapp); db.SaveChanges(); } else { att_jobcardapp.DateCreated = DateTime.Now; att_jobcardapp.StatusID = "Approved"; db.Att_JobCardApp.Add(att_jobcardapp); db.SaveChanges(); ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp; AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Job_Cards), Convert.ToInt16(AuditManager.AuditOperation.Add), DateTime.Now, (int)att_jobcardapp.JobCardAppID); } } ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); return(RedirectToAction("Index")); } return(View(att_jobcardapp)); }
public ActionResult Cancel(int?id) { Att_JobCardApp job = new Att_JobCardApp(); job = db.Att_JobCardApp.First(aa => aa.JobCardAppID == id); job.StatusID = "Rejected"; job.ApprovedDate = DateTime.Now; db.SaveChanges(); if (job.StatusID == "Rejected") { var EName = db.EmpViews.First(aa => aa.EmployeeID == job.EmpID).FullName; string Toadd = "*****@*****.**"; string subject = "Job Card Approval/Rejection" + EName; string body = "Dear Sir/Madam, <br/> job card request was Rejected < br /> Date : " + job.DateCreated + "+ < br /> , kindly review it. <br/> Employee Name: " + EName + "<br/> Employee No: " + job.EmpID + "<br/> Date Time: " + job.DateCreated.Value.ToShortDateString() + "<br/> Please Click on below link to procced further <a href='http://192.168.0.21/wms'>http://192.168.0.21/ESSP</a>"; EmailManager.SendEmail(Toadd, subject, body); } ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp; AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Job_Cards), Convert.ToInt16(AuditManager.AuditOperation.Reject), DateTime.Now, (int)id); int RecordID = job.JobCardAppID; // Below Code is for Notification ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; int TypeID = Convert.ToInt16(Utilities.NotificationType.Job_Card); string TypeName = Utilities.NotificationType.Job_Card.ToString().Replace("_", " "); int EmployeeID = LoggedInUser.EmpID ?? 0; Utilities.DeleteNotification(job.JobCardAppID, Convert.ToInt16(Utilities.NotificationType.Pending_Job_Card)); Utilities.InsertEMPNotification(TypeID, TypeName, EmployeeID, id ?? 0, job.EmpID ?? 0, BaseURL + "Attendance/JobCard/Index"); return(RedirectToAction("Index")); }
private bool CheckForValidation(List <Att_JobCardApp> queryable, Att_JobCardApp att_jobcardapp) { bool check = false; foreach (var item in queryable) { DateTime dts = new DateTime(); DateTime dte = new DateTime(); if (item.TimeBased == true) { dts = item.DateStarted.Value; dte = item.DateStarted.Value; } else { dts = item.DateStarted.Value; dte = item.DateEnded.Value; } while (dts <= dte) { if (dts == att_jobcardapp.DateStarted.Value || dts == att_jobcardapp.DateEnded.Value) { check = true; } dts = dts.AddDays(1); } } return(check); }
public ActionResult DeleteConfirmed(int id) { Att_JobCardApp att_jobcardapp = db.Att_JobCardApp.Find(id); db.Att_JobCardApp.Remove(att_jobcardapp); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: /Attendance/EmployeeJobCard/Delete/5 public ActionResult Delete(int?id) { Att_JobCardApp att_jobcardapp = db.Att_JobCardApp.Find(id); db.Att_JobCardApp.Remove(att_jobcardapp); db.SaveChanges(); ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp; AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Job_Cards), Convert.ToInt16(AuditManager.AuditOperation.Delete), DateTime.Now, (int)att_jobcardapp.JobCardAppID); return(RedirectToAction("Index")); }
public ActionResult GetID(int?ID) { Att_JobCardApp jb = new Att_JobCardApp(); jb.DateStarted = DateTime.Today; jb.EmpID = ID; jb.StartTime = DateTime.Now; ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderBy(aa => aa.FullName).ToList(), "UserID", "FullName"); ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName"); return(View("Create", jb)); }
public ActionResult Edit([Bind(Include = "JobCardAppID,DateCreated,DateStarted,DateEnded,JCTypeID,UserID,EmpID,Status,TimeBased,StartTime,EndTime,TotalMins,Remarks,SupervisorID,StatusID,ApprovedDate")] Att_JobCardApp att_jobcardapp) { if (ModelState.IsValid) { db.Entry(att_jobcardapp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp; AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Job_Cards), Convert.ToInt16(AuditManager.AuditOperation.Edit), DateTime.Now, (int)att_jobcardapp.JobCardAppID); return(RedirectToAction("Index")); } ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); return(View(att_jobcardapp)); }
// GET: /Attendance/EmployeeJobCard/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Att_JobCardApp att_jobcardapp = db.Att_JobCardApp.Find(id); if (att_jobcardapp == null) { return(HttpNotFound()); } return(View(att_jobcardapp)); }
// GET: /Attendance/EmployeeJobCard/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Att_JobCardApp att_jobcardapp = db.Att_JobCardApp.Find(id); if (att_jobcardapp == null) { return(HttpNotFound()); } ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); return(View(att_jobcardapp)); }
// GET: /Attendance/EmployeeJobCard/Create public ActionResult Create(int?ID) { Att_JobCardApp jb = new Att_JobCardApp(); jb.DateStarted = DateTime.Today; jb.EmpID = ID; jb.StartTime = DateTime.Now; if (ID != null) { ViewBag.EmployeeName = db.EmpViews.First(aa => aa.EmployeeID == ID).FullName; ViewBag.Designation = db.EmpViews.First(aa => aa.EmployeeID == ID).DesignationName; ViewBag.Department = db.EmpViews.First(aa => aa.EmployeeID == ID).SectionName; } ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName"); return(View(jb)); }
// GET: /Attendance/JobCard/Edit/5 public ActionResult Edit(int?id) { ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Att_JobCardApp att_jobcardapp = db.Att_JobCardApp.Find(id); if (att_jobcardapp == null) { return(HttpNotFound()); } ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderBy(aa => aa.FullName).ToList(), "UserID", "FullName"); ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); return(View(att_jobcardapp)); }
public ActionResult Edit([Bind(Include = "JobCardAppID,DateCreated,DateStarted,DateEnded,JCTypeID,UserID,EmpID,Status,TimeBased,StartTime,EndTime,TotalMins,Remarks,SupervisorID,StatusID,ApprovedDate")] Att_JobCardApp att_jobcardapp) { ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; if (ModelState.IsValid) { db.Entry(att_jobcardapp).State = System.Data.Entity.EntityState.Modified; att_jobcardapp.DateCreated = DateTime.Now; att_jobcardapp.EmpID = LoggedInUser.EmpID; att_jobcardapp.StatusID = "Pending"; att_jobcardapp.SupervisorID = LoggedInUser.ReportingToID; db.SaveChanges(); ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp; AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Job_Cards), Convert.ToInt16(AuditManager.AuditOperation.Edit), DateTime.Now, (int)att_jobcardapp.JobCardAppID); return(RedirectToAction("Index")); } ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderBy(aa => aa.FullName).ToList(), "UserID", "FullName"); ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); return(View(att_jobcardapp)); }
public ActionResult SelectEmployee(FormCollection form) { try { string ErrorMessage = ""; List <EmpView> emps = new List <EmpView>(); ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; emps = db.EmpViews.Where(aa => aa.Status == "Active").ToList(); List <EmpView> ViewEmps = new List <EmpView>(); List <EmpView> tempEmps = new List <EmpView>(); VMJCApplication vm = new VMJCApplication(); ViewEmps = emps.ToList(); vm.CardType = Request.Form["JobCardType"].ToString(); vm.DateEnded = Convert.ToDateTime(Request.Form["JobDateTo"]); vm.JCValue = Convert.ToInt32(Request.Form["JCValue"]); vm.DateStarted = Convert.ToDateTime(Request.Form["JobDateFrom"]); if (Request.Form["SelectionRB"].ToString() == "rbAll") { ViewEmps = emps.ToList(); vm.JCCriteria = "A"; } else { var checkedLoc = form.GetValues("cbLocation"); List <HR_Location> locs = new List <HR_Location>(); locs = db.HR_Location.ToList(); if (checkedLoc != null) { List <HR_Location> tempLocs = new List <HR_Location>(); foreach (var item in checkedLoc) { short id = Convert.ToInt16(item); tempEmps.AddRange(ViewEmps.Where(aa => aa.LocID == id).ToList()); tempLocs.Add(locs.First(aa => aa.LocID == id)); } ViewEmps = tempEmps.ToList(); vm.LocEmployees = tempLocs; vm.JCCriteria = "L"; } else { tempEmps = ViewEmps.ToList(); tempEmps.Clear(); } // var checkedType = form.GetValues("cbType"); List <HR_EmpType> types = new List <HR_EmpType>(); types = db.HR_EmpType.ToList(); if (checkedType != null) { List <HR_EmpType> tempTypes = new List <HR_EmpType>(); foreach (var item in checkedType) { short id = Convert.ToInt16(item); string name = types.First(aa => aa.TypID == id).TypeName; tempEmps.AddRange(ViewEmps.Where(aa => aa.TypeName == name).ToList()); tempTypes.Add(types.First(aa => aa.TypID == id)); } ViewEmps = tempEmps.ToList(); vm.TypeEmployees = tempTypes; vm.JCCriteria = "T"; } else { tempEmps = ViewEmps.ToList(); tempEmps.Clear(); } // var checkedShift = form.GetValues("cbShift"); List <Att_Shift> shifts = new List <Att_Shift>(); shifts = db.Att_Shift.ToList(); if (checkedShift != null) { List <Att_Shift> tempShifts = new List <Att_Shift>(); tempEmps.Clear(); foreach (var item in checkedShift) { short id = Convert.ToInt16(item); //string name = depts.First(aa => aa.DeptID == id).DeptID; tempEmps.AddRange(ViewEmps.Where(aa => aa.ShftID == id).ToList()); tempShifts.Add(shifts.First(aa => aa.ShftID == id)); } ViewEmps = tempEmps.ToList(); vm.ShiftEmployees = tempShifts; vm.JCCriteria = "H"; } else { tempEmps = ViewEmps.ToList(); } } foreach (var emp in tempEmps.ToList()) { Att_JobCardApp jobCardApp = new Att_JobCardApp(); jobCardApp.JCTypeID = Convert.ToInt16(vm.CardType); jobCardApp.DateCreated = DateTime.Now; jobCardApp.UserID = LoggedInUser.UserID; jobCardApp.DateStarted = vm.DateStarted; jobCardApp.DateEnded = vm.DateEnded; jobCardApp.Status = false; jobCardApp.EmpID = emp.EmployeeID; jobCardApp.TimeBased = false; if (vm.JCValue != null) { jobCardApp.TotalMins = (short)vm.JCValue; } jobCardApp.Remarks = "ByApp"; jobCardApp.StatusID = "Approved"; jobCardApp.ApprovedDate = DateTime.Now; db.Att_JobCardApp.Add(jobCardApp); } db.SaveChanges(); if (ErrorMessage == "") { return(View(vm)); } else { VMJCApplication vmDemo = new VMJCApplication(); vmDemo.LocEmployees = db.HR_Location.ToList(); vmDemo.TypeEmployees = db.HR_EmpType.ToList(); vmDemo.DeptEmployees = db.HR_Department.ToList(); vmDemo.SecEmployees = db.HR_Section.ToList(); vmDemo.ShiftEmployees = db.Att_Shift.ToList(); ViewBag.JobCardType = new SelectList(db.Att_JobCard.OrderBy(aa => aa.JCName).ToList(), "JCID", "JCName"); return(View("Index", vmDemo)); } } catch (Exception) { throw; } }
public ActionResult Create([Bind(Include = "JobCardAppID,DateCreated,DateStarted,DateEnded,JCTypeID,UserID,EmpID,Status,TimeBased,StartTime,EndTime,TotalMins,Remarks,SupervisorID,StatusID,ApprovedDate")] Att_JobCardApp att_jobcardapp) { ViewUserEmp LoggedInUser = Session["LoggedUser"] as ViewUserEmp; if (att_jobcardapp.TimeBased == false) { if (att_jobcardapp.DateStarted >= DateTime.Today && att_jobcardapp.DateEnded >= att_jobcardapp.DateStarted) { if (att_jobcardapp.DateEnded == null || att_jobcardapp.DateEnded == new DateTime(1, 1, 1)) { ModelState.AddModelError("DateEnded", "End Date is required"); } else { if (att_jobcardapp.DateStarted.Value > att_jobcardapp.DateEnded.Value) { ModelState.AddModelError("DateEnded", "End Date must be greater than Start Date"); } // Check for Duplication if (CheckForValidation(db.Att_JobCardApp.Where(aa => aa.EmpID == LoggedInUser.EmployeeID || aa.StatusID == "Approved" || aa.StatusID == "Pending").ToList(), att_jobcardapp)) { ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderByDescending(aa => aa.FullName).ToList(), "UserID", "FullName"); ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); ModelState.AddModelError("DateStarted", "You already have applied on this date"); return(View(att_jobcardapp)); } } } else { ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderByDescending(aa => aa.FullName).ToList(), "UserID", "FullName"); ModelState.AddModelError("DateStarted", "Date Must be Grater then today"); return(View(att_jobcardapp)); } } else { var AM = DateTime.Now.ToString("08:30:00"); var PM = DateTime.Now.ToString("16:30:00"); if (att_jobcardapp.StartTime >= Convert.ToDateTime(AM) && att_jobcardapp.EndTime <= Convert.ToDateTime(PM)) { if (att_jobcardapp.StartTime == null) { ModelState.AddModelError("StartTime", "Start Time is required"); } if (att_jobcardapp.EndTime == null) { ModelState.AddModelError("StartTime", "Start Time is required"); } if (att_jobcardapp.StartTime != null && att_jobcardapp.EndTime != null) { if (att_jobcardapp.StartTime.Value > att_jobcardapp.EndTime.Value) { ModelState.AddModelError("StartTime", "End Time must be greater than Start Time"); } // Check for Duplication if (db.Att_JobCardApp.Where(aa => aa.DateStarted == att_jobcardapp.DateStarted && aa.EmpID == LoggedInUser.EmployeeID && aa.StatusID != "Rejected").Count() > 0) { ModelState.AddModelError("DateStarted", "You already have applied on this date"); } } } else { ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderByDescending(aa => aa.FullName).ToList(), "UserID", "FullName"); ViewBag.TimeError = "Incorrenct Time"; return(View(att_jobcardapp)); } } int RecordID = 0; if (ModelState.IsValid) { if (att_jobcardapp.DateEnded != null) { att_jobcardapp.DateCreated = DateTime.Now; att_jobcardapp.EmpID = LoggedInUser.EmpID; att_jobcardapp.StartTime = null; att_jobcardapp.EndTime = null; att_jobcardapp.UserID = LoggedInUser.UserID; att_jobcardapp.StatusID = "Pending"; db.Att_JobCardApp.Add(att_jobcardapp); db.SaveChanges(); if (att_jobcardapp.StatusID == "Pending") { var EName = db.EmpViews.First(aa => aa.EmployeeID == att_jobcardapp.EmpID).FullName; string Toadd = "*****@*****.**"; string subject = "Job Card Request" + EName; string body = "Dear Sir/Madam, <br/> job card request was intiated of < br /> Date: " + att_jobcardapp.DateCreated + "+ < br /> , kindly review it. <br/> Employee Name: " + EName + "<br/> Employee No: " + att_jobcardapp.EmpID + "<br/> Date Time: " + att_jobcardapp.DateCreated.Value.ToShortDateString() + "<br/> Please Click on below link to procced further <a href='http://192.168.0.21/wms'>http://192.168.0.21/ESSP</a>"; EmailManager.SendEmail(Toadd, subject, body); } RecordID = att_jobcardapp.JobCardAppID; //return RedirectToAction("Index"); } else { att_jobcardapp.DateCreated = DateTime.Now; att_jobcardapp.EmpID = LoggedInUser.EmpID; att_jobcardapp.StatusID = "Pending"; att_jobcardapp.UserID = LoggedInUser.UserID; db.Att_JobCardApp.Add(att_jobcardapp); db.SaveChanges(); if (att_jobcardapp.StatusID == "Pending") { var EName = db.EmpViews.First(aa => aa.EmployeeID == att_jobcardapp.EmpID).FullName; string Toadd = "*****@*****.**"; string subject = "Job Card Request" + EName; string body = "Dear Sir/Madam, <br/> job card request was intiated of < br /> Time : " + att_jobcardapp.DateCreated + "+ < br /> , kindly review it. <br/> Employee Name: " + EName + "<br/> Employee No: " + att_jobcardapp.EmpID + "<br/> Date Time: " + att_jobcardapp.DateCreated.Value.ToShortDateString() + "<br/> Please Click on below link to procced further <a href='http://192.168.0.21/wms'>http://192.168.0.21/ESSP</a>"; EmailManager.SendEmail(Toadd, subject, body); } ViewUserEmp loggedUser = Session["LoggedUser"] as ViewUserEmp; AuditManager.SaveAuditLog(loggedUser.UserID, Convert.ToInt16(AuditManager.AuditForm.Job_Cards), Convert.ToInt16(AuditManager.AuditOperation.Add), DateTime.Now, (int)att_jobcardapp.JobCardAppID); RecordID = att_jobcardapp.JobCardAppID; // Below Code is for Notification int TypeID = Convert.ToInt16(Utilities.NotificationType.Pending_Job_Card); string TypeName = Utilities.NotificationType.Pending_Job_Card.ToString().Replace("_", " "); int EmployeeID = LoggedInUser.EmpID ?? 0; Utilities.InsertEMPNotification(TypeID, TypeName, EmployeeID, RecordID, att_jobcardapp.SupervisorID ?? 0, BaseURL + "Attendance/PendingJobCards/Index"); return(RedirectToAction("Index")); } } ViewBag.JCTypeID = new SelectList(db.Att_JobCard, "JCID", "JCName", att_jobcardapp.JCTypeID); ViewBag.SupervisorID = new SelectList(db.ViewUserEmps.Where(aa => aa.DepartmentID == LoggedInUser.DepartmentID).OrderByDescending(aa => aa.FullName).ToList(), "UserID", "FullName"); //return View(att_jobcardapp); return(RedirectToAction("Index")); }