/// <summary> /// 获取当前店铺商品限定范围的枚举 /// </summary> /// <returns></returns> public static ProductInfo.ProductRanage GetCurrStoreProductRange() { ProductInfo.ProductRanage productRanage = ProductInfo.ProductRanage.NormalSelect; DistributorsInfo currentDistributors = DistributorsBrower.GetCurrentDistributors(); if ((currentDistributors != null) && (currentDistributors.UserId != 0)) { if (Hidistro.Core.SettingsManager.GetMasterSettings(false).EnableStoreProductAuto) { productRanage = ProductInfo.ProductRanage.All; } else if (Hidistro.Core.SettingsManager.GetMasterSettings(false).EnableAgentProductRange) { productRanage = ProductInfo.ProductRanage.RangeSelect; } else { productRanage = ProductInfo.ProductRanage.NormalSelect; } } else { productRanage = ProductInfo.ProductRanage.All; } return(productRanage); }
public static DataTable GetBrandRange(ProductInfo.ProductRanage productRange = ProductInfo.ProductRanage.NormalSelect) { DataTable Brand = HiCache.Get("DataCache-CategoriesRange") as DataTable; if (Brand == null) { Brand = new CategoryDao().GetBrandRange(productRange); HiCache.Insert("DataCache-CategoriesRange", Brand, 360, CacheItemPriority.Normal); } return(Brand); }
public static DataTable GetCategoriesRange(ProductInfo.ProductRanage productRange = ProductInfo.ProductRanage.NormalSelect) { DataTable categories = HiCache.Get("DataCache-CategoriesRange") as DataTable; if (categories == null) { categories = new CategoryDao().GetCategoriesRange(productRange); HiCache.Insert("DataCache-CategoriesRange", categories, 360, CacheItemPriority.Normal); } return(categories); }
private void DataBindSoruce() { //type:0正常显示店铺已上架的商品,1正常显示店铺未上架的商品,2显示所有出售状态的商品,3根据上架范围显示已上架的商品,4根据上架范围显示未上架的商品 ProductInfo.ProductRanage productRanage = DistributorsBrower.GetCurrStoreProductRange(); int num; this.txtkeywords.Value = this.keyWord; this.rpCategorys.DataSource = CategoryBrowser.GetCategories(); this.rpCategorys.DataBind(); this.rpChooseProducts.DataSource = ProductBrowser.GetProductsEx(MemberProcessor.GetCurrentMember(), null, new int?(this.categoryId), this.keyWord, 1, 0x2710, out num, "DisplaySequence", "desc", productRanage); this.rpChooseProducts.DataBind(); }
public static DataTable GetProducts(MemberInfo member, int?topicId, int BrandId, int?categoryId, string keyWord, int pageNumber, int maxNum, out int total, string sort, string order, string swr = "", int rangeType = 0, int storeid = 0) { ProductInfo.ProductRanage productRanage = new ProductInfo.ProductRanage(); //if (!Hidistro.ControlPanel.Config.CustomConfigHelper.Instance.AnonymousOrder) productRanage = DistributorsBrower.GetCurrStoreProductRange(); /* * else//如果匿名点餐功能开启,则获取所有商品 * productRanage = ProductInfo.ProductRanage.All; */ return(new ProductBrowseDao().GetProductsRange(member, topicId, BrandId, categoryId, Globals.GetCurrentDistributorId(), keyWord, pageNumber, maxNum, out total, sort, order == "asc", productRanage, swr, rangeType, storeid)); }
public DataTable GetBrandRange(ProductInfo.ProductRanage productRanage) { string selectSql = "SELECT BrandId,BrandName,Logo,CompanyUrl,RewriteName,MetaKeywords,MetaDescription,Description,DisplaySequence,Theme FROM Hishop_BrandCategories"; selectSql += " Where 1=1 "; switch (productRanage) { case ProductInfo.ProductRanage.RangeSelect: //代理取系统设置的上架范围,分销商取所属代理商的上架范围 int ofAgentID = Globals.GetCurrentDistributorId(); DataTable dtDistributors = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select UserId,IsAgent,AgentPath From aspnet_Distributors Where UserId={0}", ofAgentID)).Tables[0]; if (dtDistributors.Rows[0]["IsAgent"].ToString() != "1" && dtDistributors.Rows[0]["AgentPath"] != DBNull.Value) { ofAgentID = int.Parse(dtDistributors.Rows[0]["AgentPath"].ToString().Split('|')[dtDistributors.Rows[0]["AgentPath"].ToString().Split('|').Length - 1]); } DataTable dtProductRange = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select * From Hishop_DistributorProductRange Where UserId={0}", ofAgentID)).Tables[0]; if (dtProductRange.Rows.Count == 0) { selectSql += " And 1=2 "; //未设置上架范围 } else { DataRow drProductRange = dtProductRange.Rows[0]; if (drProductRange["ProductRange1"] != DBNull.Value) { selectSql += string.Format(" And CategoryId in({0})", drProductRange["ProductRange1"].ToString()); } else { selectSql += " And CategoryId in(null)"; } } break; } DbCommand sqlStringCommand = this.database.GetSqlStringCommand(selectSql + " ORDER BY DisplaySequence"); using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand)) { return(DataHelper.ConverDataReaderToDataTable(reader)); } }
private void DataBindSoruce() { //type:0正常显示店铺已上架的商品,1正常显示店铺未上架的商品,2显示所有出售状态的商品,3根据上架范围显示已上架的商品,4根据上架范围显示未上架的商品 ProductInfo.ProductRanage productRanage = ProductInfo.ProductRanage.NormalUnSelect; bool bStoreProducAuto = Hidistro.Core.SettingsManager.GetMasterSettings(false).EnableStoreProductAuto; bool bAgentProducRange = Hidistro.Core.SettingsManager.GetMasterSettings(true).EnableAgentProductRange; if (bStoreProducAuto) { productRanage = ProductInfo.ProductRanage.All; } else if (bAgentProducRange) { productRanage = ProductInfo.ProductRanage.RangeUnSelect; } int num; this.txtkeywords.Value = this.keyWord; this.rpCategorys.DataSource = CategoryBrowser.GetCategories(); this.rpCategorys.DataBind(); this.rpChooseProducts.DataSource = ProductBrowser.GetProductsEx(MemberProcessor.GetCurrentMember(), null, new int?(this.categoryId), this.keyWord, 1, 0x2710, out num, "DisplaySequence", "desc", productRanage); this.rpChooseProducts.DataBind(); }
/// <summary> /// add by:JHB 150916 获取首页商品信息【根据配置来限定商品的范围】 /// type:0正常显示店铺已上架的商品,1正常显示店铺未上架的商品,2显示所有出售状态的商品,3根据上架范围显示已上架的商品,4根据上架范围显示未上架的商品 /// </summary> public DbQueryResult GetHomeProductsEx(MemberInfo member, ProductQuery query, ProductInfo.ProductRanage productRanage) { int discount = 100; StringBuilder builder = new StringBuilder(); int currentDistributorId = Globals.GetCurrentDistributorId(); builder.Append("MainCategoryPath,ProductId, ProductCode,ShortDescription,ProductName,ShowSaleCounts, ThumbnailUrl60,ThumbnailUrl40,ThumbnailUrl100,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310, MarketPrice,"); if (member != null) { discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount; builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) = 1", member.GradeId); builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = p.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice, ", member.GradeId, discount); } else { builder.Append("SalePrice,"); } builder.Append("SaleCounts, Stock"); StringBuilder builder2 = new StringBuilder(" SaleStatus =" + 1); if (query.CategoryId > 0) { builder2.AppendFormat(" and CategoryId={0}", query.CategoryId); } if (query.TypeId > 0) { builder2.AppendFormat(" and TypeId={0}", query.TypeId); } switch (productRanage) { case ProductInfo.ProductRanage.NormalSelect: //正常显示店铺已上架的商品 builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId); break; case ProductInfo.ProductRanage.All: //显示所有出售状态的商品 break; case ProductInfo.ProductRanage.RangeSelect: //根据上架范围显示已上架的商品 //本身上架的记录 builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId); //代理取系统设置的上架范围,分销商取所属代理商的上架范围 int ofAgentID = currentDistributorId; DataTable dtDistributors = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select UserId,IsAgent,AgentPath From aspnet_Distributors Where UserId={0}", ofAgentID)).Tables[0]; if (dtDistributors.Rows[0]["IsAgent"].ToString() != "1" && dtDistributors.Rows[0]["AgentPath"] != DBNull.Value) { ofAgentID = int.Parse(dtDistributors.Rows[0]["AgentPath"].ToString().Split('|')[dtDistributors.Rows[0]["AgentPath"].ToString().Split('|').Length - 1]); } DataTable dtProductRange = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select * From Hishop_DistributorProductRange Where UserId={0}", ofAgentID)).Tables[0]; if (dtProductRange.Rows.Count == 0) { builder2.AppendFormat(" And 1=2 "); //未设置上架范围 } else { DataRow drProductRange = dtProductRange.Rows[0]; builder2.AppendFormat(" AND ("); if (drProductRange["ProductRange1"] != DBNull.Value) { builder2.AppendFormat(string.Format("CategoryId in({0})", drProductRange["ProductRange1"].ToString())); } else { builder2.AppendFormat("CategoryId in(null)"); } if (drProductRange["ProductRange2"] != DBNull.Value) { builder2.AppendFormat(string.Format(" or BrandId in({0})", drProductRange["ProductRange2"].ToString())); } else { builder2.AppendFormat(" or BrandId in(null)"); } if (drProductRange["ProductRange3"] != DBNull.Value) { builder2.AppendFormat(string.Format(" or TypeId in({0})", drProductRange["ProductRange3"].ToString())); } else { builder2.AppendFormat(" or TypeId in(null)"); } builder2.AppendFormat(")"); } break; } return(DataHelper.PagingByRownumber(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "vw_Hishop_BrowseProductList p", "ProductId", builder2.ToString(), builder.ToString())); }
/// <summary> /// 产品Top显示新增产品类型参数筛选 /// </summary> public DataTable GetHomeProductTop(string top, ProductInfo.ProductTop productTop, ProductInfo.ProductRanage productRanage, int CategoryId) { string where = "Where 1=1"; string order = ""; string topStr = " top " + top + " "; int currentDistributorId = Globals.GetCurrentDistributorId(); switch (productTop) { case ProductInfo.ProductTop.Category: topStr += "a.*,b.name"; where = string.Format(" a left join Hishop_Categories b on a.CategoryId=b.CategoryId where a.CategoryId = {0}", CategoryId); break; default: topStr += "a.*"; break; } switch (productRanage) { case ProductInfo.ProductRanage.NormalSelect: //正常显示店铺已上架的商品 where += string.Format(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId); break; case ProductInfo.ProductRanage.All: //显示所有出售状态的商品 break; case ProductInfo.ProductRanage.RangeSelect: //根据上架范围显示已上架的商品 //本身上架的记录 where += string.Format(" AND a.ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId); //代理取系统设置的上架范围,分销商取所属代理商的上架范围 int ofAgentID = currentDistributorId; DataTable dtDistributors = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select UserId,IsAgent,AgentPath From aspnet_Distributors Where UserId={0}", ofAgentID)).Tables[0]; if (dtDistributors.Rows[0]["IsAgent"].ToString() != "1" && dtDistributors.Rows[0]["AgentPath"] != DBNull.Value) { ofAgentID = int.Parse(dtDistributors.Rows[0]["AgentPath"].ToString().Split('|')[dtDistributors.Rows[0]["AgentPath"].ToString().Split('|').Length - 1]); } DataTable dtProductRange = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select * From Hishop_DistributorProductRange Where UserId={0}", ofAgentID)).Tables[0]; if (dtProductRange.Rows.Count == 0) { where += string.Format(" And 1=2 "); //未设置上架范围 } else { DataRow drProductRange = dtProductRange.Rows[0]; where += string.Format(" AND ("); if (drProductRange["ProductRange1"] != DBNull.Value) { where += string.Format(string.Format("a.CategoryId in({0})", drProductRange["ProductRange1"].ToString())); } else { where += string.Format("a.CategoryId in(null)"); } if (drProductRange["ProductRange2"] != DBNull.Value) { where += string.Format(string.Format(" or a.BrandId in({0})", drProductRange["ProductRange2"].ToString())); } else { where += string.Format(" or a.BrandId in(null)"); } if (drProductRange["ProductRange3"] != DBNull.Value) { where += string.Format(string.Format(" or a.TypeId in({0})", drProductRange["ProductRange3"].ToString())); } else { where += string.Format(" or a.TypeId in(null)"); } where += string.Format(")"); } break; } if (top == "0") { topStr = "count(*)"; } if (top == "0") { order = ""; } string selectSql = string.Format("Select {0} From vw_Hishop_BrowseProductList {1} {2}", topStr, where, order); return(this.database.ExecuteDataSet(CommandType.Text, selectSql).Tables[0]); }
/// <summary> /// 产品Top显示 数据集 /// </summary> public DataTable GetHomeProductTop(int top, ProductInfo.ProductTop productTop, ProductInfo.ProductRanage productRanage) { int currentDistributorId = Globals.GetCurrentDistributorId(); string where = "Where 1=1"; string order = ""; switch (productTop) { case ProductInfo.ProductTop.New: order = " order by AddedDate desc"; break; case ProductInfo.ProductTop.Hot: order = " order by ShowSaleCounts desc"; break; case ProductInfo.ProductTop.Discount: order = " order by (MarketPrice-SalePrice) desc"; break; case ProductInfo.ProductTop.MostLike: order = " order by VistiCounts desc"; break; case ProductInfo.ProductTop.Activity: order = " order by VistiCounts desc"; break; default: order = " order by ShowSaleCounts desc"; break; } switch (productRanage) { case ProductInfo.ProductRanage.NormalSelect: //正常显示店铺已上架的商品 where += string.Format(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId); break; case ProductInfo.ProductRanage.All: //显示所有出售状态的商品 break; case ProductInfo.ProductRanage.RangeSelect: //根据上架范围显示已上架的商品 //本身上架的记录 where += string.Format(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", currentDistributorId); //代理取系统设置的上架范围,分销商取所属代理商的上架范围 int ofAgentID = currentDistributorId; DataTable dtDistributors = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select UserId,IsAgent,AgentPath From aspnet_Distributors Where UserId={0}", ofAgentID)).Tables[0]; if (dtDistributors.Rows[0]["IsAgent"].ToString() != "1" && dtDistributors.Rows[0]["AgentPath"] != DBNull.Value) { ofAgentID = int.Parse(dtDistributors.Rows[0]["AgentPath"].ToString().Split('|')[dtDistributors.Rows[0]["AgentPath"].ToString().Split('|').Length - 1]); } DataTable dtProductRange = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select * From Hishop_DistributorProductRange Where UserId={0}", ofAgentID)).Tables[0]; if (dtProductRange.Rows.Count == 0) { where += string.Format(" And 1=2 "); //未设置上架范围 } else { DataRow drProductRange = dtProductRange.Rows[0]; where += string.Format(" AND ("); if (drProductRange["ProductRange1"] != DBNull.Value) { where += string.Format(string.Format("CategoryId in({0})", drProductRange["ProductRange1"].ToString())); } else { where += string.Format("CategoryId in(null)"); } if (drProductRange["ProductRange2"] != DBNull.Value) { where += string.Format(string.Format(" or BrandId in({0})", drProductRange["ProductRange2"].ToString())); } else { where += string.Format(" or BrandId in(null)"); } if (drProductRange["ProductRange3"] != DBNull.Value) { where += string.Format(string.Format(" or TypeId in({0})", drProductRange["ProductRange3"].ToString())); } else { where += string.Format(" or TypeId in(null)"); } where += string.Format(")"); } break; } string topStr = (top == 0) ? "count(*)" : string.Format("top {0} *", top); if (top == 0) { order = ""; } string selectSql = string.Format("Select {0} From vw_Hishop_BrowseProductList {1} {2}", topStr, where, order); return(this.database.ExecuteDataSet(CommandType.Text, selectSql).Tables[0]); }
/// <summary> /// 根据限定范围获取商品分类 /// </summary> public static IList <CategoryInfo> GetMaxSubCategoriesRange(int parentCategoryId, int maxNum = 0x3e8, ProductInfo.ProductRanage productRange = ProductInfo.ProductRanage.NormalSelect) { IList <CategoryInfo> list = new List <CategoryInfo>(); DataRow[] rowArray = GetCategoriesRange(productRange).Select("ParentCategoryId = " + parentCategoryId); for (int i = 0; (i < maxNum) && (i < rowArray.Length); i++) { list.Add(DataMapper.ConvertDataRowToProductCategory(rowArray[i])); } return(list); }
public static DataTable GetAllCategoriesRange(ProductInfo.ProductRanage productRange = ProductInfo.ProductRanage.NormalSelect) { return(new CategoryDao().GetCategoriesRange(productRange)); }
//卡拉萌购 public static IList <BrandCategoryInfo> GetBrandCategory(int BrandId, int maxNum = 0x3e8, ProductInfo.ProductRanage productRange = ProductInfo.ProductRanage.NormalSelect) { IList <BrandCategoryInfo> list = new List <BrandCategoryInfo>(); DataRow[] rowArray = GetBrandRange(productRange).Select("BrandId= " + BrandId); for (int i = 0; (i < maxNum) && (i < rowArray.Length); i++) { list.Add(DataMapper.ConvertDataRowToBrandID(rowArray[i])); } return(list); }
/// <summary> /// up by:JHB 150916 店铺上架商品,根据配置来限定范围 /// type:0正常显示店铺已上架的商品,1正常显示店铺未上架的商品,2显示所有出售状态的商品,3根据上架范围显示已上架的商品,4根据上架范围显示未上架的商品 /// </summary> public static DataTable GetProductsEx(MemberInfo member, int?topicId, int?categoryId, string keyWord, int pageNumber, int maxNum, out int total, string sort, string order, ProductInfo.ProductRanage productRanage) { DataTable table = new DataTable(); int toal = 0; int currentDistributorId = Globals.GetCurrentDistributorId(); if (currentDistributorId > 0) { table = new ProductBrowseDao().GetProductsEx(member, topicId, categoryId, currentDistributorId, keyWord, pageNumber, maxNum, out toal, sort, order == "asc", productRanage); } total = toal; return(table); }
/// <summary> /// add by:JHB 150916 店铺上架商品,根据配置来限定范围 /// type:0正常显示店铺已上架的商品,1正常显示店铺未上架的商品,2显示所有出售状态的商品,3根据上架范围显示已上架的商品,4根据上架范围显示未上架的商品 /// </summary> public DataTable GetProductsEx(MemberInfo member, int?topicId, int?categoryId, int distributorId, string keyWord, int pageNumber, int maxNum, out int toal, string sort, bool isAsc = false , ProductInfo.ProductRanage productRanage = ProductInfo.ProductRanage.NormalSelect) { int discount = 100; StringBuilder builder = new StringBuilder(); builder.AppendFormat("ProductId,ProductName,ProductCode,ShowSaleCounts AS SaleCounts,ShortDescription,", maxNum); builder.Append(" ThumbnailUrl60,ThumbnailUrl100,ThumbnailUrl160,ThumbnailUrl180,ThumbnailUrl220,ThumbnailUrl310,MarketPrice,VistiCounts,"); if (member != null) { discount = new MemberGradeDao().GetMemberGrade(member.GradeId).Discount; builder.AppendFormat(" (CASE WHEN (SELECT COUNT(*) FROM Hishop_SKUMemberPrice WHERE SkuId = vw_Hishop_BrowseProductList.SkuId AND GradeId = {0}) = 1", member.GradeId); builder.AppendFormat(" THEN (SELECT MemberSalePrice FROM Hishop_SKUMemberPrice WHERE SkuId = vw_Hishop_BrowseProductList.SkuId AND GradeId = {0}) ELSE SalePrice*{1}/100 END) AS SalePrice", member.GradeId, discount); } else { builder.Append("SalePrice"); } StringBuilder builder2 = new StringBuilder(); builder2.Append(" SaleStatus=1"); if (topicId.HasValue) { builder2.AppendFormat(" AND ProductId IN (SELECT RelatedProductId FROM Vshop_RelatedTopicProducts WHERE TopicId = {0})", topicId.Value); } if (categoryId.HasValue) { CategoryInfo category = new CategoryDao().GetCategory(categoryId.Value); if (category != null) { builder2.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path); } } if (!string.IsNullOrEmpty(keyWord)) { builder2.AppendFormat(" AND (ProductName LIKE '%{0}%' OR ProductCode LIKE '%{0}%')", keyWord); } switch (productRanage) { case ProductInfo.ProductRanage.NormalSelect: //正常显示店铺已上架的商品 builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", distributorId); break; case ProductInfo.ProductRanage.NormalUnSelect: //正常显示店铺未上架的商品 builder2.AppendFormat(" AND ProductId NOT IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", distributorId); break; case ProductInfo.ProductRanage.All: //显示所有出售状态的商品 break; case ProductInfo.ProductRanage.RangeSelect: //根据上架范围显示已上架的商品 //本身上架的记录 builder2.AppendFormat(" AND ProductId IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", distributorId); //代理取系统设置的上架范围,分销商取所属代理商的上架范围 int ofAgentID = distributorId; DataTable dtDistributors = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select UserId,IsAgent,AgentPath From aspnet_Distributors Where UserId={0}", ofAgentID)).Tables[0]; if (dtDistributors.Rows[0]["IsAgent"].ToString() != "1" && dtDistributors.Rows[0]["AgentPath"] != DBNull.Value) { ofAgentID = int.Parse(dtDistributors.Rows[0]["AgentPath"].ToString().Split('|')[dtDistributors.Rows[0]["AgentPath"].ToString().Split('|').Length - 1]); } DataTable dtProductRange = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select * From Hishop_DistributorProductRange Where UserId={0}", ofAgentID)).Tables[0]; if (dtProductRange.Rows.Count == 0) { builder2.AppendFormat(" And 1=2 "); //未设置上架范围 } else { DataRow drProductRange = dtProductRange.Rows[0]; builder2.AppendFormat(" AND ("); if (drProductRange["ProductRange1"] != DBNull.Value) { builder2.AppendFormat(string.Format("CategoryId in({0})", drProductRange["ProductRange1"].ToString())); } else { builder2.AppendFormat("CategoryId in(null)"); } if (drProductRange["ProductRange2"] != DBNull.Value) { builder2.AppendFormat(string.Format(" or BrandId in({0})", drProductRange["ProductRange2"].ToString())); } else { builder2.AppendFormat(" or BrandId in(null)"); } if (drProductRange["ProductRange3"] != DBNull.Value) { builder2.AppendFormat(string.Format(" or TypeId in({0})", drProductRange["ProductRange3"].ToString())); } else { builder2.AppendFormat(" or TypeId in(null)"); } builder2.AppendFormat(")"); } break; case ProductInfo.ProductRanage.RangeUnSelect: //根据上架范围显示未上架的商品 //本身上架的记录 builder2.AppendFormat(" AND ProductId Not IN (SELECT ProductId FROM Hishop_DistributorProducts WHERE UserId={0})", distributorId); //代理取系统设置的上架范围,分销商取所属代理商的上架范围 int ofAgentIDUn = distributorId; DataTable dtDistributorsUn = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select UserId,IsAgent,AgentPath From aspnet_Distributors Where UserId={0}", ofAgentIDUn)).Tables[0]; if (dtDistributorsUn.Rows[0]["IsAgent"].ToString() != "1" && dtDistributorsUn.Rows[0]["AgentPath"] != DBNull.Value) { ofAgentIDUn = int.Parse(dtDistributorsUn.Rows[0]["AgentPath"].ToString().Split('|')[dtDistributorsUn.Rows[0]["AgentPath"].ToString().Split('|').Length - 1]); } DataTable dtProductRangeUn = this.database.ExecuteDataSet(CommandType.Text, string.Format("Select * From Hishop_DistributorProductRange Where UserId={0}", ofAgentIDUn)).Tables[0]; if (dtProductRangeUn.Rows.Count == 0) { builder2.AppendFormat(" And 1=2 "); //未设置上架范围 } else { DataRow drProductRange = dtProductRangeUn.Rows[0]; builder2.AppendFormat(" AND ("); if (drProductRange["ProductRange1"] != DBNull.Value) { builder2.AppendFormat(string.Format("CategoryId in({0})", drProductRange["ProductRange1"].ToString())); } else { builder2.AppendFormat("CategoryId in(null)"); } if (drProductRange["ProductRange2"] != DBNull.Value) { builder2.AppendFormat(string.Format(" or BrandId in({0})", drProductRange["ProductRange2"].ToString())); } else { builder2.AppendFormat(" or BrandId in(null)"); } if (drProductRange["ProductRange3"] != DBNull.Value) { builder2.AppendFormat(string.Format(" or TypeId in({0})", drProductRange["ProductRange3"].ToString())); } else { builder2.AppendFormat(" or TypeId in(null)"); } builder2.AppendFormat(")"); } break; } if (string.IsNullOrWhiteSpace(sort)) { sort = "ProductId"; } DbQueryResult result = DataHelper.PagingByRownumber(pageNumber, maxNum, sort, isAsc ? SortAction.Asc : SortAction.Desc, true, "vw_Hishop_BrowseProductList", "ProductId", builder2.ToString(), builder.ToString()); DataTable data = (DataTable)result.Data; toal = result.TotalRecords; return(data); }