Exemplo n.º 1
0
        public static void insert2(db.Books entry)
        {
            dbEntities dc = new dbEntities();

            dc.Books.Add(entry);
            dc.SaveChanges();
        }
Exemplo n.º 2
0
        public ActionResult updateTwo(db.Books entry)
        {
            db.bll.books.updateTwo(entry);

            // 新增完成重定向回主页
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        // 更新方法三
        public static void updateThree(db.Books entry)
        {
            db.dbEntities dc = new dbEntities();

            db.lib.efHelp.entryUpdate(entry, dc);
            dc.SaveChanges();
        }
Exemplo n.º 4
0
 // 删除方法
 public static void delete(int bookid)
 {
     db.dbEntities dc    = new dbEntities();
     db.Books      entry = dc.Books.SingleOrDefault(a => a.BookId == bookid);
     dc.Books.Remove(entry);
     dc.SaveChanges();
 }
Exemplo n.º 5
0
 // 更新方法二
 public static void updateTwo(db.Books entry)
 {
     db.dbEntities dc = new dbEntities();
     // 1. 将entry附加到entry 2. 附加之后,将他的状态改成修改状态
     dc.Entry <db.Books>(entry).State
         = System.Data.EntityState.Modified;
     dc.SaveChanges();
 }
Exemplo n.º 6
0
 // 更新方法一
 public static void updateOne(string AuthorName, string Title, Nullable <decimal> Price, int BookId)
 {
     db.dbEntities dc    = new dbEntities();
     db.Books      entry = dc.Books.Single(a => a.BookId == BookId);
     entry.AuthorName = AuthorName;
     entry.Title      = Title;
     entry.Price      = Price;
     dc.SaveChanges();
 }
Exemplo n.º 7
0
        public static void batchUpdatePrice(List <string> rowIDList, List <string> priceList, List <string> booktypeList, Dictionary <string, string> dicBookTag)
        {
            dbEntities dc = new dbEntities();

            for (int i = 0; i < rowIDList.Count; i++)
            {
                int      rowID = Convert.ToInt32(rowIDList[i]);
                db.Books entry = dc.Books.FirstOrDefault(b => b.BookId == rowID);
                entry.Price    = Convert.ToDecimal(priceList[i]);
                entry.BookType = booktypeList[i];
                entry.BookTag  = dicBookTag[rowIDList[i]];
            }
            dc.SaveChanges();
        }
Exemplo n.º 8
0
        public ActionResult bookUpdate(db.Books entry)
        {
            if (Request["bookTag"] != null)
            {
                entry.BookTag = Request["bookTag"].ToString();
                if (Request.Files.Count > 0 && Request.Files[0].FileName != "")
                {
                    // 上传以后将文件存起来
                    string savePath = "/upload/" + DateTime.Now.ToString("yyyyMMddhhmmss")
                                      + Request.Files[0].FileName;
                    Request.Files[0].SaveAs(Server.MapPath(savePath));
                    entry.BookCoverUrl = savePath;
                }
            }

            db.bll.books.updateThree(entry);
            return(RedirectToAction("bookIndex"));
        }
Exemplo n.º 9
0
 public ActionResult Order(int id)
 {
     db.Books entity = db.bll.books.getBooks(id);
     return(View(entity));
 }
Exemplo n.º 10
0
 public ActionResult updateThree(int id)
 {
     db.Books entry = db.bll.books.getEntry(id);
     return(View(entry));
 }
Exemplo n.º 11
0
 public ActionResult insertTwo()
 {
     db.Books entry = new db.Books();
     return(View(entry));
 }
Exemplo n.º 12
0
 public ActionResult Details(int id)
 {
     db.Books entry = db.bll.books.getEntry(id);
     return(View(entry));
 }
Exemplo n.º 13
0
 public ActionResult bookInsert()
 {
     db.Books entry = new db.Books();
     return(View(entry));
 }