protected void createCoupon_Click(object sender, EventArgs e) { ViewState["CouponEditing"] = null; editCouponPanel.Controls.Clear(); editCouponPanel.Visible = true; CouponType newCouponType = CouponType.GetCouponType(int.Parse(ddlCouponTypes.SelectedValue)); LoadNewCouponEditor(newCouponType); }
protected void btnSave_Click(object sender, EventArgs e) { if ((bool)ViewState["IsNew"]) { PercentOffCoupon pctOffCoupon = new PercentOffCoupon( txtCouponCode.Text, CouponType.GetCouponType((int)ViewState["CouponTypeId"])); FillCouponValiues(pctOffCoupon); } else { PercentOffCoupon pctOffCoupon = (PercentOffCoupon)Coupon.GetCoupon(txtCouponCode.Text); FillCouponValiues(pctOffCoupon); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindCoupons(); ddlCouponTypes.DataSource = new Query("CSK_CouponTypes").ExecuteReader(); ddlCouponTypes.DataBind(); } if (ViewState["CouponEditing"] != null) { string couponCode = (string)ViewState["CouponEditing"]; LoadCouponEditor(couponCode); } if (ViewState["NewCouponType"] != null) { int newCouponTypeId = (int)ViewState["NewCouponType"]; CouponType newCouponType = CouponType.GetCouponType(newCouponTypeId); LoadNewCouponEditor(newCouponType); } }