// GET: /Editor/ public ActionResult Index() { TAS2013Entities db = new TAS2013Entities(); if (Session["EditAttendanceDate"] == null) { ViewData["datef"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"); } else { ViewData["datef"] = Session["EditAttendanceDate"].ToString(); } User LoggedInUser = Session["LoggedUser"] as User; ViewData["JobDateFrom"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"); ViewData["JobDateTo"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"); ViewBag.JobCardType = new SelectList(db.JobCards, "WorkCardID", "WorkCardName"); ViewBag.ShiftList = new SelectList(db.Shifts, "ShiftID", "ShiftName"); // string _EmpNo = Request.Form["EmpNo"].ToString(); ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDJobCard = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CrewList = new SelectList(db.Crews, "CrewID", "CrewName"); ViewBag.SectionList = new SelectList(db.Sections, "SectionID", "SectionName"); ViewBag.DesignationID = new SelectList(db.Designations.Where(aa => aa.CompanyID == LoggedInUser.CompanyID), "DesignationID", "DesignationName"); ViewBag.Message = ""; return(View()); }
// GET: /Editor/Create public ActionResult Create() { User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompName = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); return(View()); }
// // 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() { 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())); }
public ActionResult Create() { User LoggedInUser = Session["LoggedUser"] as User; ViewBag.EmpID = new SelectList(db.Emps.OrderBy(s => s.EmpName), "EmpID", "EmpNo"); ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LvType = new SelectList(db.LvTypes.Where(aa => aa.Enable == true).OrderBy(s => s.LvType1).ToList(), "LvType1", "LvDesc"); return(View()); }
public ActionResult Index() { User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View()); }
public ActionResult CreateLeaveQuota() { float AL = float.Parse(Request.Form["ALeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float CL = float.Parse(Request.Form["CLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float SL = float.Parse(Request.Form["SLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); //float CPL = float.Parse(Request.Form["CPLLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); List <Emp> _Emp = new List <Emp>(); List <LvType> _lvType = new List <LvType>(); byte catID = Convert.ToByte(Request.Form["CatID"].ToString()); switch (Request.Form["cars"].ToString()) { case "company": string companyIDs = Request.Form["CompanyID"].ToString(); int compID = Convert.ToInt32(Request.Form["CompanyID"].ToString()); _Emp = db.Emps.Where(aa => aa.CompanyID == compID && aa.EmpType.CatID == catID).ToList(); break; case "location": int locID = Convert.ToInt32(Request.Form["LocationID"].ToString()); _Emp = db.Emps.Where(aa => aa.LocID == locID && aa.EmpType.CatID == catID).ToList(); break; case "employee": int compIDemp = Convert.ToInt32(Request.Form["CompanyIDEmp"].ToString()); string empNo = Request.Form["EmpNo"].ToString(); _Emp = db.Emps.Where(aa => aa.CompanyID == compIDemp && aa.EmpNo == empNo).ToList(); break; } User LoggedInUser = Session["LoggedUser"] as User; if (_Emp.Count > 0) { _lvType = db.LvTypes.Where(aa => aa.UpdateBalance == true).ToList(); GenerateLeaveQuotaAttributes(_Emp, _lvType, AL, CL, SL); ViewBag.CMessage = "Leave Balance is created"; } else { ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found"; } ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View("Index")); }
public ActionResult Create([Bind(Include = "EmpDate,AttDate,Tin1,Tout1,Tin2,Tout2,Tin3,Tout3,Mins,EmpNo,EmpName,Expr1,CompName,EmpID")] ViewAttDataOT viewattdataot) { User LoggedInUser = Session["LoggedUser"] as User; if (viewattdataot.CompName == null) { ModelState.AddModelError("CompName", "This Company Name is not existing"); } if (ModelState.IsValid) { db.ViewAttDataOTs.Add(viewattdataot); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CompName = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); return(View(viewattdataot)); }
// GET: /ApprovedOT/ public ActionResult Index() { if (Session["EditAttendanceDate"] == null) { ViewData["datef"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"); ViewData["datet"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd"); } else { ViewData["datef"] = Session["EditAttendanceDate"].ToString(); ViewData["datet"] = Session["EditAttendanceDate"].ToString(); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); return(View(db.ApprovedOTs.ToList())); }
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 SingleEmpEditOT() { User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); if (Request.Form["EmpNo"].ToString() != "" && Request.Form["DateFrom"].ToString() != "" && Request.Form["DateTo"].ToString() != "") { string _EmpNo = Request.Form["EmpNo"].ToString(); int CompID = Convert.ToInt32(Request.Form["CompanyID"].ToString()); DateTime _AttDataFrom = Convert.ToDateTime(Request.Form["DateFrom"].ToString()); DateTime _AttDateTo = Convert.ToDateTime(Request.Form["DateTo"].ToString()); List <ViewAttData> dailyAttendance = new List <ViewAttData>(); List <CustomShiftModel> shifts = new List <CustomShiftModel>(); shifts = GetCustomShifts(); dailyAttendance = db.ViewAttDatas.Where(aa => aa.EmpNo == _EmpNo && aa.CompanyID == CompID && aa.AttDate >= _AttDataFrom && aa.AttDate <= _AttDateTo).ToList(); if (dailyAttendance.Count > 0) { int empid = (int)dailyAttendance.FirstOrDefault().EmpID; List <AttDataAppOT> attDataOTApp = new List <AttDataAppOT>(); List <OTApprovalList> vm = new List <OTApprovalList>(); // {"Invalid object name 'dbo.AttDataAppOT'."} attDataOTApp = db.AttDataAppOTs.Where(aa => aa.AEmpID == empid && aa.AAttDate >= _AttDataFrom && aa.AAttDate <= _AttDateTo).ToList(); int totalNorHours = 0; int totalAppHours = 0; foreach (var att in dailyAttendance) { OTApprovalList v = new OTApprovalList(); v.ActualOTHours = ConvertIntoTime(att.OTMin, att.GZOTMin); v.ApprOTHours = GetApprovedOT(attDataOTApp.Where(aa => aa.AEmpDate == att.EmpDate)); v.ShiftID = GetShiftID(attDataOTApp.Where(aa => aa.AEmpDate == att.EmpDate), shifts); totalAppHours = totalAppHours + GetApprovedOTMins(attDataOTApp.Where(aa => aa.AEmpDate == att.EmpDate)); if (att.OTMin > 0) { totalNorHours = (int)(totalNorHours + att.OTMin); } if (att.GZOTMin > 0) { totalNorHours = (int)(totalNorHours + att.GZOTMin); } v.Name = att.EmpName; v.EmpDate = att.EmpDate; v.EmpNo = att.EmpNo; v.DesignationName = att.DesignationName; v.SectionName = att.SectionName; v.AttDate = Convert.ToDateTime(att.AttDate).ToString(); vm.Add(v); } OTApprovalList ota = new OTApprovalList(); ota.ActualOTHours = ((int)(totalNorHours / 60)).ToString(); ota.ApprOTHours = ((int)(totalAppHours / 60)).ToString(); ota.ShiftID = ""; ota.Name = ""; ota.EmpDate = ""; ota.EmpNo = "Total"; ota.DesignationName = ""; ota.SectionName = ""; ota.AttDate = ""; vm.Add(ota); VMOTEditor vmOT = new VMOTEditor(); vmOT.OTList = vm; vmOT.Shifts = shifts; vmOT.EmpNo = _EmpNo; vmOT.CompanyID = CompID; vmOT.dtFrom = _AttDataFrom; vmOT.dtTo = _AttDateTo; vmOT.Count = vm.Count - 1; vmOT.EmpID = empid; return(View(vmOT)); } } return(View()); }
public ActionResult EditorOT(FormCollection form) { TAS2013Entities db = new TAS2013Entities(); try { User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewData["datef"] = Convert.ToDateTime(Request.Form["DateFrom"].ToString()).ToString("yyyy-MM-dd"); //ViewData["datef"] = Request.Form["DateFrom"].ToString(); if (Request.Form["EmpNo"].ToString() != "" && Request.Form["DateFrom"].ToString() != "") { string _EmpNo = Request.Form["EmpNo"].ToString(); DateTime _AttDataFrom = Convert.ToDateTime(Request.Form["DateFrom"].ToString()); Session["EditAttendanceDate"] = Request.Form["DateFrom"].ToString(); var _CompId = Request.Form["CompanyID"]; int compID = Convert.ToInt32(_CompId); ViewAttDataOT _attData = new ViewAttDataOT(); List <EmpView> _Emp = new List <EmpView>(); int EmpID = 0; _Emp = db.EmpViews.Where(aa => aa.EmpNo == _EmpNo && aa.CompanyID == compID && aa.Status == true).ToList(); if (_Emp.Count > 0) { EmpID = _Emp.FirstOrDefault().EmpID; if (db.AttDataOTs.Where(aa => aa.EmpID == EmpID && aa.AttDate == _AttDataFrom).Count() > 0) { _attData = db.ViewAttDataOTs.First(aa => aa.EmpID == EmpID && aa.AttDate == _AttDataFrom); } } _attData.EmpID = EmpID; _attData.EmpNo = _Emp.FirstOrDefault().EmpNo; _attData.AttDate = _AttDataFrom; _attData.EmpName = _Emp.FirstOrDefault().EmpName; _attData.FatherName = _Emp.FirstOrDefault().FatherName; _attData.SectionName = _Emp.FirstOrDefault().SectionName; _attData.DeptName = _Emp.FirstOrDefault().DeptName; _attData.DesignationName = _Emp.FirstOrDefault().DesignationName; if (_attData.EmpNo != null) { List <PollData> _Polls = new List <PollData>(); string _EmpDate = _attData.EmpID.ToString() + _AttDataFrom.Date.ToString("yyMMdd"); _Polls = db.PollDatas.Where(aa => aa.EntDate == _AttDataFrom && aa.EmpID == _attData.EmpID).OrderBy(a => a.EntTime).ToList(); ViewBag.PollsDataIn = _Polls.Where(aa => aa.Reader.OnlyOT == true && aa.RdrDuty == 1); ViewBag.PollsDataOut = _Polls.Where(aa => aa.Reader.OnlyOT == true && aa.RdrDuty == 1); ViewBag.EmpID = new SelectList(db.Emps.OrderBy(s => s.EmpName), "EmpID", "EmpNo", _attData.EmpID); Session["NEmpNo"] = _attData.EmpID; ViewBag.SucessMessage = ""; return(View(_attData)); } else { return(View(_attData)); } } else { return(View("Index")); } } catch (Exception ex) { if (ex.Message.Contains("Sequence")) { ViewBag.Message = "No Entry found on this particular date"; } return(View("Index")); } }
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)); } }
public ActionResult AdjustLeaveQuotaStepOne() { string EmpNo = Request.Form["AdjustEmpNo"].ToString(); DateTime dt = DateTime.Today; if (Request.Form["ALQDate"].ToString() != "") { string date = Request.Form["ALQDate"].ToString(); dt = Convert.ToDateTime(date); } int CompanyID = Convert.ToInt32(Request.Form["CompanyID"].ToString()); User LoggedInUser = Session["LoggedUser"] as User; var emp = db.Emps.Where(aa => aa.CompanyID == CompanyID && aa.EmpNo == EmpNo && aa.Status == true).ToList(); if (emp.Count > 0) { //Check for Employee lies under user permission if (CheckEmpValidation(emp)) { int EmpID = emp.FirstOrDefault().EmpID; string year = dt.Year.ToString(); var lvType = db.LvConsumeds.Where(aa => aa.EmpID == EmpID && aa.Year == year).ToList(); if (lvType.Count > 0) { //go to next page LeaveQuotaModel lvModel = new LeaveQuotaModel(); lvModel.EmpID = emp.FirstOrDefault().EmpID; lvModel.EmpNo = emp.FirstOrDefault().EmpNo; lvModel.EmpName = emp.FirstOrDefault().EmpName; lvModel.Year = year; lvModel.SectionName = emp.FirstOrDefault().Section.SectionName; foreach (var lv in lvType) { switch (lv.LeaveType) { case "A": //CL if (lv.YearRemaining != null) { lvModel.CL = (float)lv.YearRemaining; } break; case "B": //AL if (lv.YearRemaining != null) { lvModel.AL = (float)lv.YearRemaining; } break; case "C": //SL if (lv.YearRemaining != null) { lvModel.SL = (float)lv.YearRemaining; } break; case "E": //CPL if (lv.YearRemaining != null) { lvModel.CPL = (float)lv.YearRemaining; } break; } } return(View("AdjustLeaves", lvModel)); } } else { ViewBag.CMessage = "Employee No " + Request.Form["AdjustEmpNo"].ToString() + ": Create Leave Quota for this employee"; } } else { ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found"; } ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View("Index")); }
public ActionResult AdjustLeaves(FormCollection collection) { float AL = float.Parse(Request.Form["ALeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float CL = float.Parse(Request.Form["CLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float SL = float.Parse(Request.Form["SLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); float CPL = float.Parse(Request.Form["CPLLeaves"].ToString(), CultureInfo.InvariantCulture.NumberFormat); int EmpID = Convert.ToInt32(Request.Form["EmpID"].ToString()); string year = Request.Form["LvYear"].ToString(); string EmpLvTypeYearCL = EmpID.ToString() + "A" + year; string EmpLvTypeYearAL = EmpID.ToString() + "B" + year; string EmpLvTypeYearSL = EmpID.ToString() + "C" + year; string EmpLvTypeYearCPL = EmpID.ToString() + "E" + year; var lvTypeAL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearAL).ToList(); var lvTypeCL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearCL).ToList(); var lvTypeSL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearSL).ToList(); var lvTypeCPL = db.LvConsumeds.Where(aa => aa.EmpLvTypeYear == EmpLvTypeYearCPL).ToList(); //Anual if (lvTypeAL.Count > 0) { foreach (var item in lvTypeAL) { item.YearRemaining = (float)AL; item.GrandTotalRemaining = (float)AL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = AL; lvConsumed.YearRemaining = AL; lvConsumed.GrandTotal = AL; lvConsumed.GrandTotalRemaining = AL; lvConsumed.EmpLvType = EmpID.ToString() + "B"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearAL; lvConsumed.LeaveType = "B"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } //Casual if (lvTypeCL.Count > 0) { foreach (var item in lvTypeCL) { item.YearRemaining = (float)CL; item.GrandTotalRemaining = (float)CL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = CL; lvConsumed.YearRemaining = CL; lvConsumed.GrandTotal = CL; lvConsumed.GrandTotalRemaining = CL; lvConsumed.EmpLvType = EmpID.ToString() + "A"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearCL; lvConsumed.LeaveType = "A"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } //Sick if (lvTypeSL.Count > 0) { foreach (var item in lvTypeSL) { item.YearRemaining = (float)SL; item.GrandTotalRemaining = (float)SL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = SL; lvConsumed.YearRemaining = SL; lvConsumed.GrandTotal = SL; lvConsumed.GrandTotalRemaining = SL; lvConsumed.EmpLvType = EmpID.ToString() + "C"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearSL; lvConsumed.LeaveType = "C"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } //CPL if (lvTypeCPL.Count > 0) { foreach (var item in lvTypeCPL) { item.YearRemaining = (float)CPL; item.GrandTotalRemaining = (float)CPL; db.SaveChanges(); } } else { LvConsumed lvConsumed = new LvConsumed(); lvConsumed.Year = DateTime.Today.Year.ToString(); lvConsumed.EmpID = EmpID; lvConsumed.JanConsumed = 0; lvConsumed.FebConsumed = 0; lvConsumed.MarchConsumed = 0; lvConsumed.AprConsumed = 0; lvConsumed.MayConsumed = 0; lvConsumed.JuneConsumed = 0; lvConsumed.JulyConsumed = 0; lvConsumed.AugustConsumed = 0; lvConsumed.SepConsumed = 0; lvConsumed.OctConsumed = 0; lvConsumed.NovConsumed = 0; lvConsumed.DecConsumed = 0; lvConsumed.TotalForYear = CPL; lvConsumed.YearRemaining = CPL; lvConsumed.GrandTotal = CPL; lvConsumed.GrandTotalRemaining = CPL; lvConsumed.EmpLvType = EmpID.ToString() + "E"; lvConsumed.EmpLvTypeYear = EmpLvTypeYearCPL; lvConsumed.LeaveType = "E"; db.LvConsumeds.Add(lvConsumed); db.SaveChanges(); } User LoggedInUser = Session["LoggedUser"] as User; ViewBag.CompanyID = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID); ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.CatID = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName"); return(View("Index")); }