Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["book"] == null)
            {
                Response.Redirect("/index.aspx");
                return;
            }
            int bookid = -1;

            try
            {
                bookid = int.Parse(Request["book"]);
            }
            catch (Exception)
            {
                Response.Redirect("/index.aspx");
                return;
            }
            BookStatModel x = BookStatBLL.GetBookByID(bookid);

            BookOnThisPage = x;
            if (x.id == -1)
            {
                Response.Redirect("/index.aspx");
                return;
            }
            txtAuthor.Text = x.author;
            if (x.origintitle.Trim() != "")
            {
                txtOriginTitle.Text = x.origintitle;
            }
            else
            {
                txtOriginTitle.Visible = false;
            }
            txtPrice.Text     = "¥" + x.price.ToString("F2");
            txtStars.Text     = x.stars.ToString() + "/5";
            txtSummary.Text   = x.summary;
            txtTitle.Text     = x.title;
            tdAuthor.Text     = x.author;
            tdISBN.Text       = x.isbn;
            tdPages.Text      = x.pages;
            tdPrice.Text      = x.origin_price;
            tdPublisher.Text  = x.publisher;
            tdTitle.Text      = x.title;
            tdPubdate.Text    = x.pubdate;
            imgCover.ImageUrl = "/public/images/cover/" + x.image;
            tabCatalog.Text   = x.catalog;
            tabSummary.Text   = x.summary;
            if (x.stock == 0)
            {
                btnBuy.Enabled = false;
            }
            if (x.onsale == 0)
            {
                btnBuy.Enabled = false;
            }
            txtStock.Text = "剩余" + x.stock.ToString() + "本";
        }
Exemplo n.º 2
0
 protected void btnBan_Click(object sender, EventArgs e)
 {
     if (Request["bookid"] != null)
     {
         BookStatModel book = BookStatBLL.GetBookByID(int.Parse(Request["bookid"]));
         BookStatBLL.SetBookOnSale(book.id, book.onsale == 0 ? 1 : 0);
         Response.Redirect("bookdetail.aspx?bookid=" + Request["bookid"]);
     }
 }
Exemplo n.º 3
0
 public void SetBook(BookStatModel book, int rank, int sales)
 {
     txtClientID.Text  = rank.ToString();
     txtTitle.Text     = book.title;
     txtSales.Text     = "总销量:" + sales.ToString();
     txtSummary.Text   = book.summary;
     imgCover.ImageUrl = "/public/images/cover/" + book.image;
     Panel2.Attributes["data-target"] = "#" + Panel1.ClientID;
     linkDetail.NavigateUrl           = "/details.aspx?book=" + book.id.ToString();
 }
Exemplo n.º 4
0
 protected void btnSubmmit2_Click(object sender, EventArgs e)
 {
     if (Request["bookid"] != null)
     {
         BookStatModel book = BookStatBLL.GetBookByID(int.Parse(Request["bookid"]));
         book.stock = int.Parse(txtStock.Text);
         book.price = double.Parse(txtPrice.Text);
         BookStatBLL.SetBook(book);
         Response.Redirect("bookdetail.aspx?bookid=" + Request["bookid"]);
     }
 }
Exemplo n.º 5
0
        public static int UpdateBookStat(BookStatModel book)
        {
            string sql = "update bookstat set stock=@stock, onsale=@onsale,price=@price,up_date = getdate(),stars=@stars where id = @bookid";

            return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter[] {
                new SqlParameter("stock", book.stock),
                new SqlParameter("onsale", book.onsale),
                new SqlParameter("price", book.price),
                new SqlParameter("stars", book.stars),
                new SqlParameter("bookid", book.id),
            }));
        }
Exemplo n.º 6
0
        protected void btnBatchBan_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            foreach (GridViewRow row in BookTable.Rows)
            {
                if (((CheckBox)row.Cells[0].FindControl("btnSelect")).Checked)
                {
                    BookStatModel book = BookStatBLL.GetBookByID((int)BookTable.DataKeys[row.RowIndex].Value);
                    BookStatBLL.SetBookOnSale(book.id, 0);
                }
            }
            BindUserInfo();
        }
Exemplo n.º 7
0
 protected void BookTable_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (BookTable.EditIndex != -1)
     {
         return;
     }
     if (e.CommandName == "BanBook")
     {
         int           bookid = int.Parse((string)e.CommandArgument);
         BookStatModel book   = BookStatBLL.GetBookByID(bookid);
         BookStatBLL.SetBookOnSale(bookid, book.onsale == 1 ? 0 : 1);
         BindUserInfo();
     }
 }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.DataSource     = CategoryBLL.GetCategoryDictByRole(0);
                DropDownList1.DataValueField = "key";
                DropDownList1.DataTextField  = "value";
                DropDownList1.DataBind();
                DropDownList1_SelectedIndexChanged(null, null);
                if (Request["bookid"] != null)
                {
                    int bookid = int.Parse(Request["bookid"]);
                    if (BookStatBLL.GetBookCountByID(bookid) == 0)
                    {
                        return;
                    }
                    BookStatModel book = new BookStatModel();
                    book             = BookStatBLL.GetBookByID(bookid);
                    txtauthorid.Text = book.author_id.ToString();

                    txtcatalog.Text     = book.catalog;
                    txtisbn.Text        = book.isbn;
                    txtorigin.Text      = book.origintitle;
                    txtOriginPrice.Text = book.origin_price;
                    txtpages.Text       = book.pages;
                    txtPrice.Text       = book.price.ToString();
                    txtpubdate.Text     = book.pubdate;
                    txtpublisherid.Text = book.publisher_id.ToString();

                    txtStock.Text   = book.stock.ToString();
                    txtsub.Text     = book.subtitle;
                    txtsummary.Text = book.summary;
                    txttitle.Text   = book.title;
                    if (book.onsale == 1)
                    {
                        btnBan.CssClass = "btn btn-danger";
                        btnBan.Text     = "下架该图书";
                    }
                    else
                    {
                        btnBan.Text     = "上架该图书";
                        btnBan.CssClass = "btn btn-success";
                    }

                    DropDownList1.SelectedValue = CategoryBLL.GetCategoryParent(book.category_id).ToString();
                    DropDownList1_SelectedIndexChanged(null, null);
                    DropDownList2.SelectedValue = book.category_id.ToString();
                }
            }
        }
Exemplo n.º 9
0
        public static BookStatModel GetBookByID(int bookid)
        {
            var reader = BookStatDAL.SelectBookByID(bookid);

            if (reader != null && reader.Read())
            {
                BookStatModel book = new BookStatModel(
                    reader.GetInt32(0),
                    reader.GetString(1),
                    reader.GetString(2),
                    reader.GetString(3),
                    reader.GetString(4),
                    reader.GetString(5),
                    reader.GetInt32(6),
                    reader.GetDouble(7),
                    reader.GetInt32(8),
                    reader.GetDateTime(9),
                    reader.GetDouble(10),
                    reader.GetString(11),
                    reader.GetString(12),
                    reader.GetString(13),
                    reader.GetString(14),
                    reader.GetString(15),
                    reader.GetString(16),
                    reader.GetString(17),
                    reader.GetString(18),
                    reader.GetInt32(19),
                    reader.GetInt32(20),
                    reader.GetInt32(21),
                    reader.GetInt32(22)
                    );
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                return(book);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            BookStatModel book2 = new BookStatModel();

            book2.id = -1;
            return(book2);
        }
Exemplo n.º 10
0
        public static List <BookStatModel> GetNewestBooks(int count)
        {
            List <BookStatModel> books = new List <BookStatModel>();
            var reader = BookStatDAL.SelectNewestBooksOnSale(count);

            while (reader.Read())
            {
                BookStatModel book = new BookStatModel(
                    reader.GetInt32(0),
                    reader.GetString(1),
                    reader.GetString(2),
                    reader.GetString(3),
                    reader.GetString(4),
                    reader.GetString(5),
                    reader.GetInt32(6),
                    reader.GetDouble(7),
                    reader.GetInt32(8),
                    reader.GetDateTime(9),
                    reader.GetDouble(10),
                    reader.GetString(11),
                    reader.GetString(12),
                    reader.GetString(13),
                    reader.GetString(14),
                    reader.GetString(15),
                    reader.GetString(16),
                    reader.GetString(17),
                    reader.GetString(18),
                    reader.GetInt32(19),
                    reader.GetInt32(20),
                    reader.GetInt32(21),
                    reader.GetInt32(22)
                    );
                books.Add(book);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            return(books);
        }
Exemplo n.º 11
0
        protected void BookTable_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int           bookid = (int)BookTable.DataKeys[e.RowIndex].Value;
            BookStatModel book   = BookStatBLL.GetBookByID(bookid);

            ;
            int newStock = 0;

            if (int.TryParse(e.NewValues["stock"].ToString(), out newStock))
            {
                book.stock = newStock;
                BookStatBLL.SetBook(book);
            }
            double newPrice = 0;

            if (double.TryParse(e.NewValues["price"].ToString(), out newPrice))
            {
                book.price = newPrice;
                BookStatBLL.SetBook(book);
            }

            BookTable.EditIndex = -1;
            BindUserInfo();
        }
Exemplo n.º 12
0
 public static int SetBook(BookStatModel book)
 {
     return(BookStatDAL.UpdateBookStat(book));
 }