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);
        }
예제 #2
0
 public ActionResult Edit(Company company)
 {
     db = new EMSEntities12();
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(company);
 }
예제 #3
0
 public ActionResult Edit(Piece piece)
 {
     db = new EMSEntities12();
     if (ModelState.IsValid)
     {
         db.Entry(piece).State = EntityState.Modified;
         db.SaveChanges();
         foreach (Employee emp in db.Employees)
         {
             if (emp.EmployeeId == piece.EmployeeRef6Id)
             {
                 ViewBag.Name = emp.FirstName + " " + emp.LastName;
                 break;
             }
         }
         foreach (Company cmp in db.Companies)
         {
             if (cmp.CompanyId == piece.EmployedWith6Id)
             {
                 ViewBag.Company = cmp.CompanyName;
                 break;
             }
         }
         ViewBag.EmployeeId = piece.EmployeeRef6Id;
         ViewBag.CompanyId = piece.EmployedWith6Id;
         return RedirectToAction("Index", "Pieces", new { EmployeeId = piece.EmployeeRef6Id, CompanyId = piece.EmployedWith6Id });
     }
     return View(piece);
 }
        public ActionResult FindEdit(FullTimeEmployee fulltimeemployee)
        {
            db = new EMSEntities12();
            String sin = fulltimeemployee.Employee.SIN_BN;
            EMSPSSUtilities.SINValid(ref sin);
            fulltimeemployee.Employee.SIN_BN = sin;
            if (fulltimeemployee.DateOfTermination == null)
            {
                fulltimeemployee.ReasonForLeavingId = null;
            }
            else if (fulltimeemployee.DateOfTermination != null && fulltimeemployee.ReasonForLeavingId == 0)
            {
                ModelState.AddModelError("ReasonForLeaving", "You must enter a reason for leaving.");
            }
            if (!EMSPSSUtilities.VerifySIN(fulltimeemployee.Employee.SIN_BN))
            {
                ModelState.AddModelError("SIN_BN", fulltimeemployee.Employee.SIN_BN + " is not a valid SIN.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(Convert.ToDateTime("1900-01-01"), fulltimeemployee.Employee.DateOfBirth))
            {
                ModelState.AddModelError("DOB", "Date of Birth must be past the year 1900.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(fulltimeemployee.Employee.DateOfBirth, DateTime.Now))
            {
                ModelState.AddModelError("DOB", "Date of Birth must be in the past.");
            }
            if (fulltimeemployee.DateOfTermination != null)
            {
                DateTime dot = (DateTime)fulltimeemployee.DateOfTermination;
                if (!EMSPSSUtilities.DateIsElapsed(fulltimeemployee.DateOfHire, dot))
                {
                    ModelState.AddModelError("DOT", "Date of Termination must be in the future from Date of Hire.");
                }
            }
            if (ModelState.IsValid)
            {
                EMSPSSUtilities.AuditExistingEmployee(fulltimeemployee.EmployeeRefId, fulltimeemployee.Employee, User.Identity.Name);
                EMSPSSUtilities.AuditExistingFullTimeEmployee(fulltimeemployee.EmployeeRefId, fulltimeemployee, User.Identity.Name);

                fulltimeemployee.Employee.Completed = EMSPSSUtilities.ValidateFullTimeEmployeeComplete(fulltimeemployee);

                fulltimeemployee.Company = db.Companies.Find(fulltimeemployee.EmployedWithId);

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

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

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

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

            return View(fulltimeemployee);
        }
        public ActionResult FindEdit(ContractEmployee contractemployee)
        {
            db = new EMSEntities12();
            String sin = contractemployee.Employee.SIN_BN;
            EMSPSSUtilities.SINValid(ref sin);
            contractemployee.Employee.Completed = true;
            contractemployee.Employee.SIN_BN = sin;
            if (contractemployee.ReasonForLeaving4Id == 0)
            {
                contractemployee.ReasonForLeaving4Id = null;
            }
            if (!EMSPSSUtilities.VerifySIN(contractemployee.Employee.SIN_BN) || !EMSPSSUtilities.VerifyBusinessNum(contractemployee.Employee.SIN_BN, contractemployee.Employee.DateOfBirth.ToString("yyyy-MM-dd")))
            {
                ModelState.AddModelError("SIN_BN", contractemployee.Employee.SIN_BN + " is not a valid BN.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(Convert.ToDateTime("1600-01-01"), contractemployee.Employee.DateOfBirth))
            {
                ModelState.AddModelError("DOB", "Date of Incorporation must be past the year 1600.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(contractemployee.Employee.DateOfBirth, DateTime.Now))
            {
                ModelState.AddModelError("DOB", "Date of Incorporation must be in the past.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(contractemployee.Employee.DateOfBirth, contractemployee.ContractStartDate))
            {
                ModelState.AddModelError("CSD", "Contract Start date must be in the future from date of incorporation.");
            }
            if (!EMSPSSUtilities.DateIsElapsed(contractemployee.ContractStartDate, contractemployee.ContractStopDate))
            {
                ModelState.AddModelError("CSD2", "Contract Stop date must be in the future from Contract Start date.");
            }
            if (ModelState.IsValid)
            {
                EMSPSSUtilities.AuditExistingEmployee(contractemployee.EmployeeRef4Id, contractemployee.Employee, User.Identity.Name);
                EMSPSSUtilities.AuditExistingContractEmployee(contractemployee.EmployeeRef4Id, contractemployee, User.Identity.Name);

                contractemployee.Company = db.Companies.Find(contractemployee.EmployedWith4Id);

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

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

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

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