public ActionResult editBook(int Id, string CourseName, string bookName, string bookId, string Author, decimal Price, string Publisher, int Edition) //修改订书信息 { T_TB_Choose item = db.T_TB_Choose.Find(Id); T_TB_TeachingTask item2 = db.T_TB_TeachingTask.Find(item.TeachingTaskId); T_TB_Books item3 = db.T_TB_Books.Find(bookId); item2.CourseName = CourseName; item3.Id = bookId; item3.Name = bookName; item3.Author = Author; item3.Price = Price; item3.Publisher = Publisher; item3.Edition = Edition; db.SaveChanges(); return(RedirectToAction("BookMessage")); }
public ActionResult Add(int cId, string bookName, string bookId, string bookAuthor, string Price, string Publisher, int Edition, string Reason, int bookCheck = 0) { //确定书籍书否存在,不存在则添加 T_TB_Books book = db.T_TB_Books.Find(bookId); if (bookId != null && book == null) { book = new T_TB_Books(); book.Id = bookId; book.Name = bookName; book.Author = bookAuthor; book.Price = Convert.ToDecimal(Price); book.Publisher = Publisher; book.Edition = Edition; db.T_TB_Books.Add(book); } //向教材选定表添加 T_TB_Choose choose = new T_TB_Choose(); choose.BookId = bookId; choose.TeachingTaskId = cId; choose.Reason = Reason; choose.State = 2; db.T_TB_Choose.Add(choose); //修改教学任务状态为已经填写 T_TB_TeachingTask task = db.T_TB_TeachingTask.Find(cId); task.State = 4; //添加老师预定书 if (bookCheck == 1) { T_TB_TeaYuding temp = new T_TB_TeaYuding(); temp.TeaId = (string)Session["Id"]; temp.BookId = bookId; temp.TaskId = cId; db.T_TB_TeaYuding.Add(temp); } db.SaveChanges(); return(RedirectToAction("GetLIst")); }