Beispiel #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = CouponId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FriendlyDescription != null ? FriendlyDescription.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Remark != null ? Remark.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Code != null ? Code.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Discount.GetHashCode();
         hashCode = (hashCode * 397) ^ (Store != null ? Store.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Category != null ? Category.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Validity.GetHashCode();
         hashCode = (hashCode * 397) ^ (CouponLink != null ? CouponLink.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ New.GetHashCode();
         hashCode = (hashCode * 397) ^ IsPercentage.GetHashCode();
         hashCode = (hashCode * 397) ^ Shipping.GetHashCode();
         return(hashCode);
     }
 }
Beispiel #2
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);
            }
        }