public ActionResult SysLogin(User1 model) //用户登录主页 { var state = false; if (ModelState.IsValid) { var db = new AirDataBase(); db.Database.CreateIfNotExists(); var lst = db.User.AsQueryable(); lst = lst.Where(o => o.UserName.Contains(model.UserName)); foreach (var a in lst) { if (a.UserName == model.UserName && a.UserPassword == model.UserPassword) { state = true; } else { state = false; } } } if (state == true) { return(RedirectToAction("Index", "Home")); } else { return(Redirect("SysIndex")); } }
public ActionResult Edit(int id) { var db = new AirDataBase(); var article = db.Goods.First(o => o.GoodsId == id); ViewData.Model = article; return(View()); }
public ActionResult Delete(int id) { var db = new AirDataBase(); var article = db.Goods.First(o => o.GoodsId == id); db.Goods.Remove(article); db.SaveChanges(); return(RedirectToAction("GIndex")); }
public ActionResult EditSave(int id, string name, string buyprice, string sellprice, long number) { var db = new AirDataBase(); var article = db.Goods.First(o => o.GoodsId == id); article.GoodsName = name; article.GoodsBuyPrice = buyprice; article.GoodsSellPrice = sellprice; article.GoodsNumber = number; db.SaveChanges(); return(RedirectToAction("GIndex")); }
// GET: Goods //库存管理 public ActionResult GIndex(string a) { var db = new AirDataBase(); db.Database.CreateIfNotExists(); var list = db.Goods.AsQueryable(); if (!string.IsNullOrWhiteSpace(a)) { list = list.Where(o => o.GoodsName.Contains(a)); } ViewBag.Goods = list.OrderByDescending(o => o.GoodsId).ToList(); ViewBag.a = a; return(View()); }
public ActionResult SysAdminRegisterSave(User1 model) //用户注册保存 { if (ModelState.IsValid) { var db = new AirDataBase(); db.Database.CreateIfNotExists(); var sysAdminRegister = new User1(); sysAdminRegister.UserName = model.UserName; sysAdminRegister.UserPassword = model.UserPassword; db.User.Add(sysAdminRegister); db.SaveChanges(); } return(Redirect("SysIndex")); }
public ActionResult SellsSellSave(Sell model)//商品销售保存 { if (ModelState.IsValid) { var db = new AirDataBase(); db.Database.CreateIfNotExists(); var sellssell = new Sell(); sellssell.SellsName = model.SellsName; sellssell.SellsSellPrice = model.SellsSellPrice; sellssell.SellsNumber = model.SellsNumber; sellssell.SellsSellDate = DateTime.Now; db.Sells.Add(sellssell); db.SaveChanges(); } return(Redirect("SellsSell")); }
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")); }