Пример #1
0
    /// <summary>
    /// 从购物车中移除产品
    /// </summary>
    private void Del()
    {
        string id = Request.QueryString["productId"];

        if (!string.IsNullOrEmpty(id))
        {
            int productId = 0;
            int.TryParse(id, out productId);

            shopCarBLL.Remove(productId);

            Response.Write("{success:true}");
        }
        else
        {
            Response.Write("{success:false}");
        }
        Response.End();
    }
Пример #2
0
    protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int productId = int.Parse(e.CommandArgument.ToString());

        switch (e.CommandName.ToLower())
        {
        case "delete":
            _shopCarBLL.Remove(productId);
            Response.Redirect("ShopCar.aspx", true);
            break;

        case "edit":
            Label      lblNum       = (Label)e.Item.FindControl("lblNum");
            TextBox    txtNum       = (TextBox)e.Item.FindControl("txtNum");
            LinkButton lnkbtnEdit   = (LinkButton)e.Item.FindControl("lnkbtnEdit");
            LinkButton lnkbtnSave   = (LinkButton)e.Item.FindControl("lnkbtnSave");
            LinkButton lnkbtnCancel = (LinkButton)e.Item.FindControl("lnkbtnCancel");

            lblNum.Visible       = false;
            txtNum.Visible       = true;
            lnkbtnEdit.Visible   = false;
            lnkbtnSave.Visible   = true;
            lnkbtnCancel.Visible = true;
            txtNum.Text          = lblNum.Text;
            break;

        case "cancel":
            Response.Redirect("ShopCar.aspx", true);
            break;

        case "save":
            TextBox txtNumModified = (TextBox)e.Item.FindControl("txtNum");
            int     num            = 1;
            int.TryParse(txtNumModified.Text.Trim(), out num);
            _shopCarBLL.SetNum(productId, num);
            Response.Redirect("ShopCar.aspx", true);
            break;

        default:
            break;
        }
    }