Exemplo n.º 1
0
 private void btnEditDistrbutor_Click(object sender, EventArgs e)
 {
     int num;
     DistributorGradeInfo distributorGrade = new DistributorGradeInfo();
     distributorGrade.Name = txtRankName.Text.Trim();
     distributorGrade.Description = txtRankDesc.Text.Trim();
     distributorGrade.GradeId = gradeId;
     if (!(!int.TryParse(txtValue.Text, out num) || txtValue.Text.Contains(".")))
     {
         distributorGrade.Discount = num;
     }
     else
     {
         ShowMsg("等级折扣必须为正整数", false);
         return;
     }
     if (ValidationMemberGrade(distributorGrade))
     {
         if (DistributorHelper.UpdateDistributorGrade(distributorGrade))
         {
             ShowMsg("修改分销商等级成功", true);
         }
         else
         {
             ShowMsg("修改分销商等级失败", false);
         }
     }
 }
Exemplo n.º 2
0
 private void btnAddDistrbutor_Click(object sender, EventArgs e)
 {
     if (DistributorHelper.ExistGradeName(txtRankName.Text.Trim()))
     {
         ShowMsg("已经存在相同名称的分销商等级", false);
     }
     else
     {
         int num;
         DistributorGradeInfo distributorGrade = new DistributorGradeInfo();
         distributorGrade.Name = txtRankName.Text.Trim();
         distributorGrade.Description = txtRankDesc.Text.Trim();
         if (!(!int.TryParse(txtValue.Text, out num) || txtValue.Text.Contains(".")))
         {
             distributorGrade.Discount = num;
         }
         else
         {
             ShowMsg("等级折扣必须只能为正整数", false);
             return;
         }
         if (ValidationMemberGrade(distributorGrade))
         {
             if (DistributorHelper.AddDistributorGrade(distributorGrade))
             {
                 ResetText();
                 ShowMsg("成功添加了一个分销商等级", true);
             }
             else
             {
                 ShowMsg("添加分销商等级失败", false);
             }
         }
     }
 }
Exemplo n.º 3
0
 public override bool AddDistributorGrade(DistributorGradeInfo distributorGrade)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("INSERT INTO aspnet_DistributorGrades(Name, Description, Discount) VALUES(@Name,@Description,@Discount)");
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, distributorGrade.Name);
     database.AddInParameter(sqlStringCommand, "Description", DbType.String, distributorGrade.Description);
     database.AddInParameter(sqlStringCommand, "Discount", DbType.Int32, distributorGrade.Discount);
     return (database.ExecuteNonQuery(sqlStringCommand) == 1);
 }
Exemplo n.º 4
0
 public static bool AddDistributorGrade(DistributorGradeInfo distributorGrade)
 {
     Globals.EntityCoding(distributorGrade, true);
     bool flag = DistributorProvider.Instance().AddDistributorGrade(distributorGrade);
     if (flag)
     {
         EventLogs.WriteOperationLog(Privilege.AddDistributorGrade, string.Format(CultureInfo.InvariantCulture, "添加了名为 “{0}” 的分销商等级", new object[] { distributorGrade.Name }));
     }
     return flag;
 }
Exemplo n.º 5
0
 private bool ValidationMemberGrade(DistributorGradeInfo distributorGrade)
 {
     ValidationResults results = Hishop.Components.Validation.Validation.Validate<DistributorGradeInfo>(distributorGrade, new string[] { "ValDistributorGrade" });
     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;
 }
Exemplo n.º 6
0
 public static DistributorGradeInfo PopulDistributorGrade(IDataReader reader)
 {
     DistributorGradeInfo info = new DistributorGradeInfo();
     info.GradeId = (int) reader["GradeId"];
     info.Discount = (int) reader["Discount"];
     info.Name = (string) reader["Name"];
     if (reader["Description"] != DBNull.Value)
     {
         info.Description = (string) reader["Description"];
     }
     return info;
 }
Exemplo n.º 7
0
 public abstract bool AddDistributorGrade(DistributorGradeInfo distributorGrade);
Exemplo n.º 8
0
 public abstract bool UpdateDistributorGrade(DistributorGradeInfo distributorGrade);
Exemplo n.º 9
0
 public override bool UpdateDistributorGrade(DistributorGradeInfo distributorGrade)
 {
     DbCommand sqlStringCommand = database.GetSqlStringCommand("UPDATE aspnet_DistributorGrades SET Name =@Name,Description = @Description,Discount = @Discount WHERE GradeId = @GradeId");
     database.AddInParameter(sqlStringCommand, "Name", DbType.String, distributorGrade.Name);
     database.AddInParameter(sqlStringCommand, "Description", DbType.String, distributorGrade.Description);
     database.AddInParameter(sqlStringCommand, "Discount", DbType.Int32, distributorGrade.Discount);
     database.AddInParameter(sqlStringCommand, "GradeId", DbType.Currency, distributorGrade.GradeId);
     return (database.ExecuteNonQuery(sqlStringCommand) == 1);
 }
Exemplo n.º 10
0
 public override DistributorGradeInfo GetDistributorGradeInfo(int gradeId)
 {
     DistributorGradeInfo info = new DistributorGradeInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM aspnet_DistributorGrades WHERE GradeId=@GradeId");
     database.AddInParameter(sqlStringCommand, "GradeId", DbType.Int32, gradeId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info = DataMapper.PopulDistributorGrade(reader);
         }
     }
     return info;
 }