public ActionResult Create() { var _wings = new List <Division>(); using (TAS2013Entities context = new TAS2013Entities()) { _wings = context.Divisions.ToList(); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CrewID = new SelectList(db.Crews.OrderBy(s => s.CrewName), "CrewID", "CrewName"); ViewBag.DesigID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName"); ViewBag.GradeID = new SelectList(db.Grades.OrderBy(s => s.GradeName), "GradeID", "GradeName"); ViewBag.JobID = new SelectList(db.JobTitles.OrderBy(s => s.JobTitle1), "JobID", "JobTitle1"); ViewBag.LocID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); ViewBag.SecID = new SelectList(db.Sections.OrderBy(s => s.SectionName), "SectionID", "SectionName"); ViewBag.ShiftID = new SelectList(db.Shifts.OrderBy(s => s.ShiftName), "ShiftID", "ShiftName"); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); ViewBag.EmpID = new SelectList(db.EmpFaces.OrderBy(s => s.Face1), "EmpID", "Face1"); ViewBag.EmpID = new SelectList(db.EmpFps.OrderBy(s => s.Fp1), "EmpID", "Fp1"); ViewBag.EmpID = new SelectList(db.LvQuotas.OrderBy(s => s.CompanyID), "EmpID", "EmpID"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); return(View(new Emp())); }
// // GET: /AttProcessors/Create public ActionResult Create() { TAS2013Entities db = new TAS2013Entities(); User LoggedInUser = Session["LoggedUser"] as User; QueryBuilder qb = new QueryBuilder(); String query = qb.QueryForCompanyViewLinq(LoggedInUser); ViewBag.PeriodTag = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = false, Text = "Monthly", Value = "M" }, new SelectListItem { Selected = true, Text = "Daily", Value = "D" }, new SelectListItem { Selected = false, Text = "Summary", Value = "S" }, }, "Value", "Text", 1); ViewBag.CriteriaID = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Company", Value = "C" }, new SelectListItem { Selected = false, Text = "Location", Value = "L" }, new SelectListItem { Selected = false, Text = "Employee", Value = "E" }, }, "Value", "Text", 1); ViewBag.ProcessCats = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Yes", Value = "1" }, new SelectListItem { Selected = false, Text = "No", Value = "0" }, }, "Value", "Text", 1); if (LoggedInUser.RoleID == 1) { ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDForEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); } else { ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDForEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); } ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View()); }
public ActionResult Create() { ViewBag.DayOff1 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name"); ViewBag.DayOff2 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name"); QueryBuilder qb = new QueryBuilder(); User LoggedInUser = Session["LoggedUser"] as User; string query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); ViewBag.RosterType = new SelectList(db.RosterTypes.OrderBy(s => s.Name), "ID", "Name"); return(View()); }
public ActionResult Edit([Bind(Include = "ShiftID,ShiftName,StartTime,DayOff1,DayOff2,Holiday,RosterType,MonMin,TueMin,WedMin,ThuMin,FriMin,SatMin,SunMin,LateIn,EarlyIn,EarlyOut,LateOut,OverTimeMin,MinHrs,HasBreak,BreakMin,GZDays,OpenShift,LocationID")] Shift shift) { if (string.IsNullOrEmpty(shift.ShiftName)) { ModelState.AddModelError("ShiftName", "Required"); } if (shift.ShiftName != null) { if (shift.ShiftName.Length > 50) { ModelState.AddModelError("ShiftName", "String length exceeds!"); } //if (db.Shifts.Where(aa => aa.ShiftName == shift.ShiftName).Count() > 0) //{ // ModelState.AddModelError("ShiftName", "Shift Name must be unique"); //} } if (shift.HasBreak == true) { if (shift.BreakMin == null) { ModelState.AddModelError("BreakMin", "Required"); } } if (shift.LateIn == null) { ModelState.AddModelError("LateIn", "Required"); } User LoggedInUser = Session["LoggedUser"] as User; if (ModelState.IsValid) { shift.CompanyID = LoggedInUser.CompanyID; shift.GZDays = shift.Holiday; db.Entry(shift).State = EntityState.Modified; db.SaveChanges(); int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Shift, (byte)MyEnums.Operation.Edit, DateTime.Now); return(RedirectToAction("Index")); } ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); ViewBag.DayOff1 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name", shift.DayOff1); ViewBag.DayOff2 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name", shift.DayOff2); ViewBag.RosterType = new SelectList(db.RosterTypes.OrderBy(s => s.Name), "ID", "Name", shift.RosterType); return(View(shift)); }
public ActionResult Edit(byte?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Shift shift = db.Shifts.Find(id); if (shift == null) { return(HttpNotFound()); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); ViewBag.DayOff1 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name", shift.DayOff1); ViewBag.DayOff2 = new SelectList(db.DaysNames.OrderBy(s => s.Name), "ID", "Name", shift.DayOff2); ViewBag.RosterType = new SelectList(db.RosterTypes.OrderBy(s => s.Name), "ID", "Name", shift.RosterType); return(View(shift)); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Emp emp = db.Emps.Find(id); if (emp == null) { return(HttpNotFound()); } try { EmpType et = db.EmpTypes.Where(aa => aa.TypeID == emp.TypeID).FirstOrDefault(); User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", emp.CompanyID); ViewBag.LocID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName", emp.LocID); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName", et.CatID); ViewBag.CrewID = new SelectList(db.Crews.OrderBy(s => s.CrewName), "CrewID", "CrewName", emp.CrewID); ViewBag.DesigID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName", emp.DesigID); ViewBag.GradeID = new SelectList(db.Grades.OrderBy(s => s.GradeName), "GradeID", "GradeName", emp.GradeID); ViewBag.JobID = new SelectList(db.JobTitles.OrderBy(s => s.JobTitle1), "JobID", "JobTitle1", emp.JobID); ViewBag.SecID = new SelectList(db.Sections.OrderBy(s => s.SectionName), "SectionID", "SectionName", emp.SecID); ViewBag.ShiftID = new SelectList(db.Shifts.OrderBy(s => s.ShiftName), "ShiftID", "ShiftName", emp.ShiftID); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName", emp.TypeID); ViewBag.EmpID = new SelectList(db.EmpFaces.OrderBy(s => s.Face1), "EmpID", "Face1"); ViewBag.EmpID = new SelectList(db.EmpFps.OrderBy(s => s.Fp1), "EmpID", "Fp1"); ViewBag.EmpID = new SelectList(db.LvQuotas.OrderBy(s => s.CompanyID), "EmpID", "EmpID"); ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName", emp.Section.DeptID); } catch (Exception ex) { } return(View(emp)); }
public ActionResult Create(AttProcessorScheduler attprocessor) { string d = Request.Form["CriteriaID"].ToString(); switch (d) { case "C": attprocessor.Criteria = "C"; break; case "L": attprocessor.Criteria = "L"; break; case "A": attprocessor.Criteria = "A"; break; case "E": { attprocessor.Criteria = "E"; attprocessor.ProcessCat = false; string ee = Request.Form["EmpNo"].ToString(); int cc = Convert.ToInt16(Request.Form["CompanyIDForEmp"].ToString()); List <Emp> empss = new List <Emp>(); empss = context.Emps.Where(aa => aa.EmpNo == ee && aa.CompanyID == cc).ToList(); if (empss.Count() > 0) { attprocessor.EmpID = empss.First().EmpID; attprocessor.EmpNo = empss.First().EmpNo; } } break; } int a = Convert.ToInt16(Request.Form["ProcessCats"].ToString()); if (a == 1) { attprocessor.ProcessCat = true; } else { attprocessor.ProcessCat = false; } attprocessor.ProcessingDone = false; attprocessor.WhenToProcess = DateTime.Today; attprocessor.CreatedDate = DateTime.Now; int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); if ((attprocessor.DateTo - attprocessor.DateFrom).Days > 3 & attprocessor.PeriodTag == "D") { ModelState.AddModelError("DateTo", "Date Difference must be between 3 days!"); } if (ModelState.IsValid) { attprocessor.UserID = _userID; context.AttProcessorSchedulers.Add(attprocessor); context.SaveChanges(); return(RedirectToAction("Index")); } TAS2013Entities db = new TAS2013Entities(); User LoggedInUser = Session["LoggedUser"] as User; QueryBuilder qb = new QueryBuilder(); String query = qb.QueryForCompanyViewLinq(LoggedInUser); ViewBag.PeriodTag = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = false, Text = "Monthly", Value = "M" }, new SelectListItem { Selected = true, Text = "Daily", Value = "D" }, new SelectListItem { Selected = false, Text = "Summary", Value = "S" }, }, "Value", "Text", 1); ViewBag.CriteriaID = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Company", Value = "C" }, new SelectListItem { Selected = false, Text = "Location", Value = "L" }, new SelectListItem { Selected = false, Text = "Employee", Value = "E" }, }, "Value", "Text", 1); ViewBag.ProcessCats = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Yes", Value = "1" }, new SelectListItem { Selected = false, Text = "No", Value = "0" }, }, "Value", "Text", 1); if (LoggedInUser.RoleID == 1) { ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDForEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); } else { ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDForEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); query = qb.QueryForLocationTableSegerationForLinq(LoggedInUser); ViewBag.LocationID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName"); } ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View(attprocessor)); }
public ActionResult Edit([Bind(Include = "EmpID,EmpNo,EmpName,DesigID,JobID,Gender,ShiftID,LocID,TypeID,GradeID,SecID,CardNo,FpID,PinCode,NicNo,FatherName,BloodGroup,BirthDate,MarStatus,JoinDate,ValidDate,IssueDate,ResignDate,HomeAdd,ProcessAtt,ProcessIn,Status,PhoneNo,Remarks,Email,CellNo,CrewID,FlagFP,FlagFace,FlagCard,EmpImageID,CompanyID,HasOT,IsSafe,LastEntryDateTime,ReaderID")] Emp emp) { try { ViewBag.Message = ""; TAS2013Entities ctx = new TAS2013Entities(); HttpPostedFileBase file = Request.Files["ImageData"]; if (file != null) { if (file.FileName != "") { ImageConversion _Image = new ImageConversion(); int imageid = _Image.UploadImageInDataBase(file, emp); if (imageid != 0) { emp.EmpImageID = imageid; } else { } } } if (string.IsNullOrEmpty(emp.EmpNo)) { ModelState.AddModelError("EmpNo", "Emp No field is required!"); } if (string.IsNullOrEmpty(emp.EmpName)) { ModelState.AddModelError("EmpName", "Namefield is required!"); } if (emp.EmpNo != null) { if (emp.EmpNo.Length > 15) { ModelState.AddModelError("EmpNo", "String length exceeds!"); } } if (emp.EmpName != null) { if (emp.EmpName.Length > 40) { ModelState.AddModelError("EmpName", "String length exceeds!"); } } if (emp.SecID == null) { ModelState.AddModelError("SecID", "Please Specify section!"); } if (emp.TypeID == null) { ModelState.AddModelError("TypeID", "Please Specify Type!"); } if (emp.GradeID == null) { ModelState.AddModelError("GradeID", "Please Specify Grade!"); } if (ModelState.IsValid) { emp.EmpNo = emp.EmpNo.ToUpper(); db.Entry(emp).State = EntityState.Modified; ViewBag.JS = "toastr.success('" + emp.EmpName + " data Successfully edited');"; db.SaveChanges(); int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Employee, (byte)MyEnums.Operation.Edit, DateTime.Now); return(RedirectToAction("Index")); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", emp.CompanyID); ViewBag.LocID = new SelectList(CustomFunction.GetLocations(db.Locations.ToList(), db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()), "LocID", "LocName", emp.CompanyID); ViewBag.CrewID = new SelectList(db.Crews.OrderBy(s => s.CrewName), "CrewID", "CrewName"); ViewBag.DesigID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName"); ViewBag.GradeID = new SelectList(db.Grades.OrderBy(s => s.GradeName), "GradeID", "GradeName"); ViewBag.JobID = new SelectList(db.JobTitles.OrderBy(s => s.JobTitle1), "JobID", "JobTitle1"); ViewBag.SecID = new SelectList(db.Sections.OrderBy(s => s.SectionName), "SectionID", "SectionName"); ViewBag.ShiftID = new SelectList(db.Shifts.OrderBy(s => s.ShiftName), "ShiftID", "ShiftName"); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); ViewBag.EmpID = new SelectList(db.EmpFaces.OrderBy(s => s.Face1), "EmpID", "Face1"); ViewBag.EmpID = new SelectList(db.EmpFps.OrderBy(s => s.Fp1), "EmpID", "Fp1"); ViewBag.EmpID = new SelectList(db.LvQuotas.OrderBy(s => s.CompanyID), "EmpID", "EmpID"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); return(View(emp)); } catch (Exception ex) { ViewBag.Message = ex.InnerException.ToString(); User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(s => s.CompName), "CompID", "CompName"); ViewBag.CrewID = new SelectList(db.Crews.OrderBy(s => s.CrewName), "CrewID", "CrewName"); ViewBag.DesigID = new SelectList(db.Designations.OrderBy(s => s.DesignationName), "DesignationID", "DesignationName"); ViewBag.GradeID = new SelectList(db.Grades.OrderBy(s => s.GradeName), "GradeID", "GradeName"); ViewBag.JobID = new SelectList(db.JobTitles.OrderBy(s => s.JobTitle1), "JobID", "JobTitle1"); ViewBag.LocID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.SecID = new SelectList(db.Sections.OrderBy(s => s.SectionName), "SectionID", "SectionName"); ViewBag.ShiftID = new SelectList(db.Shifts.OrderBy(s => s.ShiftName), "ShiftID", "ShiftName"); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); ViewBag.EmpID = new SelectList(db.EmpFaces.OrderBy(s => s.Face1), "EmpID", "Face1"); ViewBag.EmpID = new SelectList(db.EmpFps.OrderBy(s => s.Fp1), "EmpID", "Fp1"); ViewBag.EmpID = new SelectList(db.LvQuotas.OrderBy(s => s.CompanyID), "EmpID", "EmpID"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); ViewBag.DeptID = new SelectList(db.Departments.OrderBy(s => s.DeptName), "DeptID", "DeptName"); return(View(emp)); } }