// GET: WoBuilds/Edit/5 public ActionResult Edit(int?id) { ViewBag.ReturnUrl = Request.UrlReferrer; var wobuilds = db.WoBuilds.SingleOrDefault(c => c.WoBuildId == id); var contractors = db.Contractors.ToList(); var viewModel = new WoBuildViewModel() { WoBuild = wobuilds, Contractors = contractors }; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WoBuild woBuild = db.WoBuilds.Find(id); if (woBuild == null) { return(HttpNotFound()); } return(View("Edit", viewModel)); //return View(woBuild); }
public ActionResult DeleteConfirmed(int id) { WoBuild woBuild = db.WoBuilds.Find(id); db.WoBuilds.Remove(woBuild); db.SaveChanges(); return(RedirectToAction("Index")); }
//public ActionResult Create([Bind(Include = "WoBuildId,WoEnterDateTime,WoNo,CustomerPn,Qty,Notes")] WoBuild woBuild) public ActionResult Create(WoBuild woBuild, string returnUrl) { if (ModelState.IsValid) { db.WoBuilds.Add(woBuild); db.SaveChanges(); return(Redirect(returnUrl)); //return RedirectToAction("Index"); } return(View()); //return View(woBuild); }
//public ActionResult Edit([Bind(Include = "WoBuildId,WoEnterDateTime,WoNo,CustomerPn,Qty,Notes")] WoBuild woBuild) public ActionResult Edit(WoBuild woBuild, string returnUrl) { if (ModelState.IsValid) { db.Entry(woBuild).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); return(Redirect(returnUrl)); } //return View(woBuild); return(View()); }
// GET: WoBuilds/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WoBuild woBuild = db.WoBuilds.Find(id); if (woBuild == null) { return(HttpNotFound()); } return(View(woBuild)); }
// GET: WoBuilds/Delete/5 public ActionResult Delete(int?id) { ViewBag.ReturnUrl = Request.UrlReferrer; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } WoBuild woBuild = db.WoBuilds.Find(id); if (woBuild == null) { return(HttpNotFound()); } return(View(woBuild)); }
public ActionResult ProcessBuild(DateTime builddate, int buildqty, string Pn, string WoNo, byte contractor) { //Initial boms to hold all current parts in bom table List <BomLevel1> boms = new List <BomLevel1>(); //put all parts in current bom table into an in memory list boms = db.BomLevel1s.ToList(); List <BomLevel1> selectboms = new List <BomLevel1>(); BomLevel1 dpn = new BomLevel1(); //create a list of parts in bom foreach (BomLevel1 a in boms) { if (a.UnitNo == Pn) { dpn.BomNo = a.BomNo; dpn.UnitNo = a.UnitNo; dpn.DetailPn = a.DetailPn; dpn.Description = a.Description; dpn.PurchaseMake = a.PurchaseMake; dpn.PartType = a.PartType; dpn.PartTypeDetail = a.PartTypeDetail; dpn.QtyPer = a.QtyPer; selectboms.Add(dpn); } } //Initialize build table to add built part into WoBuilds WoBuild build = new WoBuild(); //Initialize build table to subtract out level 1 parts in WoBuilds WoBuild takeout = new WoBuild(); //build the part and add it to WoBuilds if (boms.Any(i => i.UnitNo == Pn)) { //add the built part to be assembled //build.WoEnterDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")); build.WoEnterDateTime = builddate; build.ContractorId = contractor; build.WoNo = WoNo; build.CustomerPn = Pn; build.Qty = buildqty; build.Notes = null; db.WoBuilds.Add(build); db.SaveChanges(); //take out parts that were used to build assembly foreach (BomLevel1 b in boms) { if (b.UnitNo == Pn) { //takeout.WoEnterDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")); takeout.WoEnterDateTime = builddate; takeout.ContractorId = contractor; takeout.WoNo = WoNo; takeout.CustomerPn = b.DetailPn; takeout.Qty = (b.QtyPer * -buildqty); takeout.Notes = null; db.WoBuilds.Add(takeout); db.SaveChanges(); } } /* * //Initialize build table to subtract out level 2 (or other sublevel) parts in WoBuilds * WoBuild takeout1 = new WoBuild(); * * //take out sub part numbers * foreach (BomLevel1 c in boms) * { * * foreach (BomLevel1 d in selectboms) * { * * if (c.UnitNo == d.DetailPn) * { * //takeout1.WoEnterDateTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")); * takeout1.WoEnterDateTime = builddate; * takeout1.ContractorId = contractor; * takeout1.WoNo = WoNo; * takeout1.CustomerPn = c.DetailPn; * takeout1.Qty = (c.QtyPer * -buildqty); * takeout1.Notes = null; * * db.WoBuilds.Add(takeout1); * db.SaveChanges(); * } * * } * }*/ return(null); } else { ViewBag.Message = "BOM does not exist. Please create."; return(null); } }