//下架一本书,已测 //成功返回1 public int offShelfBook(int bookID) { int result = 0; BookDAL ba = new BookDAL(); result = ba.offSelfABook(bookID); return result; }
//商家修改书本信息,已测 //返回1修改成功,否则失败 public int updateBook(int bookID, int typeID, string title, string author, string publisher, string isbn, string info, float price, int amount, string imgpath) { int result = 0; BookDAL bd = new BookDAL(); Book b = new Book(); b.bookID = bookID; b.typeListId = typeID; b.bookTitle = title; b.bookAuthor = author; b.bookPublisher = publisher; b.bookIsbn = isbn; b.bookInfo = info; b.bookPrice = price; b.bookAmount = amount; b.bookImage = imgpath; result = bd.modifyBook(b); return result; }
protected void Page_Load(object sender, EventArgs e) { int id = int.Parse(Request.QueryString["id"].ToString()); BookDAL bd = new BookDAL(); bookShop.DAL.Book thisBook = bd.selectBookByID(id); if (thisBook == null) Response.Redirect("~/Error.aspx"); else { bookNameLabel.Text = thisBook.bookTitle; tool t = new tool(); string formatPrice = t.priceFormat(thisBook.bookPrice.ToString()); priceLabel.Text = formatPrice; amountLabel.Text = thisBook.bookAmount.ToString(); pubLabel.Text = thisBook.bookPublisher; isbnLabel.Text = thisBook.bookIsbn; string type = "" ; switch(thisBook.typeListId) { case 1:type = "文学";break; case 2:type = "少儿";break; case 3:type = "管理";break; case 4:type = "励志与成功";break; case 5:type = "人文社科";break; case 6:type = "生活";break; case 7:type = "艺术";break; case 8:type = "科技";break; case 9:type = "计算机与互联网";break; case 10:type = "教育";break; case 11:type = "期刊";break; } Label1.Text = type; infoLiteral.Text = thisBook.bookInfo; //提示下架,隐藏加入购物车按钮 if (!thisBook.isvalid) { Label2.Visible = true; Button1.Visible = false; } } }
//商家插入一本书,已测 //返回1插入成功,否则失败 public int insertBook(int sellerID,int typeID,string title,string author, string publisher,string isbn,string info, float price,int amount,bool valid,string imgpath) { int result = 0; BookDAL bd = new BookDAL(); Book b = new Book(); b.sellerID = sellerID; b.typeListId = typeID; b.bookTitle = title; b.bookAuthor = author; b.bookAmount = amount; b.bookPublisher = publisher; b.bookIsbn = isbn; b.bookInfo = info; b.bookPrice = price; b.isvalid = valid; b.bookImage = imgpath; result = bd.insertBook(b); return result; }
//按要求搜索书,返回DateTable,已测 //输入搜索类型和搜索关键字 //搜索类型:1书名搜索,2作者搜索,3出版社搜索,4ISBN搜索 public DataTable searchBook(int searchType, string key) { BookDAL ba = new BookDAL(); if (searchType == 1) { return ba.selectBooksByTitle(key); } else if (searchType == 2) { return ba.selectBooksByAuthor(key); } else if (searchType == 3) { return ba.selectBooksByPublisher(key); } else if (searchType == 4) { return ba.selectBooksByISBN(key); } else return null; }
//查看最新N本书,已测 public DataTable getNewBooks(int n) { BookDAL ba = new BookDAL(); return ba.selectBooksOfTopN(n); }
//查看所有某个分类的书,已测 public DataTable getAllBooksAType(int typeID) { BookDAL ba = new BookDAL(); return ba.selectBooksByType(typeID); }
//查看一个商家的所有书,已测 public DataTable getSellerAllBooks(int sellerID) { BookDAL ba = new BookDAL(); return ba.selectBooksBySellerID(sellerID); }
protected void Button1_Click(object sender, EventArgs e) { BookDAL bd = new BookDAL(); int max = bd.selectMaxID(); System.Diagnostics.Debug.WriteLine("我是最大的ID" + max); }