Example #1
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;
        }
    }
Example #2
0
    /// <summary>
    /// 编辑产品数量
    /// </summary>
    private void Edit()
    {
        string id = Request.QueryString["productId"];

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

            int num = 1;
            int.TryParse(Request.Form["Num"], out num);
            shopCarBLL.SetNum(productId, num);

            Response.Write("{success:true}");
        }
        else
        {
            Response.Write("{success:false}");
        }
        Response.End();
    }