protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["BID"] != null) { try { if (!Bll_Book.Exists_BID(Convert.ToInt32(Request.QueryString["BID"]))) { Response.Redirect("Main.aspx"); } } catch (Exception) { Response.Redirect("Main.aspx"); } } else { Response.Redirect("Main.aspx"); } if (!IsPostBack) { TextBox1.Text = 1.ToString(); } book = Bll_Book.Select_BID(Convert.ToInt32(Request.QueryString["BID"])); }
protected void Button1_Click(object sender, EventArgs e) { Random random = new Random(); string img = FileUpload1.FileName != null && FileUpload1.FileName != "" ? random.Next() + DateTime.Now.Ticks + FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf('.')) : book.BPic; if (Bll_Book.Update_BID(new Book() { BID = Convert.ToInt32(Request.QueryString["BID"]), BName = TextBox1.Text, BAuthor = TextBox5.Text, BISBN = TextBox2.Text, BSID = Convert.ToInt32(DropDownList1.SelectedValue), BPrice = Convert.ToDecimal(TextBox3.Text), BCount = Convert.ToInt32(TextBox4.Text), BSaleCount = Convert.ToInt32(TextBox8.Text), BTOC = TextBox7.Text, BComment = TextBox6.Text, BPic = img }) > 0) { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('修改成功')</script>"); if (img != book.BPic) { FileUpload1.SaveAs(Server.MapPath("../BookImages") + "/" + img); } Response.Redirect("Goods.aspx"); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('修改失败')</script>"); } }
/// <summary> /// 页面:Goods.aspx (为Repeater1添加数据源并产生分页 /// </summary> private void GoodsPaging() { pagecount = Bll_Book.RowCount() % pagesize == 0 ? Bll_Book.RowCount() / pagesize : Bll_Book.RowCount() / pagesize + 1; List <Book> books = new List <Book>(); if (Request.QueryString["pageindex"] != null) { pageindex = Convert.ToInt32(Request.QueryString["pageindex"]); } if (Request.QueryString["pageindex"] != null) { if (Convert.ToInt32(Request.QueryString["pageindex"]) > pagecount) { pageindex = pagecount; } } if (Request.QueryString["BName"] != null) { pagecount = Bll_Book.RowCount_BName(Request.QueryString["BName"].ToString()) % pagesize == 0 ? Bll_Book.RowCount_BName(Request.QueryString["BName"].ToString()) / pagesize : Bll_Book.RowCount_BName(Request.QueryString["BName"].ToString()) / pagesize + 1; if (Request.QueryString["pageindex"] != null) { if (Convert.ToInt32(Request.QueryString["pageindex"]) > pagecount) { pageindex = pagecount; } } books = Bll_Book.TopPaging_BName(Request.QueryString["BName"], pagesize, pageindex); Repeater1.DataSource = books; Repeater1.DataBind(); } else { books = Bll_Book.TopPaging(pagesize, pageindex); Repeater1.DataSource = books; Repeater1.DataBind(); } if (pageindex > 1) { HyperLink1.NavigateUrl = "Goods.aspx?pageindex=1" + (Request.QueryString["BName"] == null ? "" : "&BName=" + Request.QueryString["BName"]); HyperLink2.NavigateUrl = "Goods.aspx?pageindex=" + (pageindex - 1) + (Request.QueryString["BName"] == null ? "" : "&BName=" + Request.QueryString["BName"]); } if (pageindex < pagecount) { HyperLink3.NavigateUrl = "Goods.aspx?pageindex=" + (pageindex + 1) + (Request.QueryString["BName"] == null ? "" : "&BName=" + Request.QueryString["BName"]); HyperLink4.NavigateUrl = "Goods.aspx?pageindex=" + pagecount + (Request.QueryString["BName"] == null ? "" : "&BName=" + Request.QueryString["BName"]); } Label1.Text = pagecount.ToString(); Label2.Text = pagesize.ToString(); Label3.Text = pageindex.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Repeater1.DataSource = Bll_Book.DOrderBy_BSaleCount(); Repeater1.DataBind(); Repeater2.DataSource = Bll_Book.DOrderBy_BDate(); Repeater2.DataBind(); } }
protected void Button2_Click(object sender, EventArgs e) { try { pagecount = Bll_Book.RowCount() % pagesize == 0 ? Bll_Book.RowCount() / pagesize : Bll_Book.RowCount() / pagesize + 1; if (Convert.ToInt32(TextBox3.Text) <= pagecount) { Response.Redirect("Goods.aspx?pageindex=" + TextBox3.Text + (Request.QueryString["BName"] == null ? "" : "&BName=" + Request.QueryString["BName"])); } else { TextBox3.Text = "页码超出"; } } catch (Exception) { TextBox3.Text = "错误"; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["AName"] == null) { Response.Redirect("Default.aspx"); } book = Bll_Book.Select_BID(Convert.ToInt32(Request.QueryString["BID"])); if (!IsPostBack) { DropDownList1.DataSource = Bll_BSCategory.Select_All(); DropDownList1.DataValueField = "BSID"; DropDownList1.DataTextField = "BLName"; DropDownList1.DataBind(); TextBox1.Text = book.BName; TextBox5.Text = book.BAuthor; TextBox2.Text = book.BISBN; DropDownList1.SelectedValue = book.BSID.ToString(); TextBox3.Text = book.BPrice.ToString(); TextBox4.Text = book.BCount.ToString(); TextBox8.Text = book.BSaleCount.ToString(); TextBox6.Text = book.BTOC; TextBox7.Text = book.BComment; } }
protected void Button1_Click(object sender, EventArgs e) { string OConsignee = TextBox1.Text; //收货人昵称 string OAddress = TextBox2.Text; //地址 string OTelephone = TextBox3.Text; //联系电话 double OSumPrice = Convert.ToDouble(TextBox4.Text); //订单总消费 bool UpdateSwitch = true; //修改库存开关 string[] TradeTID = Request.QueryString["TradesTID"].ToString().Trim().Split('^'); //遍历结算中商品的库存对比购买的数量,如果全部商品库存足够,则打开修改开关,否则关闭修改开关 for (int i = 0; i < TradeTID.Length; i++) { if (TradeTID[i] != "") { Trade trade = Bll_Trade.Select_TradeAndBook_TID(Convert.ToInt32(TradeTID[i])); if (trade.BCount > Bll_Book.Select_BID(trade.BID).BCount) { UpdateSwitch = false; } } } //修改订单内商品的库存和销量 if (UpdateSwitch) { for (int i = 0; i < TradeTID.Length; i++) { if (TradeTID[i] != "") { Trade trade = Bll_Trade.Select_TradeAndBook_TID(Convert.ToInt32(TradeTID[i])); Bll_Book.Update_BCountAndBSaleCount(new Book() { BID = trade.BID, BCount = trade.BCount }); } } //为当前结算添加订单 Order order = new Order() { OID = Bll_Order.ObtainOID(), MID = Bll_Member.GetMID(Request.Cookies["Login"].Values["MName"]), ODate = DateTime.Now.ToString(), OConsignee = OConsignee, OAddress = OAddress, OTelephone = OTelephone, OSumPrice = OSumPrice, OState = "1" }; Bll_Order.Insert(order); //为订单添加订单明细 for (int i = 0; i < TradeTID.Length; i++) { if (TradeTID[i] != "") { Trade trade = Bll_Trade.Select_TradeAndBook_TID(Convert.ToInt32(TradeTID[i])); Bll_OrderDetails.Insert(new OrderDetails() { OID = order.OID, BID = trade.BID, BPrice = trade.BPrice, BCount = trade.BCount }); } } //清空当前用户购物车 Bll_Trade.Delelte_MID(order.MID); //订单号页面 Response.Redirect("Done.aspx?OID=" + order.OID); } else { ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('部分商品库存不足')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { Bll_Book.Delete_BID(Convert.ToInt32(Request.QueryString["BID"])); Response.Redirect("Goods.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //页大小 int pagesize = 5; //当前页 int pageindex = 1; //数据源 List <Book> books = new List <Book>(); //总页数 int pagecount = 0; if (Request.QueryString["pageindex"] != null) { pageindex = Convert.ToInt32(Request.QueryString["pageindex"]); } #region 大类别筛选分页 if (Request.QueryString["BLID"] != null) { string BLID = Request.QueryString["BLID"]; books = Bll_Book.Select_BLID(Convert.ToInt32(BLID)); pagecount = books.Count % pagesize == 0 ? books.Count / pagesize : books.Count / pagesize + 1; Repeater1.DataSource = Bll_Book.TopPaging_BLID(pagesize, pageindex, Convert.ToInt32(BLID)); Repeater1.DataBind(); if (pageindex > 1) { HyperLink1.NavigateUrl = "Category.aspx?BLID=" + BLID + "&pageindex=1"; HyperLink2.NavigateUrl = "Category.aspx?BLID=" + BLID + "&pageindex=" + (pageindex - 1); } if (pageindex < pagecount) { HyperLink3.NavigateUrl = "Category.aspx?BLID=" + BLID + "&pageindex=" + (pageindex + 1); HyperLink4.NavigateUrl = "Category.aspx?BLID=" + BLID + "&pageindex=" + pagecount; } Label1.Text = pageindex + " / " + pagecount; } #endregion #region 小类别筛选分页 if (Request.QueryString["BSID"] != null) { string BSID = Request.QueryString["BSID"]; books = Bll_Book.Select_BSID(Convert.ToInt32(BSID)); pagecount = books.Count % pagesize == 0 ? books.Count / pagesize : books.Count / pagesize + 1; Repeater1.DataSource = Bll_Book.TopPaging_BSID(pagesize, pageindex, Convert.ToInt32(BSID)); Repeater1.DataBind(); if (pageindex > 1) { HyperLink1.NavigateUrl = "Category.aspx?BSID=" + BSID + "&pageindex=1"; HyperLink2.NavigateUrl = "Category.aspx?BSID=" + BSID + "&pageindex=" + (pageindex - 1); } if (pageindex < pagecount) { HyperLink3.NavigateUrl = "Category.aspx?BSID=" + BSID + "&pageindex=" + (pageindex + 1); HyperLink4.NavigateUrl = "Category.aspx?BSID=" + BSID + "&pageindex=" + pagecount; } Label1.Text = pageindex + " / " + pagecount; } #endregion #region 书名筛选分页 if (Request.QueryString["BName"] != null) { string BName = Request.QueryString["BName"]; books = Bll_Book.DimSelect_BName(BName); pagecount = books.Count % pagesize == 0 ? books.Count / pagesize : books.Count / pagesize + 1; Repeater1.DataSource = Bll_Book.TopPaging_BName(BName, pagesize, pageindex); Repeater1.DataBind(); if (pageindex > 1) { HyperLink1.NavigateUrl = "Category.aspx?BName=" + BName + "&pageindex=1"; HyperLink2.NavigateUrl = "Category.aspx?BName=" + BName + "&pageindex=" + (pageindex - 1); } if (pageindex < pagecount) { HyperLink3.NavigateUrl = "Category.aspx?BName=" + BName + "&pageindex=" + (pageindex + 1); HyperLink4.NavigateUrl = "Category.aspx?BName=" + BName + "&pageindex=" + pagecount; } Label1.Text = pageindex + " / " + pagecount; } #endregion } }