public ActionResult HoursIndex(Nullable<DateTime> DateTimeQuery, string CompList) { db = new EMSEntities12(); //if (DateTimeQuery != null) //{ // return View("HoursWorkedReport" ); //} DateTime timeofweek = DateTime.Now ; Company MyComp = new Company(); EmployeeType MyEmp = new EmployeeType(); TimeCard TimeCardEnt = new TimeCard(); Dictionary<EmployeeType, decimal?> emplist2 = new Dictionary<EmployeeType, decimal?>(); List<TimeCard> tmcard = new List<TimeCard>(); if (DateTimeQuery != null) { ViewBag.ThisCompany = CompList; timeofweek = (DateTime)DateTimeQuery; foreach (Company mycmp in db.Companies) { if (mycmp.CompanyName == CompList) { MyComp.CompanyId = mycmp.CompanyId; } } while (timeofweek.DayOfWeek != DayOfWeek.Sunday) { timeofweek = timeofweek.AddDays(+1); } ViewBag.DateWeek = timeofweek; } List<EmployeeType> emplist = new List<EmployeeType>(); foreach (EmployeeType EmpTime in db.EmployeeTypes) { if (EmpTime.CompanyId == MyComp.CompanyId) { if (EmpTime.Employee.Completed && EmpTime.Employee.Active) { if (EmpTime.EmployeeType1 != "Contract ") { emplist.Add(EmpTime); } } } } foreach (TimeCard TimecrdEnt in db.TimeCards) { if (TimecrdEnt.EmployedWith5Id == MyComp.CompanyId) { tmcard.Add(TimecrdEnt); } } foreach (EmployeeType EMP in emplist) { foreach (TimeCard tmcrd in tmcard) { if (EMP.EmployeeId == tmcrd.EmployeeRef5Id) { if (DateTimeQuery == tmcrd.WeekOf) { emplist2.Add(EMP, TotalHours(tmcrd)); } } } } return View("HoursWorkedReport", emplist2); }
public ActionResult Seasonal(SeasonalEmployee Semployee, string CompList, string SeasonLst, string name, string last, string day, string month, string year, string sin) { db = new EMSEntities12(); ViewBag.SeasonName = EMSPSSUtilities.GetSeasonList(); ViewBag.CompName = EMSPSSUtilities.GetCompList(); EmployeeType ETemployee = new EmployeeType(); ViewBag.Employees = GetOptions(); Employee employee = new Employee(); employee.FirstName = name; employee.LastName = last; int Year = 0, Month = 0, Day = 0; Int32.TryParse(year, out Year); Int32.TryParse(day, out Day); Int32.TryParse(month, out Month); employee.DateOfBirth = new DateTime(Year, Month, Day); employee.SIN_BN = sin; employee.Completed = false; foreach (Company mycmp in db.Companies) { if (mycmp.CompanyName == CompList) { Semployee.EmployedWith3Id = mycmp.CompanyId; } } foreach (Season myseas in db.Seasons) { if (myseas.Season1 == SeasonLst) { Semployee.SeasonId = myseas.SeasonId; } } ETemployee.CompanyId = Semployee.EmployedWith3Id; ETemployee.EmployeeType1 = "Seasonal"; ETemployee.DateofHire = Semployee.SeasonYear; if (CompList == "") { ModelState.AddModelError("comp", "This field is Required."); } if (SeasonLst == "") { ModelState.AddModelError("season", "This field is Required."); } if (!EMSPSSUtilities.DateIsElapsed(employee.DateOfBirth, Semployee.SeasonYear, 18)) { ModelState.AddModelError("DOH", "A seasonal employee must be at least 18 years old."); } if (ModelState.IsValid) { db.Employees.Add(employee); db.SaveChanges(); EMSPSSUtilities.AuditNewBaseEmployee(employee, User.Identity.Name); Semployee.EmployeeRef3Id = employee.EmployeeId; ETemployee.EmployeeId = Semployee.EmployeeRef3Id; EMSPSSUtilities.CompareFields("", Semployee.SeasonId.ToString(), 17, 1, Semployee.EmployeeRef3Id, User.Identity.Name); db.SeasonalEmployees.Add(Semployee); db.EmployeeTypes.Add(ETemployee); db.SaveChanges(); return RedirectToAction("SearchIndex", "Home", new { FirstName = Semployee.Employee.FirstName, LastName = Semployee.Employee.LastName, SINBN = Semployee.Employee.SIN_BN }); } return View(Semployee); }
public ActionResult ContractCreation(ContractEmployee ce, string CompList) { db = new EMSEntities12(); if (CompList == "") { ModelState.AddModelError("comp", "This field is Required."); } ViewBag.CompName = EMSPSSUtilities.GetCompList(); Employee e = ce.Employee; //e.EmployeeId = null; e.Completed = true; String sin = ce.Employee.SIN_BN; EMSPSSUtilities.SINValid(ref sin); ce.Employee.SIN_BN = sin; if (!EMSPSSUtilities.VerifySIN(ce.Employee.SIN_BN)) { ModelState.AddModelError("SIN_BN", ce.Employee.SIN_BN + " is not a valid BN."); } if (!EMSPSSUtilities.VerifyBusinessNum(ce.Employee.SIN_BN, ce.Employee.DateOfBirth.ToString("yyyy-MM-dd"))) { ModelState.AddModelError("SIN_BN", "The first two digits of a BN must match the last two digits of their date of incorporation."); } if (!EMSPSSUtilities.DateIsElapsed(ce.Employee.DateOfBirth, ce.ContractStartDate)) { ModelState.AddModelError("CSD", "Contract Start date must be in the future from date of incorporation."); } if (!EMSPSSUtilities.DateIsElapsed(ce.ContractStartDate, ce.ContractStopDate)) { ModelState.AddModelError("CSD2", "Contract Stop date must be in the future from Contract Start date."); } if (ModelState.IsValid) { db.Employees.Add(e); db.SaveChanges(); foreach (Company mycmp in db.Companies) { if (mycmp.CompanyName == CompList) { ce.EmployedWith4Id = mycmp.CompanyId; } } ce.EmployeeRef4Id = e.EmployeeId; EmployeeType et = new EmployeeType(); et.EmployeeId = e.EmployeeId; et.CompanyId = ce.EmployedWith4Id; et.DateofHire = ce.ContractStartDate; et.EmployeeType1 = "Contract"; if (ce.ReasonForLeaving4Id == 0) { ce.ReasonForLeaving4Id = null; } if (ModelState.IsValid) { EMSPSSUtilities.AuditNewBaseEmployee(ce.Employee, User.Identity.Name); EMSPSSUtilities.AuditNewContractEmployee(ce, User.Identity.Name); db.ContractEmployees.Add(ce); db.EmployeeTypes.Add(et); db.SaveChanges(); return RedirectToAction("SearchIndex", "Home", new { FirstName = ce.Employee.FirstName, LastName = ce.Employee.LastName, SINBN = ce.Employee.SIN_BN }); } return View(ce); } return View(ce); }
public ActionResult PartTime(PartTimeEmployee PTemployee, string CompList, string name, string last, string day, string month, string year, string sin) { db = new EMSEntities12(); EmployeeType ETemployee = new EmployeeType(); ViewBag.Employees = GetOptions(); ViewBag.CompName = EMSPSSUtilities.GetCompList(); Employee employee = new Employee(); employee.FirstName = name; employee.LastName = last; int Year = 0, Month = 0, Day = 0; Int32.TryParse(year, out Year); Int32.TryParse(day, out Day); Int32.TryParse(month, out Month); employee.DateOfBirth = new DateTime(Year, Month, Day); employee.SIN_BN = sin; employee.Completed = false; foreach (Company mycmp in db.Companies) { if (mycmp.CompanyName == CompList) { PTemployee.EmployedWith2Id = mycmp.CompanyId; } } ETemployee.CompanyId = PTemployee.EmployedWith2Id; ETemployee.EmployeeType1 = "Part Time"; ETemployee.DateofHire = PTemployee.DateOfHire; PTemployee.Employee = employee; if (CompList == "") { ModelState.AddModelError("comp", "This field is Required."); } if (!EMSPSSUtilities.DateIsElapsed(employee.DateOfBirth, PTemployee.DateOfHire, 16)) { ModelState.AddModelError("DOH", "A part time employee must be at least 16 years old."); } if (ModelState.IsValid) { db.Employees.Add(employee); db.SaveChanges(); EMSPSSUtilities.AuditNewBaseEmployee(employee, User.Identity.Name); PTemployee.EmployeeRef2Id = employee.EmployeeId; ETemployee.EmployeeId = PTemployee.EmployeeRef2Id; EMSPSSUtilities.CompareFields("", PTemployee.DateOfHire.ToString(), 11, 1, PTemployee.EmployeeRef2Id, User.Identity.Name); db.PartTimeEmployees.Add(PTemployee); db.EmployeeTypes.Add(ETemployee); db.SaveChanges(); return RedirectToAction("SearchIndex", "Home", new { FirstName = PTemployee.Employee.FirstName, LastName = PTemployee.Employee.LastName, SINBN = PTemployee.Employee.SIN_BN }); } return View(PTemployee); }