public ActionResult GoodsBuySave(Goods1 model)//商品采购保存 { if (ModelState.IsValid) { var article = new Goods1(); article.GoodsName = model.GoodsName; article.GoodsBuyPrice = model.GoodsBuyPrice; article.GoodsSellPrice = model.GoodsSellPrice; article.GoodsNumber = model.GoodsNumber; article.GoodsBuyDate = DateTime.Now; var db = new AirDataBase(); db.Goods.Add(article); db.SaveChanges(); } return(Redirect("GIndex")); }
//商品出售 public ActionResult SellSave(Goods1 model) { if (ModelState.IsValid) { var db = new AirDataBase(); db.Database.CreateIfNotExists(); var lst = db.Goods.AsQueryable(); lst = lst.Where(o => o.GoodsName.Contains(model.GoodsName)); foreach (var a in lst) { if (a.GoodsName == model.GoodsName) { a.GoodsNumber = a.GoodsNumber - model.GoodsNumber; } } } // return RedirectToAction("Index", "Home"); return(Redirect("GIndex")); }