Exemplo n.º 1
0
        public static int AddProductType(ProductTypeInfo productType)
        {
            int result;

            if (productType == null)
            {
                result = 0;
            }
            else
            {
                ProductTypeDao productTypeDao = new ProductTypeDao();
                Globals.EntityCoding(productType, true);
                int num = productTypeDao.AddProductType(productType);
                if (num > 0)
                {
                    if (productType.Brands.Count > 0)
                    {
                        productTypeDao.AddProductTypeBrands(num, productType.Brands);
                    }
                    EventLogs.WriteOperationLog(Privilege.AddProductType, string.Format(CultureInfo.InvariantCulture, "创建了一个新的商品类型:”{0}”", new object[]
                    {
                        productType.TypeName
                    }));
                }
                result = num;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static int GetTypeId(string typeName)
        {
            ProductTypeDao productTypeDao = new ProductTypeDao();
            int            typeId         = productTypeDao.GetTypeId(typeName);
            int            result;

            if (typeId > 0)
            {
                result = typeId;
            }
            else
            {
                result = productTypeDao.AddProductType(new ProductTypeInfo
                {
                    TypeName = typeName
                });
            }
            return(result);
        }