コード例 #1
0
ファイル: shoppingcar.aspx.cs プロジェクト: Lijietong/V-E
        protected void LVShoppingcart_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Label  lbl       = (Label)e.Item.FindControl("lbshoppingcartid");
            string Eventname = e.CommandName;

            switch (Eventname)
            {
            case "Delete":
            {
                int ID     = Convert.ToInt32(lbl.Text);
                int result = GoodsManager.DeleteShoppingCart(ID);
                if (result >= 1)
                {
                    int       ID02 = Convert.ToInt32(Session["UserID"]);
                    DataTable ys   = GoodsManager.JudgeShoppingCart(ID02);
                    if (ys != null && ys.Rows.Count != 0)
                    {
                        Panel01.Visible = true;
                        Panel02.Visible = false;
                    }
                    else
                    {
                        Panel01.Visible = false;
                        Panel02.Visible = true;
                    }
                    string    UserName = Convert.ToString(Session["UserName"]);
                    DataTable dt       = GoodsManager.SelectAllTot_amt(UserName);
                    if (dt != null && dt.Rows.Count != 0)
                    {
                        RPBuy.DataSource = dt;
                        RPBuy.DataBind();
                    }
                    string    UserID = Convert.ToString(Session["UserName"]);
                    DataTable dt02   = GoodsManager.SelectShoppingCart(UserID);
                    if (dt02 != null && dt02.Rows.Count != 0)
                    {
                        LVShoppingcart.DataSource = dt02;
                        LVShoppingcart.DataBind();
                    }
                }
            }
            break;
            }
        }
コード例 #2
0
        protected void Reshoppingcart_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            Label   lbl       = (Label)e.Item.FindControl("LabelShoppingCartID");
            Label   lbl2      = (Label)e.Item.FindControl("LabelMallGoodsNum");
            Label   lblprice  = (Label)e.Item.FindControl("lblprice");
            TextBox textbox   = (TextBox)e.Item.FindControl("sqlMallNumber");
            string  Eventname = e.CommandName;

            switch (Eventname)
            {
            case "Delete":
            {
                int id     = Convert.ToInt32(lbl.Text);
                int result = GoodsManager.DeleteShoppingCart(id);
                if (result >= 1)
                {
                    int       ID02 = Convert.ToInt32(Session["user_id"]);
                    DataTable dt   = GoodsManager.JudgeShoppingCart(ID02);
                    if (dt != null && dt.Rows.Count != 0)
                    {
                        Panel01.Visible = true;
                        Panel02.Visible = false;
                    }
                    else
                    {
                        Panel01.Visible = false;
                        Panel02.Visible = true;
                    }
                    int       user_id = Convert.ToInt32(Session["user_id"]);
                    DataTable dt1     = GoodsManager.SelectAllTotalAmount(user_id);
                    if (dt1 != null && dt1.Rows.Count != 0)
                    {
                        trShoppingCartBuy.DataSource = dt1;
                        trShoppingCartBuy.DataBind();
                    }
                    int       user_id1 = Convert.ToInt32(Session["user_id"]);
                    DataTable dt2      = GoodsManager.SelectShoppingCart(user_id1);
                    if (dt2 != null && dt2.Rows.Count != 0)
                    {
                        Reshoppingcart.DataSource = dt2;
                        Reshoppingcart.DataBind();
                    }
                }
            }
            break;

            case "ChageNum":
            {
                try
                {
                    int lbl3 = Convert.ToInt32(lbl2.Text);
                    int a    = Convert.ToInt32(textbox.Text);
                    if (a > lbl3)
                    {
                        a = lbl3;
                    }
                    if (a <= 0)
                    {
                        a = 1;
                    }
                    int   ID        = Convert.ToInt32(lbl.Text);
                    float Cartprice = float.Parse(lblprice.Text);
                    int   number    = a;
                    float total     = Cartprice * number;
                    int   result    = GoodsManager.UpdateShoppingCartNum(ID, number, total);
                    if (result >= 1)
                    {
                        int       user_id = Convert.ToInt32(Session["user_id"]);
                        DataTable dt1     = GoodsManager.SelectAllTotalAmount(user_id);
                        if (dt1 != null && dt1.Rows.Count != 0)
                        {
                            trShoppingCartBuy.DataSource = dt1;
                            trShoppingCartBuy.DataBind();
                        }
                        int       user_id1 = Convert.ToInt32(Session["user_id"]);
                        DataTable dt2      = GoodsManager.SelectShoppingCart(user_id1);
                        if (dt2 != null && dt2.Rows.Count != 0)
                        {
                            Reshoppingcart.DataSource = dt2;
                            Reshoppingcart.DataBind();
                        }
                    }
                }
                catch
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "true", "<script>alert('只能输入整数!');</script>");
                }
            }
            break;
            }
        }