Пример #1
0
        private void SaveData(HttpContext context)
        {
            int     num  = context.Request["GradeId"].ToInt(0);
            string  name = Globals.StripAllTags(context.Request["GradeName"].ToNullString());
            decimal num2 = context.Request["CommissionThreshold"].ToDecimal(0);
            bool    flag = false;

            if (num2 < decimal.Zero)
            {
                throw new HidistroAshxException("佣金门槛金额必须大于等于0!");
            }
            ReferralGradeInfo referralGradeInfo = new ReferralGradeInfo();

            if (num == 0)
            {
                flag = true;
                if (!ManagerHelper.CheckAdminPrivilege(Privilege.AddReferralGrade))
                {
                    throw new HidistroAshxException("对不起,您没有添加分销员等级的权限!");
                }
            }
            else
            {
                if (!ManagerHelper.CheckAdminPrivilege(Privilege.EditReferralGrade))
                {
                    throw new HidistroAshxException("对不起,您没有编辑分销员等级的权限!");
                }
                referralGradeInfo = MemberProcessor.GetReferralGradeInfo(num);
                if (referralGradeInfo == null)
                {
                    throw new HidistroAshxException("错误的分销员等级ID!");
                }
            }
            if (MemberProcessor.HasSameCommissionThresholdGrade(num2, num))
            {
                throw new HidistroAshxException("佣金门槛不能和其他分销等级相同!");
            }
            referralGradeInfo.CommissionThreshold = num2;
            referralGradeInfo.Name = name;
            if (flag)
            {
                if (MemberProcessor.AddReferralGrade(referralGradeInfo))
                {
                    base.ReturnSuccessResult(context, "添加成功!", 0, true);
                    return;
                }
                throw new HidistroAshxException("添加分销员等级失败!");
            }
            if (MemberProcessor.UpdateReferralGrade(referralGradeInfo))
            {
                base.ReturnSuccessResult(context, "保存成功!", 0, true);
                return;
            }
            throw new HidistroAshxException("编辑分销员等级失败!");
        }
Пример #2
0
        private void btnSubmitReferralGrades_Click(object sender, EventArgs e)
        {
            string            empty             = string.Empty;
            ReferralGradeInfo referralGradeInfo = new ReferralGradeInfo();

            referralGradeInfo.Name = Globals.StripAllTags(this.txtGradeName.Text.Trim());
            referralGradeInfo.CommissionThreshold = this.txtCommissionThreshold.Text.ToDecimal(0);
            if (referralGradeInfo.Name.Length <= 0 || referralGradeInfo.Name.Length > 8)
            {
                this.ShowMsg("请输入等级名称,长度在1-8个字符之间", false);
            }
            else if (referralGradeInfo.CommissionThreshold < decimal.Zero || referralGradeInfo.CommissionThreshold > 99999m)
            {
                this.ShowMsg("佣金门槛金额必须在0-99999之间", false);
            }
            else if (MemberProcessor.HasSameCommissionThresholdGrade(referralGradeInfo.CommissionThreshold, 0))
            {
                this.ShowMsg("已存在相同的佣金门槛金额!", false);
            }
            else
            {
                IList <ReferralGradeInfo> referralGrades = MemberProcessor.GetReferralGrades();
                if (referralGrades != null && referralGrades.Count() >= 10)
                {
                    this.ShowMsg("分销员等级数量不能超过10个!", false);
                }
                else if (MemberProcessor.AddReferralGrade(referralGradeInfo))
                {
                    this.ShowMsg("成功添加了一个分销员等级", true);
                }
                else
                {
                    this.ShowMsg("添加会员等级失败", false);
                }
            }
        }