Ejemplo n.º 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();
         }
     }
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (Bll_Member.Registered(TextBox3.Text))
     {
         ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('此用户已注册')</script>");
     }
     else
     {
         if (Bll_Member.Register(new Member()
         {
             MEmail = TextBox4.Text,
             MName = TextBox3.Text,
             MPassword = TextBox6.Text
         }) > 0)
         {
             ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('注册成功')</script>");
         }
     }
 }
Ejemplo n.º 4
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.º 5
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (Bll_Member.Login(new Member()
            {
                MName = TextBox1.Text,
                MPassword = TextBox2.Text
            }) > 0)
            {
                //Session["MName"] = TextBox1.Text;

                HttpCookie keepCookie = new HttpCookie("Login"); //创建一个HttpCookie实例,Cookies名称为Login,实例只是一个容器,真正使用的是Cookie名称
                keepCookie["MName"] = TextBox1.Text;             //向Login中添加一个userName属性,并赋值
                keepCookie.Expires  = DateTime.Now.AddDays(2);   //设定Cookies的有效期为两天
                Response.Cookies.Add(keepCookie);                //把Cookies对象返回给客户端

                Response.Redirect("Main.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('用户名或密码错误')</script>");
            }
        }
Ejemplo n.º 6
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>");
            }
        }