예제 #1
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 });
        }
예제 #2
0
 private float TallyPieces(Piece p)
 {
     float pieces = 0;
     if (p.Mon != null)
     {
         pieces += (float)p.Mon;
     }
     if (p.Tue != null)
     {
         pieces += (float)p.Tue;
     }
     if (p.Wed != null)
     {
         pieces += (float)p.Wed;
     }
     if (p.Thu != null)
     {
         pieces += (float)p.Thu;
     }
     if (p.Fri != null)
     {
         pieces += (float)p.Fri;
     }
     if (p.Sat != null)
     {
         pieces += (float)p.Sat;
     }
     if (p.Sun != null)
     {
         pieces += (float)p.Sun;
     }
     return pieces;
 }
예제 #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);
 }
예제 #4
0
        private Piece GetPiecesEntry(int employeeId)
        {
            Piece pc = new Piece();
            DateTime weekOf = DateTime.Now.Date;
            while (weekOf.DayOfWeek != DayOfWeek.Monday)
            {
                weekOf = weekOf.AddDays(-1);
            }

            List<Piece> allPCs = db.Pieces.ToList();
            foreach (Piece tmp in allPCs)
            {
                if ((tmp.EmployeeRef6Id == employeeId) && (tmp.WeekOf == weekOf))
                {
                    pc = tmp;
                }
            }

            return pc;
        }