예제 #1
0
 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
 }
예제 #2
0
 public void BindData()
 {
     #region 绑定GridView
     grvbooklist.DataSource = Bookmanager.GetBookListDataTable(ViewState["CategoryID"].ToString(), ViewState["Sort"].ToString(), ViewState["Search"].ToString());
     grvbooklist.DataBind();
     #endregion
 }
예제 #3
0
    public void BindData()
    {
        #region GridView绑定

        grvbooklist.DataSource = Bookmanager.GetBookListDataTable(ViewState["CategorieID"].ToString(), ViewState["order"].ToString(), ViewState["search"].ToString());
        grvbooklist.DataBind();
        #endregion
    }
예제 #4
0
 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
 }
예제 #5
0
 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
 }
예제 #6
0
 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
 }
예제 #7
0
    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
    }
예제 #8
0
 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
 }
예제 #9
0
 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
 }
예제 #10
0
    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
    }
예제 #11
0
 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
     }
 }
예제 #12
0
 public MainPage()
 {
     this.InitializeComponent();
     Books = Bookmanager.GetBooks();
 }