public void BindData() { #region 绑定数据 Books book = Bookmanager.GetBookDetailById(Convert.ToInt32(ViewState["BookId"])); txtauthor.Text = book.Author; txtcontentdescription.Text = book.ContentDescription; txtcount.Text = book.WordsCount.ToString(); txtISBN.Text = book.ISBN; txtprice.Text = book.UnitPrice.ToString(); txtpublishdate.Text = book.PublishDate.ToString(); txtrecommand.Text = book.EditorComment; txttitle.Text = book.Title; ftbtoc.Text = book.TOC; authordescription.Text = book.AuthorDescription; Image1.ImageUrl = "~/Images/BookCovers/" + book.ISBN + ".jpg"; foreach (ListItem lt in ddlcategory.Items) { if (lt.Value == book.Categories.Id.ToString()) { lt.Selected = true; } } foreach (ListItem lt in ddlpublisher.Items) { if (lt.Value == book.Publishers.Id.ToString()) { lt.Selected = true; } } #endregion }
public void BindData() { #region 绑定GridView grvbooklist.DataSource = Bookmanager.GetBookListDataTable(ViewState["CategoryID"].ToString(), ViewState["Sort"].ToString(), ViewState["Search"].ToString()); grvbooklist.DataBind(); #endregion }
public void BindData() { #region GridView绑定 grvbooklist.DataSource = Bookmanager.GetBookListDataTable(ViewState["CategorieID"].ToString(), ViewState["order"].ToString(), ViewState["search"].ToString()); grvbooklist.DataBind(); #endregion }
public void BindData() { #region 绑定DstaList数据 dlrecommand.DataSource = Bookmanager.GetHotBooks(1, 4); dlrecommand.DataBind(); dlhot.DataSource = Bookmanager.GetHotBooks(4, 10); dlhot.DataBind(); dlmonthnew.DataSource = Bookmanager.GetNewMonthBooks(4); dlmonthnew.DataBind(); ddlhotbok.DataSource = Bookmanager.GetNewBooks(20); ddlhotbok.DataBind(); #endregion }
public void BuildSession(DataTable car) { #region 把商品信息添加到购物车 DataRow dr = car.NewRow(); Books book = Bookmanager.GetBookDetailById(Convert.ToInt32(ViewState["BookId"])); dr["BookId"] = book.Id; dr["BookName"] = book.Title; dr["BookNumber"] = 1; dr["UnitPrice"] = book.UnitPrice.ToString("0.00"); dr["ImgUrl"] = book.ISBN; car.Rows.Add(dr); Session["cart"] = car; #endregion }
protected void btndelete_Click(object sender, EventArgs e) { #region 除所选 foreach (GridViewRow grv in grvbooklist.Rows) { CheckBox chb = (CheckBox)grv.FindControl("cbok"); if (chb.Checked == true) { Bookmanager.DeleteBookById(Convert.ToInt32(grvbooklist.DataKeys[grv.RowIndex].Value)); } } BindData(); #endregion }
protected void grvbooklist_RowCommand(object sender, GridViewCommandEventArgs e) { #region 除图书 if (e.CommandName == "BookDelete") { Bookmanager.DeleteBookById(Convert.ToInt32(e.CommandArgument)); BindData(); } #endregion #region 转到图书详情 if (e.CommandName == "BookDetail") { Response.Redirect("BookAdd.aspx?BookId=" + Convert.ToInt32(e.CommandArgument)); } #endregion }
protected void btnremove_Click(object sender, EventArgs e) { #region 移动图书 foreach (GridViewRow grv in grvbooklist.Rows) { CheckBox chb = (CheckBox)grv.FindControl("cbok"); if (chb.Checked == true) { int bookid = Convert.ToInt32(grvbooklist.DataKeys[grv.RowIndex].Value); int categoryid = Convert.ToInt32(ddlnewcategory.SelectedValue); Books book = Bookmanager.GetBookDetailById(bookid); book.Categories = CategoriesManager.GetCategoriesById(categoryid); Bookmanager.EditBook(book); } } BindData(); #endregion }
public void AddOrderBook(Orders order) { #region 添加订单详情 DataTable car = (DataTable)Session["cart"]; OrderBook orderbook = new OrderBook(); foreach (DataRow dr in car.Rows) { orderbook.Order = order; orderbook.Quantity = Convert.ToInt32(dr["BookNumber"]); orderbook.UnitPrice = Convert.ToDecimal(dr["UnitPrice"]); orderbook.Book = Bookmanager.GetBookDetailById(Convert.ToInt32(dr["BookId"])); OrderBookManager.AddOrderBook(orderbook); } Session["cart"] = null; labsaleprice.Text = "0.00"; labtotalprice.Text = "0.00"; labmessage.Text = "订单添加成功,请等待商家回应"; #endregion }
public void BindData() { #region 根据图书Id绑定GridView Books book = Bookmanager.GetBookDetailById(Convert.ToInt32(ViewState["BookId"])); book.Clicks++; Bookmanager.EditBook(book); this.lblAuthor.Text = book.Author; this.lblBookName.Text = book.Title; this.lblPublisher.Text = book.Publishers.Name; this.lbltypeName.Text = book.Categories.Name; this.lblISBN.Text = book.ISBN; this.lblPublishDate.Text = book.PublishDate.ToShortDateString(); this.lblFonts.Text = book.WordsCount.ToString(); this.lblPrice.Text = book.UnitPrice.ToString("0.00"); this.lblContent.Text = book.ContentDescription; this.lblAuthorIntroduce.Text = book.AuthorDescription; this.lblRecomment.Text = book.EditorComment; this.lblCatagory.Text = book.TOC; this.lbclicks.Text = book.Clicks.ToString(); this.imgBook.ImageUrl = "~/Images/BookCovers/" + book.ISBN + ".jpg"; #endregion }
protected void btnok_Click(object sender, EventArgs e) { if (ViewState["BookId"] != null) { #region 更新图书 if (FileUploadimg.HasFile) { string[] arrexit = { ".jpg" }; DateTime dt = DateTime.Now; string Bfilename = dt.Year.ToString("0000") + dt.Month.ToString("00") + dt.Second.ToString("00") + dt.Millisecond.ToString("00"); bool isok = FunctionHelp.JudgeFileUploadimg(FileUploadimg, "~/Images/BookCovers/", Bfilename, arrexit); if (isok) { Books book = Bookmanager.GetBookDetailById(Convert.ToInt32(ViewState["BookId"])); book = GetBook(book); book.ISBN = Bfilename; Bookmanager.EditBook(book); Response.Redirect("~/Admin/ListAllBooks.aspx"); } else { labimessage.Text = "上传图片格式不正确"; } } else { Books book = Bookmanager.GetBookDetailById(Convert.ToInt32(ViewState["BookId"])); book = GetBook(book); Bookmanager.EditBook(book); Response.Redirect("~/Admin/ListAllBooks.aspx"); } #endregion } else { #region 添加图书 if (Bookmanager.SearchISBN(txtISBN.Text)) { labisbnmessage.Text = "该ISBN已存在"; } else { if (FileUploadimg.HasFile) { string[] arrexit = { ".jpg" }; bool isok = FunctionHelp.JudgeFileUploadimg(FileUploadimg, "~/Images/BookCovers/", txtISBN.Text, arrexit); if (isok) { Books book = new Books(); book = GetBook(book); Bookmanager.AddBook(book); labimessage.Text = "添加成功"; } else { labimessage.Text = "上传图片格式不正确"; } } } #endregion } }
public MainPage() { this.InitializeComponent(); Books = Bookmanager.GetBooks(); }