/// <summary> /// 加载图书详细信息 /// </summary> private void InitData() { int bookId = Convert.ToInt32(Request.QueryString["book_id"]); Book book = new Book(); book.LoadData(bookId); Category category = new Category(); category.LoadData(book.CategoryID); LabelBookInfo.Text = "【类别】" + category.CategoryName + "<hr>【书名】" + book.BookName + "<hr>【作者】" + book.Author + "<hr>【出版社】" + book.Publisher + "<hr>【出版日期】" + book.PublishDate.ToLongDateString() + "<hr>【价格】¥" + book.Price.ToString() + "<hr>【页数】" + book.PageNum.ToString() + "<hr>【简介】" + book.Description + "<hr>【销量】" + book.SaleCount.ToString() + "册"; ImageBook.ImageUrl = "BookPics\\" + book.PictureUrl; }
/// <summary> /// “删除”按钮单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ButtonDelete_Click(object sender, EventArgs e) { ArrayList selectedBooks = this.GetSelected(); Book book = new Book(); //如果用户没有选择,就单击该按钮,则给出警告 if (selectedBooks.Count == 0) { Response.Write("<Script Language=JavaScript>alert('请首先选择图书!');</Script>"); return; } //循环将选择的图书删除 foreach (int bookId in selectedBooks) { book.LoadData(bookId); book.Delete(); } Query(); }