Пример #1
0
 private void btnAddProductType_Click(object sender, EventArgs e)
 {
     ProductTypeInfo productType = new ProductTypeInfo();
     productType.TypeName = txtTypeName.Text.Trim();
     productType.Remark = txtRemark.Text;
     IList<int> list = new List<int>();
     foreach (ListItem item in chlistBrand.Items)
     {
         if (item.Selected)
         {
             list.Add(int.Parse(item.Value));
         }
     }
     productType.Brands = list;
     if (ValidationProductType(productType))
     {
         int num = ProductTypeHelper.AddProductType(productType);
         if (num > 0)
         {
             base.Response.Redirect(Globals.GetAdminAbsolutePath("/product/AddAttribute.aspx?typeId=" + num), true);
         }
         else
         {
             ShowMsg("添加商品类型失败", false);
         }
     }
 }
Пример #2
0
 public int AddProductType(ProductTypeInfo productType)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO Hishop_ProductTypes(TypeName, Remark) VALUES (@TypeName, @Remark); SELECT @@IDENTITY");
     this.database.AddInParameter(sqlStringCommand, "TypeName", DbType.String, productType.TypeName);
     this.database.AddInParameter(sqlStringCommand, "Remark", DbType.String, productType.Remark);
     object obj2 = this.database.ExecuteScalar(sqlStringCommand);
     if (obj2 != null)
     {
         return Convert.ToInt32(obj2);
     }
     return 0;
 }
Пример #3
0
 private bool ValidationProductType(ProductTypeInfo productType)
 {
     ValidationResults results = Hishop.Components.Validation.Validation.Validate<ProductTypeInfo>(productType, new string[] { "ValProductType" });
     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;
 }
Пример #4
0
 public static int AddProductType(ProductTypeInfo productType)
 {
     if (productType == null)
     {
         return 0;
     }
     Globals.EntityCoding(productType, true);
     int typeId = ProductProvider.Instance().AddProductType(productType);
     if (typeId > 0)
     {
         if (productType.Brands.Count > 0)
         {
             ProductProvider.Instance().AddProductTypeBrands(typeId, productType.Brands);
         }
         EventLogs.WriteOperationLog(Privilege.AddProductType, string.Format(CultureInfo.InvariantCulture, "创建了一个新的商品类型:”{0}”", new object[] { productType.TypeName }));
     }
     return typeId;
 }
Пример #5
0
 private void btnEditProductType_Click(object sender, EventArgs e)
 {
     ProductTypeInfo productType = new ProductTypeInfo();
     productType.TypeId = typeId;
     productType.TypeName = txtTypeName.Text;
     productType.Remark = txtRemark.Text;
     IList<int> list = new List<int>();
     foreach (ListItem item in chlistBrand.Items)
     {
         if (item.Selected)
         {
             list.Add(int.Parse(item.Value));
         }
     }
     productType.Brands = list;
     if (ValidationProductType(productType) && ProductTypeHelper.UpdateProductType(productType))
     {
         ShowMsg("修改成功", true);
     }
 }
Пример #6
0
 public bool UpdateProductType(ProductTypeInfo productType)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE Hishop_ProductTypes SET TypeName = @TypeName, Remark = @Remark WHERE TypeId = @TypeId");
     this.database.AddInParameter(sqlStringCommand, "TypeName", DbType.String, productType.TypeName);
     this.database.AddInParameter(sqlStringCommand, "Remark", DbType.String, productType.Remark);
     this.database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, productType.TypeId);
     return (this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Пример #7
0
 public static bool UpdateProductType(ProductTypeInfo productType)
 {
     if (productType == null)
     {
         return false;
     }
     Globals.EntityCoding(productType, true);
     bool flag = ProductProvider.Instance().UpdateProductType(productType);
     if (flag)
     {
         if (ProductProvider.Instance().DeleteProductTypeBrands(productType.TypeId))
         {
             ProductProvider.Instance().AddProductTypeBrands(productType.TypeId, productType.Brands);
         }
         EventLogs.WriteOperationLog(Privilege.EditProductType, string.Format(CultureInfo.InvariantCulture, "修改了编号为”{0}”的商品类型", new object[] { productType.TypeId }));
     }
     return flag;
 }
Пример #8
0
 public override IList<ProductTypeInfo> GetProductTypes()
 {
     IList<ProductTypeInfo> list = new List<ProductTypeInfo>();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_ProductTypes");
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         while (null != reader && reader.Read())
         {
             ProductTypeInfo productTypeInfo = new ProductTypeInfo();
             productTypeInfo.TypeId = (int)reader["TypeId"];
             productTypeInfo.TypeName = (string)reader["TypeName"];
             productTypeInfo.Remark = (string)reader["Remark"];
             list.Add(productTypeInfo);
         }
     }
     return list;
 }
Пример #9
0
 public override ProductTypeInfo GetProductType(int typeId)
 {
     ProductTypeInfo info = new ProductTypeInfo();
     DbCommand sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_ProductTypes WHERE TypeId = @TypeId;SELECT * FROM Hishop_ProductTypeBrands WHERE ProductTypeId = @TypeId");
     database.AddInParameter(sqlStringCommand, "TypeId", DbType.Int32, typeId);
     using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             info.TypeId = (int)reader["TypeId"];
             info.TypeName = (string)reader["TypeName"];
             info.Remark = (string)reader["Remark"];
         }
         IList<int> list = new List<int>();
         reader.NextResult();
         while (reader.Read())
         {
             list.Add((int)reader["BrandId"]);
         }
         info.Brands = list;
     }
     return info;
 }
Пример #10
0
 public static int GetTypeId(string typeName)
 {
     int typeId = new ProductTypeDao().GetTypeId(typeName);
     if (typeId > 0)
     {
         return typeId;
     }
     ProductTypeInfo productType = new ProductTypeInfo {
         TypeName = typeName
     };
     return new ProductTypeDao().AddProductType(productType);
 }
Пример #11
0
 public abstract int AddProductType(ProductTypeInfo productType);
Пример #12
0
 public abstract bool UpdateProductType(ProductTypeInfo productType);