protected void SubmitButton_Click(object sender, EventArgs e) { UserGradeInfo userGrade = new UserGradeInfo(); userGrade.Id = RequestHelper.GetQueryString <int>("ID"); userGrade.Name = Name.Text; userGrade.MinMoney = Convert.ToDecimal(MinMoney.Text); userGrade.MaxMoney = Convert.ToDecimal(MaxMoney.Text); userGrade.Discount = Convert.ToDecimal(Discount.Text); if (userGrade.MinMoney >= userGrade.MaxMoney) { ScriptHelper.Alert("等级最高金额必须大于最低金额"); } #region 判断等级范围是否重叠 var gradeList = UserGradeBLL.ReadList().Where(k => k.Id != userGrade.Id).ToList(); if (gradeList.Any(k => (k.MinMoney >= userGrade.MinMoney && k.MaxMoney <= userGrade.MaxMoney) || (k.MinMoney <= userGrade.MinMoney && k.MaxMoney >= userGrade.MaxMoney) || (k.MinMoney < userGrade.MinMoney && k.MaxMoney > userGrade.MinMoney && k.MaxMoney < userGrade.MaxMoney) || (k.MinMoney > userGrade.MinMoney && k.MinMoney < userGrade.MaxMoney && k.MaxMoney > userGrade.MaxMoney))) { ScriptHelper.Alert("等级范围重叠,请重新输入"); } #endregion string alertMessage = ShopLanguage.ReadLanguage("AddOK"); if (userGrade.Id == int.MinValue) { CheckAdminPower("AddUserGrade", PowerCheckType.Single); int id = UserGradeBLL.Add(userGrade); AdminLogBLL.Add(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("UserGrade"), id); } else { CheckAdminPower("UpdateUserGrade", PowerCheckType.Single); UserGradeBLL.Update(userGrade); AdminLogBLL.Add(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("UserGrade"), userGrade.Id); alertMessage = ShopLanguage.ReadLanguage("UpdateOK"); } ScriptHelper.Alert(alertMessage, RequestHelper.RawUrl); }