public static bool DeleteProductType(int typeId) { ManagerHelper.CheckPrivilege(Privilege.DeleteProductType); bool flag = new ProductTypeDao().DeleteProducType(typeId); if (flag) { EventLogs.WriteOperationLog(Privilege.DeleteProductType, string.Format(CultureInfo.InvariantCulture, "删除了编号为”{0}”的商品类型", new object[] { typeId })); } return flag; }
public static int AddProductType(ProductTypeInfo productType) { if (productType == null) { return 0; } Globals.EntityCoding(productType, true); int typeId = new ProductTypeDao().AddProductType(productType); if (typeId > 0) { if (productType.Brands.Count > 0) { new ProductTypeDao().AddProductTypeBrands(typeId, productType.Brands); } EventLogs.WriteOperationLog(Privilege.AddProductType, string.Format(CultureInfo.InvariantCulture, "创建了一个新的商品类型:”{0}”", new object[] { productType.TypeName })); } return typeId; }
public static bool UpdateProductType(ProductTypeInfo productType) { if (productType == null) { return false; } Globals.EntityCoding(productType, true); bool flag = new ProductTypeDao().UpdateProductType(productType); if (flag) { if (new ProductTypeDao().DeleteProductTypeBrands(productType.TypeId)) { new ProductTypeDao().AddProductTypeBrands(productType.TypeId, productType.Brands); } EventLogs.WriteOperationLog(Privilege.EditProductType, string.Format(CultureInfo.InvariantCulture, "修改了编号为”{0}”的商品类型", new object[] { productType.TypeId })); } return flag; }
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); }