예제 #1
0
        public ActionResult Edit(String id)
        {
            if (Session["person"] == null || (int)Session["type"] != 5)
            {
                return(Redirect("/TBsys/Login/Index"));
            }

            var query5 = db.T_TB_StoreTable;

            ViewBag.lst5 = query5.ToList();

            myTBsys.Models.T_TB_Books item = db.T_TB_Books.Find(id);
            //ViewBag.BooksId = new SelectList(db.T_Shop_ProductCategory, "Id", "Name", item.T_Shop_ProductCategory.Id);
            ViewBag.item = item;
            return(View());
        }
예제 #2
0
        //编辑保存
        public ActionResult EditSave(Models.T_TB_Books book, /*int State*/ string CState)
        {
            myTBsys.Models.T_TB_Books item = db.T_TB_Books.Find(book.Id);

            int State = 0;

            if (CState == "失败")
            {
                State = 0;
            }
            if (CState == "成功")
            {
                State = 4;
            }
            if (CState == "初始")
            {
                State = 2;
            }

            //修改Stortable中书状态为无库存
            var query5 = db.T_TB_StoreTable;
            List <myTBsys.Models.T_TB_StoreTable> lst5 = query5.ToList();

            for (int i = 0; i < lst5.Count; i++)
            {
                if (lst5[i].BookId == book.Id)
                {
                    lst5[i].State = State;
                }
            }

            //修改StuYuding中学生选书失败
            var query3 = db.T_TB_StuYuding;
            List <myTBsys.Models.T_TB_StuYuding> lst3 = query3.ToList();

            for (int i = 0; i < lst3.Count; i++)
            {
                if (lst3[i].BookId == book.Id)
                {
                    lst3[i].State = State;
                }
            }


            //修改TeaYuding中教师选书失败
            var query2 = db.T_TB_TeaYuding;
            List <myTBsys.Models.T_TB_TeaYuding> lst2 = query2.ToList();

            for (int i = 0; i < lst2.Count; i++)
            {
                if (lst2[i].BookId == book.Id)
                {
                    lst2[i].State = State;
                }
            }

            var query8 = db.T_TB_Choose;
            List <myTBsys.Models.T_TB_Choose> lst8 = query8.ToList();

            for (int i = 0; i < lst8.Count; i++)
            {
                if (lst8[i].BookId == book.Id)
                {
                    if (State == 0)//修改choose中书为无库存
                    {
                        lst8[i].State = 1;
                    }
                    else
                    {
                        lst8[i].State = State;
                    }
                }
            }

            //item.Store = book.Store;
            //item.Status = book.Status;
            //item.Description = book.Description;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }