Beispiel #1
0
 public bool HasSamePointMemberGrade(MemberGradeInfo memberGrade)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT COUNT(GradeId) as Count FROM aspnet_MemberGrades WHERE Points=@Points AND GradeId<>@GradeId;");
     this.database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, memberGrade.Points);
     this.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, memberGrade.GradeId);
     return (((int) this.database.ExecuteScalar(sqlStringCommand)) > 0);
 }
Beispiel #2
0
 private void btnSubmitMemberRanks_Click(object sender, EventArgs e)
 {
     string str = string.Empty;
     if (this.txtValue.Text.Trim().Contains("."))
     {
         this.ShowMsg("折扣必须为正整数", false);
     }
     else
     {
         int num;
         int num2;
         MemberGradeInfo memberGrade = new MemberGradeInfo {
             GradeId = this.gradeId,
             Name = this.txtRankName.Text.Trim(),
             Description = this.txtRankDesc.Text.Trim()
         };
         if (int.TryParse(this.txtPoint.Text.Trim(), out num))
         {
             memberGrade.Points = num;
         }
         else
         {
             str = str + Formatter.FormatErrorMessage("积分设置无效或不能为空,必须大于等于0的整数");
         }
         if (int.TryParse(this.txtValue.Text, out num2))
         {
             memberGrade.Discount = num2;
         }
         else
         {
             str = str + Formatter.FormatErrorMessage("等级折扣设置无效或不能为空,等级折扣必须在1-10之间");
         }
         if (!string.IsNullOrEmpty(str))
         {
             this.ShowMsg(str, false);
         }
         else if (this.ValidationMemberGrade(memberGrade))
         {
             if (MemberHelper.HasSamePointMemberGrade(memberGrade))
             {
                 this.ShowMsg("已经存在相同积分的等级,每个会员等级的积分不能相同", false);
             }
             else if (MemberHelper.UpdateMemberGrade(memberGrade))
             {
                 this.ShowMsg("修改会员等级成功", true);
             }
             else
             {
                 this.ShowMsg("修改会员等级失败", false);
             }
         }
     }
 }
Beispiel #3
0
 private void btnSubmitMemberRanks_Click(object sender, EventArgs e)
 {
     string str = string.Empty;
     if (txtValue.Text.Trim().Contains("."))
     {
         ShowMsg("折扣必须为正整数", false);
     }
     else
     {
         int num;
         int num2;
         MemberGradeInfo memberGrade = new MemberGradeInfo();
         memberGrade.Name = txtRankName.Text.Trim();
         memberGrade.Description = txtRankDesc.Text.Trim();
         if (int.TryParse(txtPoint.Text.Trim(), out num))
         {
             memberGrade.Points = num;
         }
         else
         {
             str = str + Formatter.FormatErrorMessage("积分设置无效或不能为空,必须大于等于0的整数");
         }
         memberGrade.IsDefault = chkIsDefault.SelectedValue;
         if (int.TryParse(txtValue.Text, out num2))
         {
             memberGrade.Discount = num2;
         }
         else
         {
             str = str + Formatter.FormatErrorMessage("等级折扣设置无效或不能为空,等级折扣必须在1-10之间");
         }
         if (!string.IsNullOrEmpty(str))
         {
             ShowMsg(str, false);
         }
         else if (ValidationMemberGrade(memberGrade))
         {
             if (MemberHelper.HasSamePointMemberGrade(memberGrade))
             {
                 ShowMsg("已经存在相同积分的等级,每个会员等级的积分不能相同", false);
             }
             else if (MemberHelper.CreateMemberGrade(memberGrade))
             {
                 ShowMsg("成功添加了一个会员等级", true);
             }
             else
             {
                 ShowMsg("添加会员等级失败", false);
             }
         }
     }
 }
Beispiel #4
0
 public static bool CreateMemberGrade(MemberGradeInfo memberGrade)
 {
     if (null == memberGrade)
     {
         return false;
     }
     Globals.EntityCoding(memberGrade, true);
     bool flag = new MemberGradeDao().CreateMemberGrade(memberGrade);
     if (flag)
     {
         EventLogs.WriteOperationLog(Privilege.AddMemberGrade, string.Format(CultureInfo.InvariantCulture, "添加了名为 “{0}” 的会员等级", new object[] { memberGrade.Name }));
     }
     return flag;
 }
Beispiel #5
0
 private bool ValidationMemberGrade(MemberGradeInfo memberGrade)
 {
     ValidationResults results = Hishop.Components.Validation.Validation.Validate<MemberGradeInfo>(memberGrade, new string[] { "ValMemberGrade" });
     string msg = string.Empty;
     if (!results.IsValid)
     {
         foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
         {
             msg = msg + Formatter.FormatErrorMessage(result.Message);
         }
         ShowMsg(msg, false);
     }
     return results.IsValid;
 }
Beispiel #6
0
 public bool CreateMemberGrade(MemberGradeInfo memberGrade)
 {
     string query = string.Empty;
     if (memberGrade.IsDefault)
     {
         query = query + "UPDATE aspnet_MemberGrades SET IsDefault = 0";
     }
     query = query + " INSERT INTO aspnet_MemberGrades ([Name], Description, Points, IsDefault, Discount) VALUES (@Name, @Description, @Points, @IsDefault, @Discount)";
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
     this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, memberGrade.Name);
     this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, memberGrade.Description);
     this.database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, memberGrade.Points);
     this.database.AddInParameter(sqlStringCommand, "IsDefault", DbType.Boolean, memberGrade.IsDefault);
     this.database.AddInParameter(sqlStringCommand, "Discount", DbType.Int32, memberGrade.Discount);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Beispiel #7
0
 public override bool CreateUnderlingGrade(MemberGradeInfo underlingGrade)
 {
     StringBuilder builder = new StringBuilder();
     if (underlingGrade.IsDefault)
     {
         builder.AppendFormat("UPDATE distro_MemberGrades SET IsDefault = 0 WHERE CreateUserId = {0};", HiContext.Current.User.UserId);
     }
     builder.AppendFormat("INSERT INTO distro_MemberGrades(CreateUserId, [Name], Description, Points, IsDefault, Discount) VALUES (@CreateUserId, @Name, @Description, @Points, @IsDefault, @Discount);", new object[0]);
     DbCommand sqlStringCommand = database.GetSqlStringCommand(builder.ToString());
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, underlingGrade.Name);
     database.AddInParameter(sqlStringCommand, "Description", DbType.String, underlingGrade.Description);
     database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, underlingGrade.Points);
     database.AddInParameter(sqlStringCommand, "IsDefault", DbType.Boolean, underlingGrade.IsDefault);
     database.AddInParameter(sqlStringCommand, "Discount", DbType.Currency, underlingGrade.Discount);
     database.AddInParameter(sqlStringCommand, "CreateUserId", DbType.Int32, HiContext.Current.User.UserId);
     return (database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Beispiel #8
0
 public static bool CreateUnderlingGrade(MemberGradeInfo underlingGrade)
 {
     Globals.EntityCoding(underlingGrade, true);
     return UnderlingProvider.Instance().CreateUnderlingGrade(underlingGrade);
 }
Beispiel #9
0
 public static bool HasSamePointMemberGrade(MemberGradeInfo memberGrade)
 {
     return UnderlingProvider.Instance().HasSamePointMemberGrade(memberGrade);
 }
Beispiel #10
0
 public static MemberGradeInfo PopulateMemberGrade(IDataReader reader)
 {
     if (null == reader)
     {
         return null;
     }
     MemberGradeInfo info = new MemberGradeInfo();
     info.GradeId = (int) reader["GradeId"];
     info.Name = (string) reader["Name"];
     if (reader["Description"] != DBNull.Value)
     {
         info.Description = (string) reader["Description"];
     }
     info.Points = (int) reader["Points"];
     info.IsDefault = (bool) reader["IsDefault"];
     info.Discount = (int) reader["Discount"];
     return info;
 }
Beispiel #11
0
 public static bool HasSamePointMemberGrade(MemberGradeInfo memberGrade)
 {
     return new MemberGradeDao().HasSamePointMemberGrade(memberGrade);
 }
Beispiel #12
0
 public abstract bool UpdateMemberGrade(MemberGradeInfo memberGrade);
Beispiel #13
0
 public static bool UpdateMemberGrade(MemberGradeInfo memberGrade)
 {
     if (null == memberGrade)
     {
         return false;
     }
     Globals.EntityCoding(memberGrade, true);
     bool flag = MemberProvider.Instance().UpdateMemberGrade(memberGrade);
     if (flag)
     {
         EventLogs.WriteOperationLog(Privilege.EditMemberGrade, string.Format(CultureInfo.InvariantCulture, "修改了编号为 “{0}” 的会员等级", new object[] { memberGrade.GradeId }));
     }
     return flag;
 }
Beispiel #14
0
 public override bool UpdateUnderlingGrade(MemberGradeInfo underlingGrade)
 {
     string query = "UPDATE distro_MemberGrades SET [Name] = @Name, Description = @Description, Points = @Points, Discount = @Discount WHERE GradeId = @GradeId;";
     DbCommand sqlStringCommand = database.GetSqlStringCommand(query);
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, underlingGrade.Name);
     database.AddInParameter(sqlStringCommand, "Description", DbType.String, underlingGrade.Description);
     database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, underlingGrade.Points);
     database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, underlingGrade.GradeId);
     database.AddInParameter(sqlStringCommand, "Discount", DbType.Currency, underlingGrade.Discount);
     return (database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Beispiel #15
0
 public override bool HasSamePointMemberGrade(MemberGradeInfo memberGrade)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand(string.Format("SELECT COUNT(GradeId) as Count FROM distro_MemberGrades WHERE Points=@Points AND CreateUserId = {0} AND GradeId<>@GradeId;", HiContext.Current.User.UserId));
     database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, memberGrade.Points);
     database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, memberGrade.GradeId);
     return (((int)database.ExecuteScalar(sqlStringCommand)) > 0);
 }
Beispiel #16
0
 public bool UpdateMemberGrade(MemberGradeInfo memberGrade)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_MemberGrades SET [Name] = @Name, Description = @Description, Points = @Points, Discount = @Discount WHERE GradeId = @GradeId");
     this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, memberGrade.Name);
     this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, memberGrade.Description);
     this.database.AddInParameter(sqlStringCommand, "Points", DbType.Int32, memberGrade.Points);
     this.database.AddInParameter(sqlStringCommand, "Discount", DbType.Int32, memberGrade.Discount);
     this.database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, memberGrade.GradeId);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Beispiel #17
0
 public abstract bool HasSamePointMemberGrade(MemberGradeInfo memberGrade);
Beispiel #18
0
 public abstract bool UpdateUnderlingGrade(MemberGradeInfo underlingGrade);