Beispiel #1
0
        protected void btnCheck_Click(object sender, EventArgs e)
        {
            foreach (BookOrderModel book in OrderOnThisPage.books)
            {
                if (book.quantity > book.book.stock)
                {
                    Modal.Show(this, "无法购买:《" + book.book.title + "》的库存量不足");
                    return;
                }
                if (book.book.onsale == 0)
                {
                    Modal.Show(this, "无法购买:" + book.book.title + "已经下架");
                    return;
                }
            }
            if (OrderOnThisPage.user.balance < OrderOnThisPage.totalPrice)
            {
                Modal.Show(this, "无法购买:余额不足");
                return;
            }

            OrderBLL.SetOrderStatus(OrderOnThisPage.id, OrderStatus.Process);
            btnCancel.Enabled = false;

            foreach (BookOrderModel book in OrderOnThisPage.books)
            {
                book.book.stock -= book.quantity;
                BookStatBLL.SetBook(book.book);
            }
            OrderOnThisPage.user.balance -= OrderOnThisPage.totalPrice;
            UserInfoBLL.SetNewInfo(OrderOnThisPage.user);
            Modal.Show(this, "支付成功", 1000, "/orderdetail.aspx?orderid=" + OrderOnThisPage.id);
        }
Beispiel #2
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() + "本";
        }
Beispiel #3
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"]);
     }
 }
Beispiel #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     LatestBooksRow.SetTitle("最近更新", "Latest Books");
     LatestBooksRow.SetBooks(BookStatBLL.GetNewestBooks(5));
     BestSellersRow.SetTitle("当前热销", "Current Bestsellers");
     BestSellersRow.SetBooks(BookStatBLL.GetHighestStarsBooks(5));
     TopRatedBooksRow.SetTitle("评分最高", "Top Rated Books");
     TopRatedBooksRow.SetBooks(BookStatBLL.GetHighestStarsBooks(5));
     Navbar.SetLinks(CategoryBLL.GetCategoryByRole(0));
 }
Beispiel #5
0
        private void BindUserInfo()
        {
            string sql = "select * from bookstat_full";

            BookTable.DataSource = SqlHelper.ExecuteDataTable(sql);
            BookTable.DataBind();
            btnAll.Checked  = false;
            txtID.Text      = "";
            txtKeyword.Text = "";
            Label1.Text     = BookStatBLL.GetBookOnSaleCount().ToString();
        }
Beispiel #6
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"]);
     }
 }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dictionary <BookStatModel, int> books = BookStatBLL.GetTopSellingBooks(10);
            int rank = 1;

            foreach (KeyValuePair <BookStatModel, int> book in books)
            {
                TopListElement control = (TopListElement)LoadControl("~/Controls/Element/TopListElement.ascx");
                Panel1.Controls.Add(control);
                control.SetParent(Panel1.ClientID);
                control.SetBook(book.Key, rank, book.Value);
                rank++;
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StreamReader  responseReader = new StreamReader(Server.MapPath("~/IndexSettings.json"));
            string        result         = responseReader.ReadToEnd();
            IndexSettings settings       = JsonConvert.DeserializeObject <IndexSettings>(result);
            var           Book           = BookStatBLL.GetBookByID(settings.WeeklyBook);

            txtPrice.Text          = Book.price.ToString("F2");
            txtOriginPrice.Text    = Book.origin_price;
            txtTitle.Text          = Book.title;
            txtSummry.Text         = Book.summary;
            linkDetail.NavigateUrl = "/details.aspx?book=" + Book.id.ToString();
            imgCover.ImageUrl      = "/public/images/cover/" + Book.image;
        }
Beispiel #9
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();
        }
Beispiel #10
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();
     }
 }
Beispiel #11
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();
                }
            }
        }
Beispiel #12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request["id[]"] == null)
            {
                context.Response.Write("failed");
                return;
            }
            if (context.Request["onsale"] == null)
            {
                context.Response.Write("failed");
                return;
            }
            string[]   id       = context.Request["id[]"].Split(',');
            int        onsale   = int.Parse(context.Request["onsale"]);
            bool       flag     = true;
            List <int> failedid = new List <int>();

            for (int i = 0; i < id.Length; i++)
            {
                int s = int.Parse(id[i]);
                if (BookStatBLL.SetBookOnSale(s, onsale) == "失败")
                {
                    flag = false;
                    failedid.Add(i);
                }
            }
            if (flag)
            {
                context.Response.Write("id");
                for (int i = 0; i < failedid.Count; i++)
                {
                    context.Response.Write(failedid[i] + "\n");
                }
                context.Response.Write("修改失败");
            }
            else
            {
                context.Response.Write("修改成功");
            }
        }
Beispiel #13
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();
        }