Ejemplo n.º 1
0
 public estimateitems PartToItem(parts part,int qty,int id)
 {
     estimate currEstimate = _DAOFactory.EstimateDAO.getById(id);
     estimateitems newItem = new estimateitems();
     newItem.estid = id;
     newItem.partnumber = part.partnumber;
     newItem.description = part.description;
     newItem.partcost = part.cost;
     newItem.unittype = part.unittype;
     switch (part.labortype)
     {
         case "Body":
             newItem.laborcost = currEstimate.bodycost;
             break;
         case "Paint":
             newItem.laborcost = currEstimate.paintcost;
             break;
         case "Frame":
             newItem.laborcost = currEstimate.framecost;
             break;
         default:
             newItem.laborcost = 100.00;
             break;
     }
     newItem.labor = part.labor;
     if (qty == 0)
     {
         newItem.totallabor = newItem.labor;
         newItem.laborprice = newItem.totallabor * newItem.laborcost;
     }
     else
     {
         newItem.totallabor = newItem.labor * qty;
         newItem.laborprice = newItem.totallabor * newItem.laborcost;
     }
     newItem.partprice = newItem.partcost * qty;
     newItem.extprice = newItem.partprice + newItem.laborprice;
     newItem.qty = qty;
     return newItem;
 }
Ejemplo n.º 2
0
 public ActionResult PartDetail(int id, FormCollection collection, parts partDetail)
 {
     string valid = isValid(id);
     if (valid == null)
     {
         return RedirectToAction("Home", "Account");
     }
     partDetail = _DAOFactory.PartsDAO.getByPartNum(partDetail.partnumber);
     int qty;
     if (int.TryParse(collection["Quantity"], out qty))
     {
         var item = PartToItem(partDetail, qty,id);
         item.estid = id;
         item.job = _DAOFactory.EstimateItemsDAO.getNewJob(id);
         _DAOFactory.EstimateItemsDAO.create(item);
     }
     else
     {
         ModelState.AddModelError("Error", "Please enter a valid quantity!");
         if (_DAOFactory.EstimateItemsDAO.PartNumberExists(partDetail.partnumber))
         {
             ViewBag.PartExists = true;
         }
         else
         {
             ViewBag.PartExists = false;
         }
         return View(partDetail);
     }
     ViewBag.AddedPart = "Successfully Added Part";
     ViewBag.PartExists = true;
     return View(partDetail);
 }