public ActionResult Edit([Bind(Include = "GOODSID,GOODSNM,PRICE")] GOODSTBL gOODSTBL) { if (ModelState.IsValid) { Models.STOCKTBL sTOCKTBL = new STOCKTBL(); db.Entry(gOODSTBL).State = EntityState.Modified; sTOCKTBL.DEALID = gOODSTBL.GOODSID; sTOCKTBL.GOODSID = gOODSTBL.GOODSID; sTOCKTBL.GOODSNM = gOODSTBL.GOODSNM; sTOCKTBL.PRICE = gOODSTBL.PRICE; sTOCKTBL.STOCK = (from goods in db.STOCKTBL where goods.DEALID == gOODSTBL.GOODSID select goods.STOCK).Single(); sTOCKTBL.TPRICE = sTOCKTBL.PRICE * sTOCKTBL.STOCK; sTOCKTBL.LASTUDT = DateTime.Now; db.Entry(sTOCKTBL).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gOODSTBL)); }
public ActionResult DeleteConfirmed(string id) { GOODSTBL gOODSTBL = db.GOODSTBL.Find(id); STOCKTBL sTOCKTBL = db.STOCKTBL.Find(id); db.GOODSTBL.Remove(gOODSTBL); db.STOCKTBL.Remove(sTOCKTBL); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "GOODSID,GOODSNM,PRICE")] GOODSTBL gOODSTBL) { if (ModelState.IsValid) { Models.STOCKTBL sTOCKTBL = new STOCKTBL(); db.GOODSTBL.Attach(gOODSTBL); db.Entry(gOODSTBL).Property(m => m.GOODSID).IsModified = false; db.Entry(gOODSTBL).Property(m => m.GOODSNM).IsModified = true; db.Entry(gOODSTBL).Property(m => m.PRICE).IsModified = true; sTOCKTBL.PRICE = gOODSTBL.PRICE; sTOCKTBL.STOCK = (from goods in db.STOCKTBL where goods.DEALID == gOODSTBL.GOODSID select goods.STOCK).Single(); sTOCKTBL.TPRICE = sTOCKTBL.PRICE * sTOCKTBL.STOCK; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gOODSTBL)); }
public ActionResult Create([Bind(Include = "GOODSID,GOODSNM,PRICE")] GOODSTBL gOODSTBL) { if (ModelState.IsValid) { Models.STOCKTBL sTOCKTBL = new STOCKTBL(); int initializer = 0; db.GOODSTBL.Add(gOODSTBL); db.STOCKTBL.Add(sTOCKTBL); sTOCKTBL.DEALID = gOODSTBL.GOODSID; sTOCKTBL.GOODSID = gOODSTBL.GOODSID; sTOCKTBL.GOODSNM = gOODSTBL.GOODSNM; sTOCKTBL.PRICE = gOODSTBL.PRICE; sTOCKTBL.STOCK = initializer; sTOCKTBL.TPRICE = initializer; sTOCKTBL.LASTUDT = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gOODSTBL)); }