public ActionResult Create([Bind(Include = "GOODSID,STOCK")] STOCKTBL sTOCKTBL) { if (ModelState.IsValid) { db.STOCKTBL.Add(sTOCKTBL); sTOCKTBL.DEALID = (from goods in db.GOODSTBL where goods.GOODSID == sTOCKTBL.GOODSID select goods.GOODSID).Single(); sTOCKTBL.GOODSNM = (from goods in db.GOODSTBL where goods.GOODSID == sTOCKTBL.GOODSID select goods.GOODSNM).Single(); sTOCKTBL.PRICE = (from goods in db.GOODSTBL where goods.GOODSID == sTOCKTBL.GOODSID select goods.PRICE).Single(); sTOCKTBL.TPRICE = sTOCKTBL.PRICE * sTOCKTBL.STOCK; sTOCKTBL.LASTUDT = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sTOCKTBL)); }
public ActionResult DeleteConfirmed(string id) { STOCKTBL sTOCKTBL = db.STOCKTBL.Find(id); db.STOCKTBL.Remove(sTOCKTBL); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: STOCKTBLs/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } STOCKTBL sTOCKTBL = db.STOCKTBL.Find(id); if (sTOCKTBL == null) { return(HttpNotFound()); } return(View(sTOCKTBL)); }