public ActionResult EditorOT(VMOTEntry vmdata) { try { User LoggedInUser = Session["LoggedUser"] as User; List <EmpView> emps = new List <EmpView>(); emps = db.EmpViews.Where(aa => aa.EmpNo == vmdata.EmpNo && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); if (emps.Count() > 0 && vmdata.FromDate != null && vmdata.ToDate != null) { List <ViewAttData> attdata = new List <ViewAttData>(); attdata = db.ViewAttDatas.Where(aa => aa.EmpNo == vmdata.EmpNo && aa.AttDate >= vmdata.FromDate && aa.AttDate <= vmdata.ToDate).ToList(); vmdata.dbViewAttData = attdata; vmdata.Count = attdata.Count; } else { ViewBag.Message = "There is no employee found"; } return(View("Index", vmdata)); } catch (Exception) { throw; } }
public ActionResult CreateLeaveQuota() { double AL = Convert.ToDouble(Request.Form["ALeaves"].ToString()); double CL = Convert.ToDouble(Request.Form["CLeaves"].ToString()); double SL = Convert.ToDouble(Request.Form["SLeaves"].ToString()); DateTime QYear = Convert.ToDateTime(Request.Form["QYear"].ToString()); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); List <EmpView> emps = new List <EmpView>(); User LoggedInUser = Session["LoggedUser"] as User; List <LvType> _lvType = new List <LvType>(); string rb = Request.Form["RBQuotaEmpSelection"].ToString(); switch (rb) { case "byAll": emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); break; case "byEmpType": int EmpType = Convert.ToInt32(Request.Form["TypeID"].ToString()); emps = db.EmpViews.Where(aa => aa.TypeID == EmpType && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); break; case "byEmp": string empNo = Request.Form["EmpNo"].ToString(); emps = db.EmpViews.Where(aa => aa.EmpNo == empNo && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); break; } if (emps.Count > 0) { _lvType = db.LvTypes.Where(aa => aa.UpdateBalance == true).ToList(); string val = CheckEmployeeLeaveQuota(emps, QYear.Year.ToString()); if (val == "OK") { GenerateLeaveQuotaAttributes(emps, _lvType, AL, CL, SL, QYear.Year.ToString()); ViewBag.CMessage = "Leave Balance is created"; } else { ViewBag.CMessage = "Already created quota for specific employee " + val; } } else { ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found"; } ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); ViewBag.TypeID = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName"); return(View("Index")); }
// GET: /Section/ public ActionResult Index(string sortOrder, string searchString, string currentFilter, int?page) { if (Session["LogedUserFullname"].ToString() != "") { ViewBag.CurrentSort = sortOrder; ViewBag.SectionSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; if (searchString != null) { page = 1; } else { searchString = currentFilter; } ViewBag.CurrentFilter = searchString; User LoggedInUser = HttpContext.Session["LoggedUser"] as User; List <Section> sections = new List <Section>(); sections = db.Sections.ToList(); sections = AssistantQuery.GetFilteredSections(sections, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); if (!String.IsNullOrEmpty(searchString)) { sections = sections.Where(s => s.SectionName.ToUpper().Contains(searchString.ToUpper()) || s.Department.DeptName.ToUpper().Contains(searchString.ToUpper())).ToList(); } switch (sortOrder) { case "name_desc": sections = sections.OrderByDescending(s => s.SectionName).ToList(); break; default: sections = sections.OrderBy(s => s.SectionName).ToList(); break; } int pageSize = 8; int pageNumber = (page ?? 1); return(View(sections.ToPagedList(pageNumber, pageSize))); } else { return(Redirect(Request.UrlReferrer.ToString())); } }
public ActionResult JCLeaveEditor(VMLeaveEditor vmdata) { List <string> dropDownValues = new List <string>(); dropDownValues.Add("None"); dropDownValues.AddRange(db.JobCards.Select(aa => aa.WorkCardName).ToList()); dropDownValues.AddRange(db.LvTypes.Select(aa => aa.LvDesc).ToList()); dropDownValues.Add("HLV:Casual"); dropDownValues.Add("HLV:Annual"); vmdata.dropdowns = dropDownValues; User LoggedInUser = Session["LoggedUser"] as User; List <EmpView> emps = new List <EmpView>(); emps = db.EmpViews.Where(aa => aa.EmpNo == vmdata.EmpNo && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); try { if (emps.Count() > 0 && vmdata.FromDate != null && vmdata.ToDate != null) { List <ViewAttData> attdata = new List <ViewAttData>(); attdata = db.ViewAttDatas.Where(aa => aa.EmpNo == vmdata.EmpNo && aa.AttDate >= vmdata.FromDate && aa.AttDate <= vmdata.ToDate && aa.StatusAB == true).ToList(); if (attdata.Count() == 0) { ViewBag.message = "No entry found"; } vmdata.dbViewAttData = attdata; } else { ViewBag.Messages = "There is no employee found"; } return(View("Index", vmdata)); } catch (Exception) { throw; } }
public ActionResult EditAttWizardOne(FormCollection form) { try { User LoggedInUser = Session["LoggedUser"] as User; 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(); AttData _attData = new AttData(); List <EmpView> emps = new List <EmpView>(); int EmpID = 0; emps = db.EmpViews.Where(aa => aa.EmpNo == _EmpNo && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); if (emps.Count > 0) { EmpID = emps.FirstOrDefault().EmpID; if (db.AttDatas.Where(aa => aa.EmpID == EmpID && aa.AttDate == _AttDataFrom).Count() > 0) { _attData = db.AttDatas.FirstOrDefault(aa => aa.EmpID == EmpID && aa.AttDate == _AttDataFrom); List <PollData> _Polls = new List <PollData>(); string _EmpDate = _attData.EmpID.ToString() + _AttDataFrom.Date.ToString("yyMMdd"); _Polls = db.PollDatas.Where(aa => aa.EmpDate == _EmpDate).OrderBy(a => a.EntTime).ToList(); ViewBag.PollsDataIn = _Polls.Where(aa => aa.RdrDuty == 1); ViewBag.PollsDataOut = _Polls.Where(aa => aa.RdrDuty == 5); ViewBag.EmpID = new SelectList(db.Emps.OrderBy(s => s.EmpName), "EmpID", "EmpNo", _attData.EmpID); Session["NEmpNo"] = _attData.EmpID; ViewBag.SucessMessage = ""; if (_attData.WorkMin != null) { ViewBag.WorkMin = (TimeSpan.FromMinutes((double)_attData.WorkMin)); } if (_attData.LateOut != null) { ViewBag.LateOut = TimeSpan.FromMinutes((double)_attData.LateOut); } if (_attData.LateIn != null) { ViewBag.LateIn = TimeSpan.FromMinutes((double)_attData.LateIn); } if (_attData.EarlyOut != null) { ViewBag.EarlyOut = TimeSpan.FromMinutes((double)_attData.EarlyOut); } if (_attData.EarlyIn != null) { ViewBag.EarlyIn = TimeSpan.FromMinutes((double)_attData.EarlyIn); } if (_attData.OTMin != null) { ViewBag.OT = TimeSpan.FromMinutes((double)_attData.OTMin); } if (_attData.GZOTMin != null) { ViewBag.GZOT = TimeSpan.FromMinutes((double)_attData.GZOTMin); } return(View(_attData)); } else { ViewBag.Message = "Attendance Not Found"; return(View("Index")); } } else { ViewBag.Message = "No employee found"; } } else { ViewBag.Message = "Please fill all field"; } 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 EditAttJobCard() { User LoggedInUser = Session["LoggedUser"] as User; string Message = ""; string MessageSuccess = ""; string criteria = Request.Form["CreateJCCriteria"].ToString(); short _WorkCardID = Convert.ToInt16(Request.Form["JobCardType"].ToString()); //First Save Job Card Application JobCardApp jobCardApp = new JobCardApp(); jobCardApp.CardType = _WorkCardID; jobCardApp.DateCreated = DateTime.Now; jobCardApp.DateStarted = Convert.ToDateTime(Request.Form["JobDateFrom"]); jobCardApp.DateEnded = Convert.ToDateTime(Request.Form["JobDateTo"]); jobCardApp.Status = false; string Remakrs = Request.Form["Remakrs"].ToString(); if (Remakrs != "") { jobCardApp.Remarks = Remakrs; } jobCardApp.UserID = LoggedInUser.UserID; int NoOfDays = (int)(jobCardApp.DateEnded.Value - jobCardApp.DateStarted.Value).TotalDays; if (NoOfDays < 400) { if (jobCardApp.DateStarted <= jobCardApp.DateEnded) { switch (criteria) { case "ByCrew": jobCardApp.CriteriaDate = Convert.ToInt32(Request.Form["CrewID"].ToString()); jobCardApp.JobCardCriteria = "C"; if (ValidateJobCard(jobCardApp)) { db.JobCardApps.Add(jobCardApp); if (db.SaveChanges() > 0) { AddJobCardAppToJobCardData(); } } else { Message = "Job Card Validation failed"; } break; case "ByEmployee": string EmpNo = Request.Form["EmpNo"].ToString(); List <EmpView> emps = new List <EmpView>(); emps = db.EmpViews.Where(aa => aa.EmpNo == EmpNo && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); if (emps.Count > 0) { jobCardApp.CriteriaDate = emps.FirstOrDefault().EmpID; jobCardApp.JobCardCriteria = "E"; if (ValidateJobCard(jobCardApp)) { db.JobCardApps.Add(jobCardApp); if (db.SaveChanges() > 0) { AddJobCardAppToJobCardData(); } } else { Message = "Already applied job card on this date"; } } else { Message = "There is no employee found"; } break; } } else { Message = "Dates format is incorrect, please select correct format"; } } else { Message = "Job card should not be applied more then one year"; } //List<EmpView> emps = new List<EmpView>(); 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.CrewID = new SelectList(db.Crews, "CrewID", "CrewName"); if (Message == "") { MessageSuccess = "Job Card created sucessfully"; } ViewBag.DMessage = MessageSuccess; ViewBag.CMessage = Message; return(View("JCCreate")); }
private void BindGridViewEmployee(string search) { FiltersModel fm = Session["FiltersModel"] as FiltersModel; List <EmpView> _View = new List <EmpView>(); List <EmpView> _TempView = new List <EmpView>(); User LoggedInUser = HttpContext.Current.Session["LoggedUser"] as User; _View = db.EmpViews.Where(aa => aa.Status == true && aa.Deleted != true).ToList(); _View = AssistantQuery.GetFilteredEmps(_View, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); _View = _View.Where(aa => aa.Status == true).ToList(); //if (fm.DivisionFilter.Count > 0) //{ // _TempView.Clear(); // foreach (var comp in fm.DivisionFilter) // { // short _compID = Convert.ToInt16(comp.ID); // _TempView.AddRange(_View.Where(aa => aa.DivID == _compID).ToList()); // } // _View = _TempView.ToList(); //} //if (fm.DepartmentFilter.Count > 0) //{ // _TempView.Clear(); // foreach (var comp in fm.DepartmentFilter) // { // short _compID = Convert.ToInt16(comp.ID); // _TempView.AddRange(_View.Where(aa => aa.DeptID == _compID).ToList()); // } // _View = _TempView.ToList(); //} if (fm.SectionFilter.Count > 0) { _TempView.Clear(); foreach (var comp in fm.SectionFilter) { short _compID = Convert.ToInt16(comp.ID); _TempView.AddRange(_View.Where(aa => aa.SecID == _compID).ToList()); } _View = _TempView.ToList(); } if (fm.TypeFilter.Count > 0) { _TempView.Clear(); foreach (var comp in fm.TypeFilter) { short _compID = Convert.ToInt16(comp.ID); _TempView.AddRange(_View.Where(aa => aa.TypeID == _compID).ToList()); } _View = _TempView.ToList(); } //if (fm.RegionFilter.Count > 0) //{ // _TempView.Clear(); // foreach (var comp in fm.RegionFilter) // { // short _compID = Convert.ToInt16(comp.ID); // _TempView.AddRange(_View.Where(aa => aa.RegionID == _compID).ToList()); // } // _View = _TempView.ToList(); //} //if (fm.CityFilter.Count > 0) //{ // _TempView.Clear(); // foreach (var comp in fm.CityFilter) // { // short _compID = Convert.ToInt16(comp.ID); // _TempView.AddRange(_View.Where(aa => aa.CityID == _compID).ToList()); // } // _View = _TempView.ToList(); //} if (fm.LocationFilter.Count > 0) { _TempView.Clear(); foreach (var comp in fm.LocationFilter) { short _compID = Convert.ToInt16(comp.ID); _TempView.AddRange(_View.Where(aa => aa.LocID == _compID).ToList()); } _View = _TempView.ToList(); } if (fm.ShiftFilter.Count > 0) { _TempView.Clear(); foreach (var comp in fm.ShiftFilter) { short _compID = Convert.ToInt16(comp.ID); _TempView.AddRange(_View.Where(aa => aa.ShiftID == _compID).ToList()); } _View = _TempView.ToList(); } GridViewEmployee.DataSource = _View.Where(aa => aa.EmpName.ToUpper().Contains(search.ToUpper()) || aa.EmpNo.ToUpper().Contains(search.ToUpper())).ToList(); GridViewEmployee.DataBind(); }
// GET: /LvApp/ public ActionResult Index(string sortOrder, string searchString, string currentFilter, int?page) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.TypeSortParm = sortOrder == "LvType" ? "LvType_desc" : "LvType"; ViewBag.DateSortParm = sortOrder == "Date" ? "Date_desc" : "Date"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } User LoggedInUser = Session["LoggedUser"] as User; QueryBuilder qb = new QueryBuilder(); //string query = qb.MakeCustomizeQuery(LoggedInUser); DateTime dt1 = DateTime.Today; DateTime dt2 = new DateTime(dt1.Year, 1, 1); string date = dt2.Year.ToString() + "-" + dt2.Month.ToString() + "-" + dt2.Day.ToString() + " "; DataTable dt = qb.GetValuesfromDB("select * from ViewLvApplication where(ToDate >= '" + date + "') order by LvID desc"); List <ViewLvApplication> lvapplications = dt.ToList <ViewLvApplication>(); lvapplications = AssistantQuery.GetFilteredLeaveApplication(lvapplications, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); ViewBag.CurrentFilter = searchString; //var lvapplications = db.LvApplications.Where(aa=>aa.ToDate>=dt2).Include(l => l.Emp).Include(l => l.LvType1); if (!String.IsNullOrEmpty(searchString)) { lvapplications = lvapplications.Where(s => s.EmpName.ToUpper().Contains(searchString.ToUpper()) || s.EmpNo.ToUpper().Contains(searchString.ToUpper())).ToList(); } switch (sortOrder) { case "name_desc": lvapplications = lvapplications.OrderByDescending(s => s.EmpName).ToList(); break; case "LvType_desc": lvapplications = lvapplications.OrderByDescending(s => s.LeaveTypeID).ToList(); break; case "LvType": lvapplications = lvapplications.OrderBy(s => s.LeaveTypeID).ToList(); break; case "Date_desc": lvapplications = lvapplications.OrderByDescending(s => s.LvDate).ToList(); break; case "Date": lvapplications = lvapplications.OrderBy(s => s.LvDate).ToList(); break; default: lvapplications = lvapplications.OrderBy(s => s.EmpName).ToList(); break; } int pageSize = 8; int pageNumber = (page ?? 1); return(View(lvapplications.OrderBy(aa => aa.LvDate).ToPagedList(pageNumber, pageSize))); }
// GET: /Emp/ public ActionResult Index(string sortOrder, string searchString, string currentFilter, int?page) { ViewBag.CurrentSort = sortOrder; ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : ""; ViewBag.DesigSortParm = sortOrder == "designation" ? "designation_desc" : "designation"; ViewBag.LocSortParm = sortOrder == "location" ? "location_desc" : "location"; ViewBag.SectionSortParm = sortOrder == "section" ? "section_desc" : "section"; ViewBag.DepartmentSortParm = sortOrder == "wing" ? "wing_desc" : "wing"; ViewBag.ShiftSortParm = sortOrder == "shift" ? "shift_desc" : "shift"; ViewBag.TypeSortParm = sortOrder == "type" ? "type_desc" : "type"; if (searchString != null) { page = 1; } else { searchString = currentFilter; } User LoggedInUser = Session["LoggedUser"] as User; int NoOfEmps = 4000; List <EmpView> emps = new List <EmpView>(); emps = db.EmpViews.Where(aa => aa.Status == true && aa.Deleted != true).ToList(); emps = emps.Take(NoOfEmps).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); ViewBag.CurrentFilter = searchString; if (!String.IsNullOrEmpty(searchString)) { if (searchString == "Active" || searchString == "active") { emps = emps.Where(aa => aa.Status == true).ToList(); } else if (searchString == "Inactive" || searchString == "inactive") { emps = emps.Where(aa => aa.Status == false).ToList(); } else { try { emps = emps.Where(s => s.EmpName.ToUpper().Contains(searchString.ToUpper()) || s.EmpNo.Contains(searchString.ToUpper())).ToList(); } catch (Exception) { throw; } } } switch (sortOrder) { case "name_desc": emps = emps.OrderByDescending(s => s.EmpName).ToList(); break; case "designation_desc": emps = emps.OrderByDescending(s => s.DesignationName).ToList(); break; case "designation": emps = emps.OrderBy(s => s.DesignationName).ToList(); break; case "location_desc": emps = emps.OrderByDescending(s => s.LocName).ToList(); break; case "location": emps = emps.OrderBy(s => s.LocName).ToList(); break; case "section_desc": emps = emps.OrderByDescending(s => s.SectionName).ToList(); break; case "section": emps = emps.OrderBy(s => s.SectionName).ToList(); break; //case "wing_desc": // emps = emps.OrderByDescending(s => s.sec.DeptName).ToList(); // break; //case "wing": // emps = emps.OrderBy(s => s.DeptName).ToList(); // break; case "shift_desc": emps = emps.OrderByDescending(s => s.ShiftName).ToList(); break; case "shift": emps = emps.OrderBy(s => s.ShiftName).ToList(); break; case "type_desc": emps = emps.OrderByDescending(s => s.TypeName).ToList(); break; case "type": emps = emps.OrderBy(s => s.TypeName).ToList(); break; default: emps = emps.OrderBy(s => s.EmpName).ToList(); break; } int pageSize = 10; int pageNumber = (page ?? 1); return(View(emps.ToPagedList(pageNumber, pageSize))); //var emps = db.Emps.Include(e => e.Company).Include(e => e.Crew).Include(e => e.Designation).Include(e => e.Grade).Include(e => e.JobTitle).Include(e => e.Location).Include(e => e.Section).Include(e => e.Shift).Include(e => e.EmpType).Include(e => e.EmpFace).Include(e => e.EmpFp).Include(e => e.LvQuota); //return View(emps.ToList()); }
public ActionResult Create(AttProcessorScheduler attprocessor) { User LoggedInUser = Session["LoggedUser"] as User; string d = Request.Form["CriteriaID"].ToString(); string Message = ""; switch (d) { case "C": attprocessor.Criteria = "C"; break; case "L": attprocessor.Criteria = "L"; break; case "E": { TAS2013Entities db = new TAS2013Entities(); attprocessor.Criteria = "E"; string EmpNo = Request.Form["EmpNo"].ToString(); List <EmpView> emps = new List <EmpView>(); emps = db.EmpViews.Where(aa => aa.EmpNo == EmpNo && aa.Status == true).ToList(); emps = AssistantQuery.GetFilteredEmps(emps, db.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList()); if (emps.Count() > 0) { attprocessor.EmpID = emps.First().EmpID; attprocessor.EmpNo = emps.First().EmpNo; } else { Message = "There is no employee found"; ViewBag.CMessage = Message; ViewBag.PeriodTag = new SelectList(new List <SelectListItem> { new SelectListItem { Selected = true, Text = "Daily", Value = "D" }, new SelectListItem { Selected = false, Text = "Monthly", Value = "M" }, 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.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName"); return(View(attprocessor)); } } break; } attprocessor.ProcessingDone = false; int _userID = Convert.ToInt32(Session["LogedUserID"].ToString()); if (ModelState.IsValid) { attprocessor.UserID = _userID; attprocessor.CreatedDate = DateTime.Today; context.AttProcessorSchedulers.Add(attprocessor); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(attprocessor)); }