public ActionResult OrderListAddSave(int publishid, int bookid, string time, int num) { try { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.order order = new Models.order(); order.publish_id = publishid; order.book_id = bookid; order.time = time; order.num = num; db.order.Add(order); db.SaveChanges(); return(Content("添加成功")); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { var msg = string.Empty; var errors = (from u in ex.EntityValidationErrors select u.ValidationErrors).ToList(); foreach (var item in errors) { msg += item.FirstOrDefault().ErrorMessage; } return(Content(msg)); } }
public ActionResult BookListEditSave(int id, string publishid, string name, string type, string price, string author) { if (name == "" || type == "") { return(Content("输入格式不对请重新输入")); } else { try { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.book b = db.book.Find(id); b.name = name; b.price = Convert.ToInt32(price); b.author = author; b.type = type; db.SaveChanges(); return(Content("编辑成功")); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { var msg = string.Empty; var errors = (from u in ex.EntityValidationErrors select u.ValidationErrors).ToList(); foreach (var item in errors) { msg += item.FirstOrDefault().ErrorMessage; } return(Content(msg)); } } }
public ActionResult OrderListDel(int id) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.order o = db.order.Find(id); db.order.Attach(o); db.order.Remove(o); db.SaveChanges(); return(RedirectToAction("orderlist")); }
public ActionResult EditSave(int id, string name, string phone, string work) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.person p = db.person.Find(id); p.work = work; p.name = name; p.phone = phone; db.SaveChanges(); return(RedirectToAction("index")); }
public ActionResult ReturnBookSave(int id, string returntime) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.bring bring = db.bring.Find(id); bring.isreturn = 1; bring.returntime = returntime; bring.bookstatus.bringnum++; db.SaveChanges(); return(RedirectToAction("BookStatusList")); }
public ActionResult AddSave(string name, string phone, string work) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.person people = new Models.person(); people.name = name; people.phone = phone; people.work = work; db.person.Add(people); db.SaveChanges(); return(RedirectToAction("index")); }
public ActionResult Del(int Id) { //删除需判断与之关联的的实体是否存在 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.person p = db.person.Find(Id); db.person.Attach(p); db.person.Remove(p); db.SaveChanges(); return(RedirectToAction("index")); }
/***出版社的图书删除外键***/ public ActionResult BookListDel(int id) { //判断有是否有与其关联的外键 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.book b = db.book.Find(id); b.isdeal = 1; //db.book.Attach(b); //db.book.Remove(b); db.SaveChanges(); return(RedirectToAction("booklist", new { publishid = b.pulish_id })); }
public ActionResult PublishListEditSave(int id, string name, string phone, string location, string email) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.publish p = db.publish.Find(id); p.name = name; p.phone = phone; p.location = location; p.email = email; db.SaveChanges(); return(RedirectToAction("publishlist")); }
public ActionResult PublishListAddSave(string name, string phone, string location, string email) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.publish p = new Models.publish(); p.name = name; p.phone = phone; p.location = location; p.email = email; db.publish.Add(p); db.SaveChanges(); List <电商.Areas.Admin.Models.publish> list = db.publish.Where(m => m.name == name).ToList(); return(Content("添加成功")); }
public ActionResult PublishListDel(int id) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.publish p = db.publish.Find(id); List <电商.Areas.Admin.Models.book> booklist = db.book.Where(m => m.pulish_id == id).ToList(); if (booklist.Count >= 1) { foreach (电商.Areas.Admin.Models.book item in booklist) { item.isdeal = 1; } } p.isdeal = 1; //db.publish.Attach(p); //db.publish.Remove(p); db.SaveChanges(); return(RedirectToAction("publishlist")); }
public ActionResult BringListAddSave(int bookid, string time, string user) { int userId = Convert.ToInt32(user); 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.bookstatus bookstaus = db.bookstatus.Find(bookid); if (bookstaus.num - bookstaus.bringnum <= 0) { return(Content("余量不足")); } List <电商.Areas.Admin.Models.person> list = db.person.Where(m => m.id == userId).ToList(); if (list.Count >= 1) { try { 电商.Areas.Admin.Models.person this_people = list[0]; 电商.Areas.Admin.Models.bring b = new Models.bring(); b.book_id = bookid; b.person_id = this_people.id; b.bringtime = time; bookstaus.num--; db.bring.Add(b); db.SaveChanges(); return(Content("借阅成功")); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { var msg = string.Empty; var errors = (from u in ex.EntityValidationErrors select u.ValidationErrors).ToList(); foreach (var item in errors) { msg += item.FirstOrDefault().ErrorMessage; } return(Content(msg)); } } else { return(Content("用户不存在")); } }
public ActionResult AddtoLibrarySave(int orderId, string location, string finishtime) { 电商.Areas.Admin.Models.Entities4 db = new Models.Entities4(); 电商.Areas.Admin.Models.order order = db.order.Find(orderId); order.isFinish = 1; order.endtime = finishtime; List <电商.Areas.Admin.Models.bookstatus> bs = db.bookstatus.Where(m => m.book_id == order.book_id && m.location == location).ToList(); if (bs.Count >= 1) { 电商.Areas.Admin.Models.bookstatus b = bs[0]; b.num += order.num; } else { 电商.Areas.Admin.Models.bookstatus b = new Models.bookstatus(); b.num = order.num; b.location = location; b.book_id = order.book_id; db.bookstatus.Add(b); } db.SaveChanges(); return(RedirectToAction("Index")); }