public ActionResult Create(Company company)
        {
            db = new EMSEntities12();
            if (ModelState.IsValid)
            {
                List<Company> companyList = db.Companies.ToList();
                bool companyExists = false;

                for (int x = 0; x < companyList.Count; ++x)
                {
                    if (companyList[x].CompanyName == company.CompanyName)
                    {
                        companyExists = true;
                    }
                }
                if (!companyExists && company.CompanyName != null)
                {
                        company.EnrolledSince = DateTime.Now;
                        db.Companies.Add(company);
                        db.SaveChanges();
                }
                return RedirectToAction("Index");
            }

            return View(company);
        }
 public ActionResult Index()
 {
     db = new EMSEntities12();
     List<Audit> al = db.Audits.ToList();
     al = FixList(al);
     return View(al);
 }
        public ActionResult AdminHome()
        {
            db = new EMSEntities12();
            Employee employee = new Employee();
            List<Employee> emplist = new List<Employee>();

              foreach(FullTimeEmployee FtCompleted in db.FullTimeEmployees )
              {
              if (!FtCompleted.Employee.Completed)
              {
                  emplist.Add(FtCompleted.Employee);

              }
              }
              foreach (PartTimeEmployee PtCompleted in db.PartTimeEmployees)
              {
              if (!PtCompleted.Employee.Completed)
              {
                  emplist.Add(PtCompleted.Employee);

              }
              }
              foreach (SeasonalEmployee SesonCompleted in db.SeasonalEmployees)
              {
              if (!SesonCompleted.Employee.Completed)
              {
                  emplist.Add(SesonCompleted.Employee);

              }
              }

              return View(emplist);
        }
        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 Edit(Company company)
 {
     db = new EMSEntities12();
     if (ModelState.IsValid)
     {
         db.Entry(company).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(company);
 }
 public ViewResult FindDetails(int id)
 {
     db = new EMSEntities12();
     SeasonalEmployee se = EMSPSSUtilities.GetSeasonal(id);
     ReasonForLeaving rfl = db.ReasonForLeavings.Find(se.ReasonForLeaving3Id);
     if (rfl != null)
     {
         ViewBag.Reason = rfl.ReasonForLeaving1;
     }
     ViewBag.SIN = EMSPSSUtilities.FormatSIN_BN(se.Employee.SIN_BN, true);
     return View(se);
 }
        public ViewResult FindDetails(int id)
        {
            db = new EMSEntities12();
            FullTimeEmployee fulltimeemployee = EMSPSSUtilities.GetFullTimer(id);
            ReasonForLeaving rfl = db.ReasonForLeavings.Find(fulltimeemployee.ReasonForLeavingId);
            if (rfl != null)
            {
                ViewBag.Reason = rfl.ReasonForLeaving1;
            }

            ViewBag.SIN = EMSPSSUtilities.FormatSIN_BN(fulltimeemployee.Employee.SIN_BN, true);
            return View(fulltimeemployee);
        }
        public ViewResult FindDetails(int id)
        {
            db = new EMSEntities12();
            ContractEmployee ce = EMSPSSUtilities.GetContract(id);
            ReasonForLeaving rfl = db.ReasonForLeavings.Find(ce.ReasonForLeaving4Id);
            if (rfl != null)
            {
                ViewBag.Reason = rfl.ReasonForLeaving1;
            }

            ViewBag.BN = EMSPSSUtilities.FormatSIN_BN(ce.Employee.SIN_BN, false);
            return View(ce);
        }
        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);
        }
示例#10
0
 private List<Audit> FixList(List<Audit> al)
 {
     db = new EMSEntities12();
     for (int x = 0; x < al.Count;x++ )
     {
         if (al[x].Fieldname.Fieldname1 == "ReasonForLeavingId" || al[x].Fieldname.Fieldname1 == "ReasonForLeaving")
         {
             al[x].Fieldname.Fieldname1 = "ReasonForLeaving";
             if (al[x].OldValue != "")
             {
                 Int32 id = Int32.Parse(al[x].OldValue);
                 if (id != 0)
                 {
                     al[x].OldValue = db.ReasonForLeavings.Find(id).ReasonForLeaving1;
                 }
             }
             if (al[x].NewValue != "")
             {
                 Int32 id = Int32.Parse(al[x].NewValue);
                 if (id != 0)
                 {
                     al[x].NewValue = db.ReasonForLeavings.Find(id).ReasonForLeaving1;
                 }
             }
         }
         else if (al[x].Fieldname.Fieldname1 == "SeasonId" || al[x].Fieldname.Fieldname1 == "Season")
         {
             al[x].Fieldname.Fieldname1 = "Season";
             if (al[x].OldValue != "")
             {
                 Int32 id = Int32.Parse(al[x].OldValue);
                 if (id != 0)
                 {
                     al[x].OldValue = db.Seasons.Find(id).Season1;
                 }
             }
             if (al[x].NewValue != "")
             {
                 Int32 id = Int32.Parse(al[x].NewValue);
                 if (id != 0)
                 {
                     al[x].NewValue = db.Seasons.Find(id).Season1;
                 }
             }
         }
     }
     return al;
 }
        public ActionResult Edit(int EmployeeId, DateTime? timeCardDate)
        {
            db = new EMSEntities12();
            int CompanyId = EMSPSSUtilities.GetCompanyId(EmployeeId);
            if (timeCardDate != null)
            {

                DateTime weekOf = (DateTime)timeCardDate.Value;
                while (weekOf.DayOfWeek != DayOfWeek.Monday)
                {
                    weekOf = weekOf.AddDays(-1);
                }

                TimeCard tc = new TimeCard();
                List<TimeCard> allTCs = db.TimeCards.ToList();

                foreach (TimeCard tmp in allTCs)
                {
                    if ((tmp.EmployeeRef5Id == EmployeeId) && (tmp.EmployedWith5Id == CompanyId) && (tmp.WeekOf == weekOf))
                    {
                        return View(tmp);
                    }
                }
                // if it reaches here, the timecard was not found
                // create and add it before proceeding

                tc.EmployedWith5Id = CompanyId;
                tc.EmployeeRef5Id = EmployeeId;
                tc.Employee = db.Employees.Find(EmployeeId);
                tc.Company = db.Companies.Find(CompanyId);
                tc.WeekOf = weekOf;
                tc.Mon = null;
                tc.Tue = null;
                tc.Wed = null;
                tc.Thu = null;
                tc.Fri = null;
                tc.Sat = null;
                tc.Sun = null;

                db.TimeCards.Add(tc);
                db.SaveChanges();

                return View(tc);
            }
            return RedirectToAction("Index", "TimeCard", new { EmployeeId = EmployeeId, CompanyId = CompanyId });
        }
        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);
        }
示例#13
0
 public ActionResult SearchIndex(Nullable<DateTime> DateTime)
 {
     db = new EMSEntities12();
     List<Audit> al = db.Audits.ToList();
     if (DateTime != null)
     {
         List<Audit> returnList = new List<Audit>();
         foreach (Audit a in al)
         {
             if (a.DateTime > DateTime)
             {
                 returnList.Add(a);
             }
         }
         returnList = FixList(returnList);
         return View("Index", returnList);
     }
     al = FixList(al);
     return View("Index", al);
 }
示例#14
0
        public ActionResult Edit(int EmployeeId, DateTime? piecesDate)
        {
            db = new EMSEntities12();
            int CompanyId = EMSPSSUtilities.GetCompanyId(EmployeeId);
            if (piecesDate != null)
            {
                DateTime weekOf = piecesDate.Value;
                while (weekOf.DayOfWeek != DayOfWeek.Monday)
                {
                    weekOf = weekOf.AddDays(-1);
                }

                foreach (Piece tmp in db.Pieces)
                {
                    if ((tmp.EmployeeRef6Id == EmployeeId) && (tmp.EmployedWith6Id == CompanyId) && (tmp.WeekOf == weekOf))
                    {
                        return View(tmp);
                    }
                }
                // if it reaches here, the timecard was not found
                // create and add it before proceeding

                Piece newPiece = new Piece();
                newPiece.EmployedWith6Id = CompanyId;
                newPiece.EmployeeRef6Id = EmployeeId;
                newPiece.WeekOf = weekOf;
                newPiece.Mon = null;
                newPiece.Tue = null;
                newPiece.Wed = null;
                newPiece.Thu = null;
                newPiece.Fri = null;
                newPiece.Sat = null;
                newPiece.Sun = null;

                db.Pieces.Add(newPiece);
                db.SaveChanges();

                return View(newPiece);
            }
            return RedirectToAction("Index", "Pieces", new { EmployeeId = EmployeeId, CompanyId = CompanyId });
        }
示例#15
0
        public ActionResult Details(int EmployeeId, DateTime weekOf)
        {
            db = new EMSEntities12();
            int CompanyId = EMSPSSUtilities.GetCompanyId(EmployeeId);
            // test if weekOf is a monday, if not, go to employee's timecard index
            if (weekOf.Date.DayOfWeek != DayOfWeek.Monday)
            {
                return RedirectToAction("Index", "Pieces", new { EmployeeId = EmployeeId, CompanyId = CompanyId });
            }

            foreach (Piece tmp in db.Pieces)
            {
                if ((tmp.EmployeeRef6Id == EmployeeId) && (tmp.EmployedWith6Id == CompanyId) && (tmp.WeekOf == weekOf))
                {
                    return View(tmp);
                }
            }

            // if it reaches here, the timecard was not found return to employee's timecard index
            foreach (Employee emp in db.Employees)
            {
                if (emp.EmployeeId == EmployeeId)
                {
                    ViewBag.Name = emp.FirstName + " " + emp.LastName;
                    break;
                }
            }
            foreach (Company cmp in db.Companies)
            {
                if (cmp.CompanyId == CompanyId)
                {
                    ViewBag.Company = cmp.CompanyName;
                    break;
                }
            }
            ViewBag.EmployeeId = EmployeeId;
            ViewBag.CompanyId = CompanyId;

            return RedirectToAction("Index", "Pieces", new { EmployeeId = EmployeeId, CompanyId = CompanyId });
        }
 //
 // GET: /Company/Edit/5
 public ActionResult Edit(int id)
 {
     db = new EMSEntities12();
     Company company = db.Companies.Find(id);
     return View(company);
 }
示例#17
0
        //
        // GET: /TimeCard/
        public ActionResult Index(int EmployeeId)
        {
            db = new EMSEntities12();
            int CompanyId = EMSPSSUtilities.GetCompanyId(EmployeeId);
            List<Piece> list = new List<Piece>();
            foreach (Employee emp in db.Employees)
            {
                if (emp.EmployeeId == EmployeeId)
                {
                    ViewBag.Name = emp.FirstName + " " + emp.LastName;
                    break;
                }
            }
            foreach (Company cmp in db.Companies)
            {
                if (cmp.CompanyId == CompanyId)
                {
                    ViewBag.Company = cmp.CompanyName;
                    break;
                }
            }
            ViewBag.EmployeeId = EmployeeId;
            ViewBag.CompanyId = CompanyId;

            foreach (Piece curr in db.Pieces)
            {
                if ((curr.EmployeeRef6Id == EmployeeId) && (curr.EmployedWith6Id == CompanyId))
                {
                    list.Add(curr);
                }
            }

            return View(list);
        }
        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);
        }
示例#19
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 ActiveEmployeeReport(string CompList)
        {
            db = new EMSEntities12();
            ViewBag.Company = CompList;
            int compId = 0;
            foreach (Company mycmp in db.Companies)
            {
                if (mycmp.CompanyName == CompList)
                {
                    compId = mycmp.CompanyId;
                }
            }

            Dictionary<FullTimeEmployee, float> ftEmpList = new Dictionary<FullTimeEmployee, float>();
            Dictionary<PartTimeEmployee, float> ptEmpList = new Dictionary<PartTimeEmployee, float>();
            Dictionary<SeasonalEmployee, float> seEmpList = new Dictionary<SeasonalEmployee, float>();
            List<ContractEmployee> conEmpList = new List<ContractEmployee>();
            foreach (EmployeeType et in db.EmployeeTypes)
            {
                if (et.CompanyId == compId)
                {
                    if (et.EmployeeType1 != "Contract  ")
                    {
                        if (et.Employee.FullTimeEmployees.Count > 0)
                        {
                            FullTimeEmployee fulltimer = EMSPSSUtilities.GetFullTimer(et.EmployeeId);
                            if ((fulltimer.DateOfTermination > DateTime.Now || fulltimer.DateOfTermination == null) && fulltimer.Employee.Completed)
                            {
                                ftEmpList.Add(fulltimer, CalculateAvgHourWorked(et.Employee.EmployeeId));
                            }
                        }
                        else if (et.Employee.PartTimeEmployees.Count > 0)
                        {
                            PartTimeEmployee parttimer = EMSPSSUtilities.GetPartTimer(et.EmployeeId);
                            if ((parttimer.DateOfTermination > DateTime.Now || parttimer.DateOfTermination == null) && parttimer.Employee.Completed)
                            {
                                ptEmpList.Add(parttimer, CalculateAvgHourWorked(et.Employee.EmployeeId));
                            }
                        }
                        else if (et.Employee.SeasonalEmployees.Count > 0)
                        {

                            SeasonalEmployee sea = EMSPSSUtilities.GetSeasonal(et.EmployeeId);
                            DateTime lowRange = DateTime.Now;
                            DateTime highRange = DateTime.Now;
                            if (sea.Season.Season1 == "Winter")
                            {
                                lowRange = new DateTime(DateTime.Now.Year - 1, 12, 1);
                                highRange = new DateTime(DateTime.Now.Year, 4, 30);
                            }
                            else if (sea.Season.Season1 == "Spring")
                            {
                                lowRange = new DateTime(DateTime.Now.Year, 5, 1);
                                highRange = new DateTime(DateTime.Now.Year, 6, 30);
                            }
                            else if (sea.Season.Season1 == "Summer")
                            {
                                lowRange = new DateTime(DateTime.Now.Year, 7, 1);
                                highRange = new DateTime(DateTime.Now.Year, 8, 31);
                            }
                            else if (sea.Season.Season1 == "Fall")
                            {
                                lowRange = new DateTime(DateTime.Now.Year, 9, 1);
                                highRange = new DateTime(DateTime.Now.Year, 11, 30);
                            }
                            if (sea.SeasonYear >= lowRange && sea.SeasonYear <= highRange && sea.Employee.Completed)
                            {
                                seEmpList.Add(sea, CalculateAvgHourWorked(et.Employee.EmployeeId));
                            }
                        }
                    }
                    else
                    {
                        ContractEmployee con = EMSPSSUtilities.GetContract(et.EmployeeId);
                        if (con.ContractStopDate > DateTime.Now && con.ContractStartDate < DateTime.Now)
                        {
                            conEmpList.Add(con);
                        }
                    }
                }
            }
            ViewBag.ftlist = ftEmpList;
            ViewBag.ptlist = ptEmpList;
            ViewBag.sealist = seEmpList;
            ViewBag.conlist = conEmpList;
            return View();
        }
        public ActionResult InactiveEmployeeReport(string CompList)
        {
            db = new EMSEntities12();
            ViewBag.Company = CompList;
            int compId = 0;
            foreach (Company mycmp in db.Companies)
            {
                if (mycmp.CompanyName == CompList)
                {

                    compId = mycmp.CompanyId;
                }
            }

            List<FullTimeEmployee> ftEmpList = new List<FullTimeEmployee>();
            List<PartTimeEmployee> ptEmpList = new List<PartTimeEmployee>();
            List<SeasonalEmployee> seEmpList = new List<SeasonalEmployee>();
            List<ContractEmployee> conEmpList = new List<ContractEmployee>();
            foreach (EmployeeType et in db.EmployeeTypes)
            {
                if (et.CompanyId == compId)
                {
                    if (et.EmployeeType1 != "Contract  ")
                    {
                        if (et.Employee.FullTimeEmployees.Count > 0)
                        {
                            FullTimeEmployee fulltimer = EMSPSSUtilities.GetFullTimer(et.EmployeeId);
                            if ((fulltimer.DateOfTermination < DateTime.Now && fulltimer.DateOfTermination != null) && fulltimer.Employee.Completed)
                            {
                                if (fulltimer.ReasonForLeavingId == null)
                                {
                                    ReasonForLeaving re = new ReasonForLeaving();
                                    re.ReasonForLeaving1 = "--";
                                    fulltimer.ReasonForLeaving = re;
                                }
                                ftEmpList.Add(fulltimer);
                            }
                        }
                        else if (et.Employee.PartTimeEmployees.Count > 0)
                        {
                            PartTimeEmployee parttimer = EMSPSSUtilities.GetPartTimer(et.EmployeeId);
                            if ((parttimer.DateOfTermination < DateTime.Now && parttimer.DateOfTermination != null) && parttimer.Employee.Completed)
                            {
                                if (parttimer.ReasonForLeaving2Id == null)
                                {
                                    ReasonForLeaving re = new ReasonForLeaving();
                                    re.ReasonForLeaving1 = "--";
                                    parttimer.ReasonForLeaving = re;
                                }
                                ptEmpList.Add(parttimer);
                            }
                        }
                        else if (et.Employee.SeasonalEmployees.Count > 0)
                        {
                            SeasonalEmployee sea = EMSPSSUtilities.GetSeasonal(et.EmployeeId);
                            DateTime lowRange = DateTime.Now;
                            DateTime highRange = DateTime.Now;
                            if (sea.Season.Season1 == "Winter")
                            {
                                lowRange = new DateTime(DateTime.Now.Year - 1, 12, 1);
                                highRange = new DateTime(DateTime.Now.Year, 4, 30);
                            }
                            else if (sea.Season.Season1 == "Spring")
                            {
                                lowRange = new DateTime(DateTime.Now.Year, 5, 1);
                                highRange = new DateTime(DateTime.Now.Year, 6, 30);
                            }
                            else if (sea.Season.Season1 == "Summer")
                            {
                                lowRange = new DateTime(DateTime.Now.Year, 7, 1);
                                highRange = new DateTime(DateTime.Now.Year, 8, 31);
                            }
                            else if (sea.Season.Season1 == "Fall")
                            {
                                lowRange = new DateTime(DateTime.Now.Year, 9, 1);
                                highRange = new DateTime(DateTime.Now.Year, 11, 30);
                            }
                            if (DateTime.Now < lowRange || DateTime.Now > highRange && sea.Employee.Completed)
                            {
                                if (sea.ReasonForLeaving3Id == null)
                                {
                                    ReasonForLeaving re = new ReasonForLeaving();
                                    re.ReasonForLeaving1 = "--";
                                    sea.ReasonForLeaving = re;
                                }
                                seEmpList.Add(sea);
                            }
                        }
                    }
                    else
                    {
                        ContractEmployee con = EMSPSSUtilities.GetContract(et.EmployeeId);
                        if (con.ContractStopDate < DateTime.Now || con.ContractStartDate > DateTime.Now)
                        {
                            if (con.ReasonForLeaving4Id == null)
                            {
                                ReasonForLeaving re = new ReasonForLeaving();
                                re.ReasonForLeaving1 = "--";
                                con.ReasonForLeaving = re;
                            }
                            conEmpList.Add(con);
                        }
                    }

                }
            }
            ViewBag.ftlist = ftEmpList;
            ViewBag.ptlist = ptEmpList;
            ViewBag.sealist = seEmpList;
            ViewBag.conlist = conEmpList;
            return View();
        }
        public ActionResult Index(int EmployeeId)
        {
            db = new EMSEntities12();
            int CompanyId = EMSPSSUtilities.GetCompanyId(EmployeeId);
            List<TimeCard> tcList = new List<TimeCard>();
            foreach (Employee emp in db.Employees)
            {
                if (emp.EmployeeId == EmployeeId)
                {
                    ViewBag.Name = emp.FirstName + " " + emp.LastName;
                    break;
                }
            }
            foreach (Company cmp in db.Companies)
            {
                if (cmp.CompanyId == CompanyId)
                {
                    ViewBag.Company = cmp.CompanyName;
                    break;
                }
            }
            ViewBag.EmployeeId = EmployeeId;
            ViewBag.CompanyId = CompanyId;

            foreach (TimeCard tc in db.TimeCards)
            {
                if ((tc.EmployeeRef5Id == EmployeeId) && (tc.EmployedWith5Id == CompanyId))
                {
                    tcList.Add(tc);
                }
            }

            return View(tcList);
        }
        public ActionResult PayrollReport(string CompList)
        {
            db = new EMSEntities12();
            ViewBag.Company = CompList;
            int compId = 0;
            foreach (Company mycmp in db.Companies)
            {
                if (mycmp.CompanyName == CompList)
                {
                    compId = mycmp.CompanyId;
                }
            }

            List<FullTimeEmployee> ftEmpList = new List<FullTimeEmployee>();
            List<String> ftNotes = new List<String>();
            List<float> ftHours = new List<float>();
            List<float> ftPay = new List<float>();

            List<PartTimeEmployee> ptEmpList = new List<PartTimeEmployee>();
            List<String> ptNotes = new List<String>();
            List<float> ptHours = new List<float>();
            List<float> ptPay = new List<float>();

            List<SeasonalEmployee> seaEmpList = new List<SeasonalEmployee>();
            List<String> seaNotes = new List<String>();
            List<float> seaHours = new List<float>();
            List<float> seaPay = new List<float>();

            List<float> pieceTally = new List<float>();

            List<ContractEmployee> conEmpList = new List<ContractEmployee>();
            List<String> conNotes = new List<String>();

            foreach (EmployeeType et in db.EmployeeTypes)
            {
                if (et.CompanyId == compId)
                {
                    if (et.Employee.Active && et.Employee.Completed)
                    {

                        if (et.EmployeeType1 != "Contract  ")
                        {
                            if (et.Employee.FullTimeEmployees.Count > 0)
                            {
                                string comment = "";
                                FullTimeEmployee fulltimer = EMSPSSUtilities.GetFullTimer(et.EmployeeId);
                                if (fulltimer.Employee.Completed)
                                {
                                    if (fulltimer.DateOfTermination == null || fulltimer.DateOfTermination > DateTime.Now)
                                    {
                                        float hoursWorked = addHours(GetTimeCardEntry(fulltimer.EmployeeRefId));
                                        if (hoursWorked < 40)
                                        {
                                            comment = "Not full work week";
                                        }
                                        ftEmpList.Add(fulltimer);
                                        ftNotes.Add(comment);
                                        ftHours.Add(hoursWorked);
                                        ftPay.Add(((float)fulltimer.Salary / 52));
                                    }
                                }
                            }
                            else if (et.Employee.PartTimeEmployees.Count > 0)
                            {
                                string comment = "";
                                PartTimeEmployee parttimer = EMSPSSUtilities.GetPartTimer(et.EmployeeId);
                                if (parttimer.Employee.Completed)
                                {
                                    if (parttimer.DateOfTermination == null || parttimer.DateOfTermination > DateTime.Now)
                                    {
                                        float hoursWorked = addHours(GetTimeCardEntry(parttimer.EmployeeRef2Id));
                                        float pay = 0;
                                        if (hoursWorked > 40)
                                        {
                                            comment = (hoursWorked - 40).ToString() + " hours of OT";
                                            float rate = (float)parttimer.HourlyRate;
                                            pay = (40 * rate) + ((hoursWorked - 40) * (rate * 1.5f));
                                        }
                                        else
                                        {
                                            pay = ((float)parttimer.HourlyRate * hoursWorked);
                                        }
                                        ptEmpList.Add(parttimer);
                                        ptNotes.Add(comment);
                                        ptHours.Add(hoursWorked);
                                        ptPay.Add(pay);
                                    }
                                }

                            }
                            else if (et.Employee.SeasonalEmployees.Count > 0)
                            {
                                SeasonalEmployee sea = EMSPSSUtilities.GetSeasonal(et.EmployeeId);
                                if (sea.Employee.Completed)
                                {
                                    if (sea.SeasonYear.Year == DateTime.Now.Year)
                                    {
                                        string comment = "";
                                        float pay = 0;
                                        float hoursWorked = addHours(GetTimeCardEntry(sea.EmployeeRef3Id));
                                        float pieces = TallyPieces(GetPiecesEntry(sea.EmployeeRef3Id));
                                        pieceTally.Add(pieces);
                                        pay = pieces * (float)sea.PiecePay;
                                        if (hoursWorked > 40)
                                        {
                                            pay += 150;
                                        }
                                        seaEmpList.Add(sea);
                                        seaNotes.Add(comment);
                                        seaHours.Add(hoursWorked);
                                        seaPay.Add(pay);
                                    }
                                }
                            }
                        }
                        else
                        {
                            ContractEmployee con = EMSPSSUtilities.GetContract(et.EmployeeId);
                            TimeSpan span = con.ContractStopDate - DateTime.Now;
                            TimeSpan span2 = con.ContractStopDate - con.ContractStartDate;
                            if (span.TotalDays > 0)
                            {
                                conNotes.Add(span.TotalDays.ToString("n2") + " days remaining.");
                                con.FixedContractAmount = (con.FixedContractAmount * 7) / span2.TotalDays;
                                conEmpList.Add(con);
                            }
                        }
                    }
                }
            }
            if (pieceTally.Count > 0)
            {
                int highest = DecideMostProductive(pieceTally);
                seaNotes[highest] = "Most Productive";
            }

            ViewBag.ftlist = ftEmpList;
            ViewBag.fthours = ftHours;
            ViewBag.ftpay = ftPay;
            ViewBag.ftnotes = ftNotes;

            ViewBag.ptlist = ptEmpList;
            ViewBag.pthours = ptHours;
            ViewBag.ptpay = ptPay;
            ViewBag.ptnotes = ptNotes;

            ViewBag.sealist = seaEmpList;
            ViewBag.seahours = seaHours;
            ViewBag.seapay = seaPay;
            ViewBag.seanotes = seaNotes;

            ViewBag.conlist = conEmpList;
            ViewBag.connotes = conNotes;

            return View();
        }
示例#24
0
        public ActionResult SearchIndex(string FirstName2, string LastName2, string SINBN2)
        {
            db = new EMSEntities12();
            EMSPSSUtilities.UpdateEmployeeStatuses();
            var GenreLst = new List<string>();

            var GenreQry = from d in db.Employees
                           orderby d.FirstName
                           select d.FirstName;

            GenreLst.AddRange(GenreQry.Distinct());

            var employeelst = from m in db.Employees
                              select m;

            if (!String.IsNullOrEmpty(FirstName2))
            {
                employeelst = employeelst.Where(s => s.FirstName.Contains(FirstName2));
            }

            if (!String.IsNullOrEmpty(LastName2))
            {
                employeelst = (employeelst.Where(x => x.LastName.Contains(LastName2)));
            }

            if (!String.IsNullOrEmpty(SINBN2))
            {
                employeelst = (employeelst.Where(x => x.SIN_BN.Contains(SINBN2)));
            }
            List<Employee> le = employeelst.ToList();
            //if user is not an admin remove contact employees
            if (!User.IsInRole("Admin"))
            {
                for (int c = 0; c < le.Count; c++)
                {
                    if (le[c].ContractEmployees.Count > 0 || !le[c].Active)
                    {
                        le.Remove(le[c]);
                        c--;
                    }
                }
            }

            return View(le);
        }
        public ActionResult ReportsHome(string ReportType, string CompList)
        {
            db = new EMSEntities12();
            EMSPSSUtilities.UpdateEmployeeStatuses();
            if (ReportType == "Seniority")
            {
                return RedirectToAction("SeniorityReport", new { CompList = CompList });
            }
            else if (ReportType == "Hours Worked")
            {
                return RedirectToAction("HoursWorkedReport", new { CompList = CompList });
            }
            else if (ReportType == "Inactive Employee Report")
            {
                return RedirectToAction("InactiveEmployeeReport", new { CompList = CompList });
            }
            else if (ReportType == "Payroll Report")
            {
                return RedirectToAction("PayrollReport", new { CompList = CompList });
            }
            else
            {
                return RedirectToAction("ActiveEmployeeReport", new { CompList = CompList });
            }

            //return View();
        }
        // GET: /Reports/
        public ActionResult SeniorityReport(string CompList)
        {
            db = new EMSEntities12();
            Company MyComp = new Company();
            foreach (Company mycmp in db.Companies)
            {
                if (mycmp.CompanyName == CompList)
                {
                    MyComp.CompanyId = mycmp.CompanyId;
                }
            }
            //Dictionary<EmployeeType, String> emplist = new Dictionary<EmployeeType,String>();
            Dictionary<EmployeeType, String> emplist2 = new Dictionary<EmployeeType, String>();
            List<EmployeeType> emplist = new List<EmployeeType>();
            List<String> strlst = new List<String>();
            foreach (EmployeeType emptype in db.EmployeeTypes)
            {
                if (emptype.CompanyId == MyComp.CompanyId && emptype.Employee.Completed && emptype.Employee.Active)
                {
                    emplist.Add(emptype);
                    ViewBag.CompanyName = emptype.Company.CompanyName;
                    // strlst.Add(ParseDays(emptype.DateofHire));

                }

            }

            foreach (EmployeeType emptypes in emplist.OrderBy(x => x.DateofHire))
            {
                emplist2.Add(emptypes, ParseDays(emptypes.DateofHire));
            }

            //ViewBag.EmplList = strlst;
            return View(emplist2);
        }
        public ActionResult SearchIndex(string companyName)
        {
            db = new EMSEntities12();
            var GenreLst = new List<string>();

            var GenreQry = from d in db.Companies
                           orderby d.CompanyName
                           select d.CompanyName;

            GenreLst.AddRange(GenreQry.Distinct());

            var companylst = from m in db.Companies
                              select m;

            if (!String.IsNullOrEmpty(companyName))
            {
                companylst = companylst.Where(s => s.CompanyName.Contains(companyName));
            }
            return View(companylst);
        }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                //Roles.CreateRole("Admin");
                //Roles.AddUserToRole("Kyle", "Admin");
                EMSEntities12 db = new EMSEntities12();
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipCreateStatus.Success;
                User u = new User();
                u.FirstName = model.FirstName;
                u.LastName = model.LastName;
                u.UserName = model.UserName;
                List<User> l = db.Users.ToList();
                foreach (User user in l)
                {
                    if (user.UserName.ToLower() == model.UserName.ToLower())
                    {
                        createStatus = MembershipCreateStatus.DuplicateUserName;
                    }
                }
                if (createStatus == MembershipCreateStatus.Success)
                {

                    db.Users.Add(u);
                    db.SaveChanges();
                    Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
                    if (model.IsAdmin == "True")
                    {
                        Roles.AddUserToRole(model.UserName, "Admin");
                    }
                }
                if (createStatus == MembershipCreateStatus.Success)
                {

                    ViewBag.SuccessMessage = "User \"" + model.UserName + "\" was successfully created.";
                    //FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return View();
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
示例#29
0
        public ActionResult Index()
        {
            db = new EMSEntities12();
            if (User.IsInRole("Admin")) // find employees that need completion
            {
                Employee employee = new Employee();
                List<Employee> emplist = new List<Employee>();

                foreach (FullTimeEmployee FtCompleted in db.FullTimeEmployees)
                {
                    if (!FtCompleted.Employee.Completed)
                    {
                        emplist.Add(FtCompleted.Employee);

                    }
                }
                foreach (PartTimeEmployee PtCompleted in db.PartTimeEmployees)
                {
                    if (!PtCompleted.Employee.Completed)
                    {
                        emplist.Add(PtCompleted.Employee);

                    }
                }
                foreach (SeasonalEmployee SesonCompleted in db.SeasonalEmployees)
                {
                    if (!SesonCompleted.Employee.Completed)
                    {
                        emplist.Add(SesonCompleted.Employee);

                    }
                }

                return View(emplist);
            }
            else // find employees that need time card entries for this week
            {
                List<Employee> emplist = new List<Employee>();
                List<TimeCard> tcl = db.TimeCards.ToList();
                List<Piece> pl = db.Pieces.ToList();
                DateTime weekOf = DateTime.Now;
                while (weekOf.DayOfWeek != DayOfWeek.Monday)
                {
                    weekOf = weekOf.AddDays(-1);
                }
                Boolean Found = false;
                foreach (FullTimeEmployee ft in db.FullTimeEmployees)
                {
                    if (ft.Employee.Active && ft.Employee.Completed)
                    {
                        foreach (TimeCard tc in tcl)
                        {
                            if (tc.EmployeeRef5Id == ft.EmployeeRefId && tc.WeekOf.Day == weekOf.Day && tc.WeekOf.Month == weekOf.Month && tc.WeekOf.Year == weekOf.Year)
                            {
                                Found = true;
                                if (tc.Mon == null || tc.Sat == null || tc.Sun == null || tc.Thu == null || tc.Tue == null || tc.Wed == null || tc.Fri == null)
                                {
                                    emplist.Add(ft.Employee);
                                }
                            }
                        }
                        if (!Found)
                        {
                            emplist.Add(ft.Employee);

                        }
                        Found = false;
                    }
                }
                foreach (PartTimeEmployee pt in db.PartTimeEmployees)
                {
                    if (pt.Employee.Active && pt.Employee.Completed)
                    {
                        foreach (TimeCard tc in tcl)
                        {
                            if (tc.EmployeeRef5Id == pt.EmployeeRef2Id && tc.WeekOf.Day == weekOf.Day && tc.WeekOf.Month == weekOf.Month && tc.WeekOf.Year == weekOf.Year)
                            {
                                Found = true;
                                if (tc.Mon == null || tc.Sat == null || tc.Sun == null || tc.Thu == null || tc.Tue == null || tc.Wed == null || tc.Fri == null)
                                {
                                    emplist.Add(pt.Employee);
                                }
                            }
                        }
                        if (!Found)
                        {
                            emplist.Add(pt.Employee);

                        }
                        Found = false;
                    }
                }
                foreach (SeasonalEmployee se in db.SeasonalEmployees)
                {
                    if (se.Employee.Active && se.Employee.Completed)
                    {
                        foreach (TimeCard tc in tcl)
                        {
                            if (tc.EmployeeRef5Id == se.EmployeeRef3Id && tc.WeekOf.Day == weekOf.Day && tc.WeekOf.Month == weekOf.Month && tc.WeekOf.Year == weekOf.Year)
                            {
                                Found = true;
                                if (tc.Mon == null || tc.Sat == null || tc.Sun == null || tc.Thu == null || tc.Tue == null || tc.Wed == null || tc.Fri == null)
                                {
                                    emplist.Add(se.Employee);
                                }
                            }
                        }
                        if (!Found)
                        {
                            emplist.Add(se.Employee);

                        }
                        Found = false;
                    }
                }

                return View(emplist);
            }
        }
 public ActionResult Home(string compList)
 {
     db = new EMSEntities12();
     if (compList == "")
     {
         List<Employee> le = db.Employees.ToList();
         for (int c = 0; c < le.Count; c++)
         {
             if (le[c].ContractEmployees.Count > 0 || !le[c].Active || !le[c].Completed || le[c].ContractEmployees.Count > 1)
             {
                 le.Remove(le[c]);
                 c--;
             }
         }
         ViewBag.empList = le;
     }
     else
     {
         List<Employee> le = new List<Employee>();
         List<EmployeeType> let = db.EmployeeTypes.ToList();
         for (int c = 0; c < let.Count; c++)
         {
             if (let[c].Company.CompanyName == compList && let[c].Employee.Active && let[c].Employee.Completed && let[c].Employee.ContractEmployees.Count < 1)
             {
                 le.Add(let[c].Employee);
             }
         }
         ViewBag.empList = le;
     }
     ViewBag.compList = EMSPSSUtilities.GetCompList();
     return View();
 }