Beispiel #1
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                // First lets save the product
                CouponInfo coupon = new CouponInfo();
                bool       isNew  = false;

                if (CouponId >= 0)
                {
                    coupon = Controller.GetCouponById(CouponId);
                }
                else
                {
                    isNew = true;
                }

                coupon.Caption = txtCaption.Text;
                coupon.Code    = txtCode.Text;

                if (String.IsNullOrEmpty(txtDiscountPercent.Text))
                {
                    coupon.DiscountPercent = null;
                }
                else
                {
                    coupon.DiscountPercent = Convert.ToDecimal(txtDiscountPercent.Text);
                }

                if (taxDiscountValue.NetPrice <= 0)
                {
                    coupon.DiscountValue = null;
                }
                else
                {
                    coupon.DiscountValue = taxDiscountValue.NetPrice;
                }

                coupon.TaxPercent = Convert.ToDecimal(txtTaxPercent.Text.Trim());
                coupon.MaxUsages  = Convert.ToInt32(txtMaxUsages.Text);
                coupon.UsagesLeft = Convert.ToInt32(txtUsagesLeft.Text);

                if (String.IsNullOrEmpty(txtValidUntil.Text))
                {
                    coupon.ValidUntil = null;
                }
                else
                {
                    coupon.ValidUntil = Convert.ToDateTime(txtValidUntil.Text);
                }


                if (isNew)
                {
                    CouponId = Controller.NewCoupon(coupon);
                }
                else
                {
                    Controller.UpdateCoupon(coupon);
                }

                List <string> addParams = new List <string>();

                if (Request["adminmode"] != null)
                {
                    addParams.Add("adminmode=couponlist");
                }
                addParams.Add("couponId=" + CouponId.ToString());

                Response.Redirect(Globals.NavigateURL(TabId, "", addParams.ToArray()), true);
            }
            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }