Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 public abstract void UpdateCoupon(CouponInfo Coupon);
Ejemplo n.º 3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                Controller = new BBStoreController();

                // If this is the first visit to the page
                if (Page.IsPostBack == false)
                {
                    CouponInfo coupon = null;

                    if (Request["couponid"] != null)
                    {
                        CouponId = Convert.ToInt32(Request["couponid"]);
                    }

                    // if coupon exists
                    if (CouponId > 0)
                    {
                        coupon = Controller.GetCouponById(CouponId);
                    }

                    //TODO: Weitere Felder
                    taxDiscountValue.Mode = "gross";
                    if (coupon == null)
                    {
                        txtCaption.Text         = "";
                        txtCode.Text            = "";
                        txtTaxPercent.Text      = 0.0m.ToString();
                        txtDiscountPercent.Text = "";
                        taxDiscountValue.Value  = 0.0m;
                        txtMaxUsages.Text       = "1";
                        txtUsagesLeft.Text      = "1";
                        txtValidUntil.Text      = DateTime.Now.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        txtCaption.Text         = coupon.Caption;
                        txtCode.Text            = coupon.Code;
                        txtTaxPercent.Text      = coupon.TaxPercent.ToString();
                        txtDiscountPercent.Text = coupon.DiscountPercent.ToString();
                        taxDiscountValue.Value  = (coupon.DiscountValue == null ? 0 : (decimal)coupon.DiscountValue);
                        txtMaxUsages.Text       = coupon.MaxUsages.ToString();
                        txtUsagesLeft.Text      = coupon.UsagesLeft.ToString();
                        if (coupon.ValidUntil != null)
                        {
                            txtValidUntil.Text = ((DateTime)coupon.ValidUntil).ToString("yyyy-MM-dd");
                        }
                        else
                        {
                            txtValidUntil.Text = "";
                        }
                    }
                }
            }

            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Ejemplo n.º 4
0
 public abstract int NewCoupon(CouponInfo Coupon);