示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.Cookies["Login"] != null)
         {
             Repeater1.DataSource = Bll_Trade.Select_TradeAndBook_MID(Bll_Member.GetMID(Request.Cookies["Login"].Values["MName"].ToString()));
             Repeater1.DataBind();
         }
     }
 }
示例#2
0
 public void MyDataBind()
 {
     Repeater1.DataSource = Bll.Bll_BLCategory.Select_All();
     Repeater1.DataBind();
     if (Request.Cookies["Login"] != null)
     {
         List <Trade> trades = Bll_Trade.Select_TradeAndBook_MID((Bll_Member.GetMID(Request.Cookies["Login"].Values["MName"].ToString())));
         foreach (Trade trade in trades)
         {
             TotalPrice += trade.BPrice * trade.BCount;
         }
         TotalProduct = trades.Count;
     }
 }
示例#3
0
 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
 {
     if (Request.Cookies["Login"] != null)
     {
         Trade trade = new Trade()
         {
             BCount = Convert.ToInt32(TextBox1.Text),
             BID    = Convert.ToInt32(Request.QueryString["BID"]),
             MID    = Bll_Member.GetMID(Request.Cookies["Login"].Values["MName"].ToString()),
         };
         if (Bll_Trade.Exits(trade))
         {
             if (book.BCount > 0 && trade.BCount <= book.BCount)
             {
                 Bll_Trade.Update_BCount(trade);
                 Response.Redirect("Goods.aspx?BID=" + book.BID);
             }
             else
             {
                 TextBox1.Text = "库存不足";
             }
         }
         else
         {
             if (book.BCount > 0 && trade.BCount <= book.BCount)
             {
                 Bll_Trade.Insert(trade);
                 Response.Redirect("Goods.aspx?BID=" + book.BID);
             }
             else
             {
                 TextBox1.Text = "库存不足";
             }
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
示例#4
0
        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>");
            }
        }