public bool UpdateProductCount(int CategoryLevel, int CategoryID)
        {
            var svProduct = new Product.ProductService();

            if (CategoryLevel == 3)
            {
                var sqlWhere  = svProduct.CreateWhereAction(ProductAction.FrontEnd) + "AND CateLV3 = " + CategoryID;
                var count     = CountData <view_SearchProduct>(" * ", sqlWhere);
                var sqlUpdate = " ProductCount = " + count;
                sqlWhere = "CategoryLevel = 3 AND CategoryID = " + CategoryID;
                UpdateByCondition <b2bCategory>(sqlUpdate, sqlWhere);
            }
            else if (CategoryLevel == 2)
            {
                var sqlUpdate = " ProductCount = (Select SUM(ProductCount) from b2bCategory where ParentCategoryID = " + CategoryID + " ) ";
                var sqlWhere  = " CategoryID = " + CategoryID;
                UpdateByCondition <b2bCategory>(sqlUpdate, sqlWhere);
            }
            else if (CategoryLevel == 1)
            {
                var sqlUpdate = " ProductCount = (Select SUM(ProductCount) from b2bCategory where ParentCategoryID = " + CategoryID + " ) ";
                var sqlWhere  = " CategoryID = " + CategoryID;
                UpdateByCondition <b2bCategory>(sqlUpdate, sqlWhere);
            }


            return(IsResult);
        }
Exemple #2
0
        public bool UpdateProductCount(int CompID)
        {
            var svProduct = new Product.ProductService();
            var sqlWhere  = svProduct.CreateWhereAction(ProductAction.FrontEnd, CompID);
            var count     = CountData <view_SearchProduct>(" * ", sqlWhere);
            var svCompany = new Company.CompanyService();

            IsResult = svCompany.UpdateByCondition <b2bCompany>(" ProductCount = " + count, "CompID = " + CompID);
            return(IsResult);
        }