Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Request.QueryString["TradesTID"] == null || Request.QueryString["TradesTID"].Trim() == "^" || Request.QueryString["TradesTID"].Trim() == "")
         {
             Response.Redirect("Main.aspx");
         }
         List <Trade> trades    = new List <Trade>();
         decimal      OSumPrice = 0;
         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]));
                 trades.Add(trade);
                 OSumPrice += trade.BCount * trade.BPrice;
             }
         }
         if (!IsPostBack)
         {
             Repeater1.DataSource = trades;
             Repeater1.DataBind();
         }
         TextBox4.Text     = OSumPrice.ToString();
         TextBox4.ReadOnly = true;
         //Response.Write(Request.QueryString["TradesTID"].ToString());
     }
     catch (Exception)
     {
         Response.Redirect("Main.aspx");
     }
 }
Ejemplo n.º 2
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     foreach (RepeaterItem item in Repeater1.Items)
     {
         Bll_Trade.Update_BCount(Convert.ToInt32((item.FindControl("TextBox1") as TextBox).Text), Convert.ToInt32((item.FindControl("Label2") as Label).Text));
         Response.Redirect("Flow.aspx");
     }
 }
Ejemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Request.QueryString["TID"] != null)
     {
         Bll_Trade.Delete_TID(Convert.ToInt32(Request.QueryString["TID"]));
     }
     Response.Redirect("Flow.aspx");
 }
Ejemplo n.º 4
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();
         }
     }
 }
Ejemplo n.º 5
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;
     }
 }
Ejemplo n.º 6
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");
     }
 }
Ejemplo n.º 7
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>");
            }
        }