Ejemplo n.º 1
0
 public static void AuditExistingSeasonalEmployee(int existingEmpId, SeasonalEmployee newEmployee, String Username)
 {
     SeasonalEmployee s = GetSeasonal(existingEmpId);
     CompareFields(s.PiecePay.ToString(), newEmployee.PiecePay.ToString(), 16, 2, newEmployee.Employee.EmployeeId, Username);
     CompareFields(s.ReasonForLeaving3Id.ToString(), newEmployee.ReasonForLeaving3Id.ToString(), 7, 2, newEmployee.Employee.EmployeeId, Username);
     CompareFields(s.SeasonId.ToString(), newEmployee.SeasonId.ToString(), 17, 2, newEmployee.Employee.EmployeeId, Username);
 }
        public ActionResult FindEdit(SeasonalEmployee seasonalemployee)
        {
            db = new EMSEntities12();
            if (seasonalemployee.ReasonForLeaving3Id == 0)
            {
                seasonalemployee.ReasonForLeaving3Id = null;
            }
            String sin = seasonalemployee.Employee.SIN_BN;
            EMSPSSUtilities.SINValid(ref sin);
            seasonalemployee.Employee.SIN_BN = sin;
            if (!EMSPSSUtilities.VerifySIN(seasonalemployee.Employee.SIN_BN))
            {
                ModelState.AddModelError("SIN_BN", seasonalemployee.Employee.SIN_BN + " is not a valid SIN.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(Convert.ToDateTime("1900-01-01"), seasonalemployee.Employee.DateOfBirth))
            {
                ModelState.AddModelError("DOB", "Date of Birth must be past the year 1900.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(seasonalemployee.Employee.DateOfBirth, DateTime.Now))
            {
                ModelState.AddModelError("DOB", "Date of Birth must be in the past.");
            }

            if (ModelState.IsValid)
            {
                EMSPSSUtilities.AuditExistingEmployee(seasonalemployee.EmployeeRef3Id, seasonalemployee.Employee, User.Identity.Name);
                EMSPSSUtilities.AuditExistingSeasonalEmployee(seasonalemployee.EmployeeRef3Id, seasonalemployee, User.Identity.Name);

                seasonalemployee.Company = db.Companies.Find(seasonalemployee.EmployedWith3Id);

                seasonalemployee.Employee.Completed = EMSPSSUtilities.ValidateSeasonalEmployeeComplete(seasonalemployee);

                db.Entry(seasonalemployee.Employee).State = EntityState.Modified;
                db.SaveChanges();

                db.Entry(seasonalemployee).State = EntityState.Modified;
                db.SaveChanges();

                //ModelState.AddModelError( validationError.PropertyName, validationError.ErrorMessage);

                return RedirectToAction("SearchIndex", "Home", new { FirstName = seasonalemployee.Employee.FirstName, LastName = seasonalemployee.Employee.LastName, SINBN = seasonalemployee.Employee.SIN_BN });
            }

            return View(seasonalemployee);
        }
Ejemplo n.º 3
0
        public static Boolean ValidateSeasonalEmployeeComplete(SeasonalEmployee s)
        {
            Boolean complete = ValidateEmployeeComplete(s.Employee);

            if (s.SeasonYear == null)
            {
                complete = false;
            }
            else if (s.SeasonId == null)
            {
                complete = false;
            }
            else if (s.PiecePay <= 0 || s.PiecePay == null)
            {
                complete = false;
            }
            return complete;
        }
Ejemplo n.º 4
0
 //get a part time employee based on id
 public static SeasonalEmployee GetSeasonal(int id)
 {
     db = new EMSEntities12();
     SeasonalEmployee seasonal = new SeasonalEmployee();
     List<SeasonalEmployee> sl = db.SeasonalEmployees.ToList();
     foreach (SeasonalEmployee s in sl)
     {
         if (s.EmployeeRef3Id == id)
         {
             seasonal = s;
             break;
         }
     }
     return seasonal;
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        public ActionResult Seasonal(string name, string last, string day, string month, string year, string sin)
        {
            SeasonalEmployee employee = new SeasonalEmployee();
            ViewBag.CompName = EMSPSSUtilities.GetCompList();
            ViewBag.Employees = GetOptions();

            ViewBag.SeasonName = EMSPSSUtilities.GetSeasonList();
            ViewBag.Employees = GetOptions();
            return View(employee);
        }