private void btnNext_Click(object sender, System.EventArgs e)
        {
            PromotionInfo promotion = this.promotionView.Promotion;

            if (promotion.MemberGradeIds.Count <= 0)
            {
                this.ShowMsg("必须选择一个适合的客户", false);
                return;
            }
            if (promotion.StartDate.CompareTo(promotion.EndDate) > 0)
            {
                this.ShowMsg("开始日期应该小于结束日期", false);
                return;
            }
            promotion.PromoteType = (PromoteType)int.Parse(this.txtPromoteType.Text);
            decimal condition     = 0m;
            decimal discountValue = 0m;

            decimal.TryParse(this.txtCondition.Text.Trim(), out condition);
            decimal.TryParse(this.txtDiscountValue.Text.Trim(), out discountValue);
            promotion.Condition     = condition;
            promotion.DiscountValue = discountValue;
            int num = SubsitePromoteHelper.AddPromotion(promotion);

            if (num == -1)
            {
                this.ShowMsg("添加促销活动失败,可能是信填写有误,请重试", false);
                return;
            }
            if (num == -2)
            {
                this.ShowMsg("添加促销活动失败,可能是选择的会员等级已经被删除,请重试", false);
                return;
            }
            if (num == 0)
            {
                this.ShowMsg("添加促销活动失败,请重试", false);
                return;
            }
            base.Response.Redirect("SetMyPromotionProducts.aspx?ActivityId=" + num);
        }
        private void btnNext_Click(object sender, EventArgs e)
        {
            PromotionInfo promotion = this.promotionView.Promotion;

            if (promotion.MemberGradeIds.Count <= 0)
            {
                this.ShowMsg("必须选择一个适合的客户", false);
            }
            else if (promotion.StartDate.CompareTo(promotion.EndDate) > 0)
            {
                this.ShowMsg("开始日期应该小于结束日期", false);
            }
            else
            {
                promotion.PromoteType = (PromoteType)int.Parse(this.txtPromoteType.Text);
                decimal result = 0M;
                decimal num2   = 0M;
                decimal.TryParse(this.txtCondition.Text.Trim(), out result);
                decimal.TryParse(this.txtDiscountValue.Text.Trim(), out num2);
                promotion.Condition     = result;
                promotion.DiscountValue = num2;
                int num3 = SubsitePromoteHelper.AddPromotion(promotion);
                switch (num3)
                {
                case -1:
                    this.ShowMsg("添加促销活动失败,可能是信填写有误,请重试", false);
                    return;

                case -2:
                    this.ShowMsg("添加促销活动失败,可能是选择的会员等级已经被删除,请重试", false);
                    return;

                case 0:
                    this.ShowMsg("添加促销活动失败,请重试", false);
                    return;
                }
                base.Response.Redirect("SetMyPromotionProducts.aspx?ActivityId=" + num3);
            }
        }
Esempio n. 3
0
        protected void btnAddFeeFree_Click(object sender, EventArgs e)
        {
            decimal Amount = 0m;

            string str = string.Empty;

            if (ValidateValues(out Amount))
            {
                if (!((chkShipChargeFee.Checked || chkServiceChargeFree.Checked) || chkPackingChargeFree.Checked))
                {
                    str = str + Formatter.FormatErrorMessage("请选择此促销活动要免除的订单费用");
                }
                if (chklMemberGrade.SelectedValue.Count <= 0)
                {
                    str = str + Formatter.FormatErrorMessage("适合的客户必须选择一个");
                }
                if (!addpromoteSales.IsValid)
                {
                    ShowMsg(addpromoteSales.CurrentErrors, false);
                }
                else
                {
                    FullFreeInfo target = new FullFreeInfo();

                    target.Name              = addpromoteSales.Item.Name;
                    target.Description       = addpromoteSales.Item.Description;
                    target.Amount            = Amount;
                    target.ShipChargeFree    = chkShipChargeFee.Checked;
                    target.OptionFeeFree     = chkPackingChargeFree.Checked;
                    target.ServiceChargeFree = chkServiceChargeFree.Checked;
                    target.MemberGradeIds    = chklMemberGrade.SelectedValue;

                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <FullFreeInfo>(target, new string[] { "ValPromotion" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            str = str + Formatter.FormatErrorMessage(result.Message);
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        ShowMsg(str, false);
                    }
                    else
                    {
                        switch (SubsitePromoteHelper.AddPromotion(target))
                        {
                        case PromotionActionStatus.Success:
                            txtAmount.Text               = string.Empty;
                            chkShipChargeFee.Checked     = false;
                            chkPackingChargeFree.Checked = false;
                            chkServiceChargeFree.Checked = false;
                            addpromoteSales.Reset();
                            ShowMsg("成功添加了一个满额免费用促销活动", true);
                            return;

                        case PromotionActionStatus.DuplicateName:
                            ShowMsg("添加促销活动失败,存在相同的促销活动名称", false);
                            return;

                        case PromotionActionStatus.SameCondition:
                            ShowMsg("已经存在相同满足条件的优惠活动", false);
                            return;
                        }
                        txtAmount.Text               = string.Empty;
                        chkShipChargeFee.Checked     = false;
                        chkPackingChargeFree.Checked = false;
                        chkServiceChargeFree.Checked = false;
                        addpromoteSales.Reset();
                        ShowMsg("添加促销活动失败", false);
                    }
                }
            }
        }
Esempio n. 4
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            int    num;
            int    num2;
            string str = string.Empty;

            if (ValidateValues(out num, out num2))
            {
                if (!addpromoteSales.IsValid)
                {
                    ShowMsg(addpromoteSales.CurrentErrors, false);
                }
                else
                {
                    WholesaleDiscountInfo target = new WholesaleDiscountInfo();
                    target.Name                      = addpromoteSales.Item.Name;
                    target.Description               = addpromoteSales.Item.Description;
                    target.Quantity                  = num;
                    target.DiscountValue             = num2;
                    target.MemberGradeIds            = chklMemberGrade.SelectedValue;
                    Session["wholesaleDiscountInfo"] = target;
                    if (chklMemberGrade.SelectedValue.Count <= 0)
                    {
                        str = Formatter.FormatErrorMessage("适合的客户必须选择一个");
                    }
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <WholesaleDiscountInfo>(target, new string[] { "ValPromotion" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            str = str + Formatter.FormatErrorMessage(result.Message);
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        ShowMsg(str, false);
                    }
                    else
                    {
                        switch (SubsitePromoteHelper.AddPromotion(target))
                        {
                        case PromotionActionStatus.Success:
                        {
                            int activeIdByPromotionName = SubsitePromoteHelper.GetActiveIdByPromotionName(target.Name);
                            base.Response.Redirect(Globals.ApplicationPath + "/Shopadmin/promotion/MyPromotionProducts.aspx?ActiveId=" + activeIdByPromotionName, true);
                            return;
                        }

                        case PromotionActionStatus.DuplicateName:
                            ShowMsg("已存在此名称的促销活动", false);
                            return;

                        case PromotionActionStatus.SameCondition:
                            ShowMsg("已经存在相同满足条件的优惠活动", false);
                            return;
                        }
                        ShowMsg("添加促销活动--批发打折错误", false);
                    }
                }
            }
        }
Esempio n. 5
0
        private void btnAddDiscount_Click(object sender, EventArgs e)
        {
            decimal amount   = 0m;
            decimal discount = 0m;
            int     rate     = 0;
            string  str      = string.Empty;

            if (ValidateValues(out amount, out discount, out rate))
            {
                DiscountValueType selectedValue = radioValueType.SelectedValue;
                if (!addpromoteSales.IsValid)
                {
                    ShowMsg(addpromoteSales.CurrentErrors, false);
                }
                else
                {
                    FullDiscountInfo target = new FullDiscountInfo();
                    target.Name        = addpromoteSales.Item.Name;
                    target.Description = addpromoteSales.Item.Description;
                    target.Amount      = amount;
                    target.ValueType   = selectedValue;

                    switch (selectedValue)
                    {
                    case DiscountValueType.Amount:
                    {
                        target.DiscountValue = discount;
                        break;
                    }

                    case DiscountValueType.Percent:
                    {
                        target.DiscountValue = rate;
                        break;
                    }
                    }
                    target.MemberGradeIds = chklMemberGrade.SelectedValue;
                    if (chklMemberGrade.SelectedValue.Count <= 0)
                    {
                        str = str + Formatter.FormatErrorMessage("适合的客户必须选择一个");
                    }
                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <FullDiscountInfo>(target, new string[] { "ValPromotion" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            str = str + Formatter.FormatErrorMessage(result.Message);
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        ShowMsg(str, false);
                    }
                    else
                    {
                        PromotionActionStatus status = SubsitePromoteHelper.AddPromotion(target);
                        switch (status)
                        {
                        case PromotionActionStatus.Success:
                            txtAmount.Text        = string.Empty;
                            txtDiscountValue.Text = string.Empty;
                            addpromoteSales.Reset();
                            ShowMsg("成功添加了促销活动--满额打折", true);
                            return;

                        case PromotionActionStatus.DuplicateName:
                            ShowMsg("已存在此名称的促销活动", false);
                            return;
                        }
                        if (status == PromotionActionStatus.SameCondition)
                        {
                            ShowMsg("已经存在相同满足条件的优惠活动", false);
                        }
                        else
                        {
                            txtAmount.Text        = string.Empty;
                            txtDiscountValue.Text = string.Empty;
                            addpromoteSales.Reset();
                            ShowMsg("添加促销活动--满额打折错误", false);
                        }
                    }
                }
            }
        }