protected ProductBrowseQuery GetProductBrowseQuery() { ProductBrowseQuery productBrowseQuery = new ProductBrowseQuery(); if (!string.IsNullOrEmpty(base.GetParameter("categoryId", false))) { int num = 0; if (int.TryParse(base.GetParameter("categoryId", false), out num)) { productBrowseQuery.Category = CatalogHelper.GetCategory(num); } } int value = default(int); if (int.TryParse(base.GetParameter("brand", false), out value)) { productBrowseQuery.BrandId = value; } if (!string.IsNullOrEmpty(base.GetParameter("valueStr", false))) { IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); string textToFormat = Globals.UrlDecode(base.GetParameter("valueStr", false)); textToFormat = Globals.HtmlEncode(textToFormat); textToFormat = Globals.StripAllTags(textToFormat); string[] array = textToFormat.Split('-'); if (!string.IsNullOrEmpty(textToFormat)) { for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('_'); if (array2.Length != 0 && !string.IsNullOrEmpty(array2[1]) && array2[1] != "0") { AttributeValueInfo attributeValueInfo = new AttributeValueInfo(); attributeValueInfo.AttributeId = Convert.ToInt32(array2[0]); attributeValueInfo.ValueId = Convert.ToInt32(array2[1]); list.Add(attributeValueInfo); } } } productBrowseQuery.AttributeValues = list; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isPrecise"])) { productBrowseQuery.IsPrecise = bool.Parse(Globals.UrlDecode(this.Page.Request.QueryString["isPrecise"])); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["keywords"])) { productBrowseQuery.Keywords = DataHelper.CleanSearchString(Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["keywords"]))); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["minSalePrice"])) { decimal value2 = default(decimal); if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["minSalePrice"]), out value2)) { productBrowseQuery.MinSalePrice = value2; } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["maxSalePrice"])) { decimal value3 = default(decimal); if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["maxSalePrice"]), out value3)) { productBrowseQuery.MaxSalePrice = value3; } } string safeIDList = Globals.GetSafeIDList(Globals.UrlDecode(this.Page.Request.QueryString["TagIds"].ToNullString()), '_', true); if (!string.IsNullOrEmpty(safeIDList)) { productBrowseQuery.TagIds = safeIDList; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"])) { productBrowseQuery.ProductCode = Globals.StripAllTags(Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["productCode"]))); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["CanUseProducts"])) { productBrowseQuery.CanUseProducts = DataHelper.CleanSearchString(Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["CanUseProducts"]))); } productBrowseQuery.PageIndex = this.pager.PageIndex; productBrowseQuery.PageSize = this.pager.PageSize; string text = productBrowseQuery.SortBy = Globals.GetSafeSortField(this.allowFields, this.Page.Request.QueryString["sortOrderBy"].ToNullString(), "DisplaySequence"); string safeSortOrder = Globals.GetSafeSortOrder(this.Page.Request.QueryString["sortOrder"].ToNullString(), "Desc"); productBrowseQuery.SortOrder = (SortAction)Enum.Parse(typeof(SortAction), safeSortOrder); Globals.EntityCoding(productBrowseQuery, true); return(productBrowseQuery); }
public static DbQueryResult GetCurrActiveOneProductList(ProductBrowseQuery query) { return(new PCActiveDao().GetCurrActiveOneProductList(query)); }
public static DbQueryResult GetBrowseProductList(ProductBrowseQuery query) { return(new ProductBrowseDao().GetBrowseProductList(query)); }
public override DbQueryResult GetCountDownProductList(ProductBrowseQuery query) { string filter = string.Format(" datediff(hh,EndDate,getdate())<0 AND ProductId IN(SELECT ProductId FROM Hishop_Products WHERE SaleStatus={0})", 1); return(DataHelper.PagingByTopsort(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "vw_Hishop_CountDown", "CountDownId", filter, "*")); }
public abstract DataSet GetGroupByProductList(ProductBrowseQuery query, out int count);
protected ProductBrowseQuery GetCurrProductBrowseQuery() { ProductBrowseQuery productBrowseQuery = new ProductBrowseQuery(); if (!string.IsNullOrWhiteSpace(this.Page.Request.QueryString["categoryId"])) { productBrowseQuery.StrCategoryId = this.Page.Request.QueryString["categoryId"]; } if (!string.IsNullOrWhiteSpace(this.Page.Request.QueryString["brand"])) { productBrowseQuery.StrBrandId = this.Page.Request.QueryString["brand"]; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"])) { System.Collections.Generic.IList <AttributeValueInfo> list = new System.Collections.Generic.List <AttributeValueInfo>(); string text = Globals.UrlDecode(this.Page.Request.QueryString["valueStr"]); text = Globals.HtmlEncode(text); string[] array = text.Split(new char[] { '-' }); if (!string.IsNullOrEmpty(text)) { for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[] { '_' }); if (array2.Length > 0 && !string.IsNullOrEmpty(array2[1]) && array2[1] != "0") { list.Add(new AttributeValueInfo { AttributeId = System.Convert.ToInt32(array2[0]), ValueId = System.Convert.ToInt32(array2[1]) }); } } } productBrowseQuery.AttributeValues = list; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isPrecise"])) { productBrowseQuery.IsPrecise = bool.Parse(Globals.UrlDecode(this.Page.Request.QueryString["isPrecise"])); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["keywords"])) { productBrowseQuery.Keywords = DataHelper.CleanSearchString(Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["keywords"]))); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["subKeywords"])) { productBrowseQuery.SubKeywords = DataHelper.CleanSearchString(Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["SubKeywords"]))); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["minSalePrice"])) { decimal value3 = 0m; if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["minSalePrice"]), out value3)) { productBrowseQuery.MinSalePrice = new decimal?(value3); } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["maxSalePrice"])) { decimal value4 = 0m; if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["maxSalePrice"]), out value4)) { productBrowseQuery.MaxSalePrice = new decimal?(value4); } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["TagIds"])) { productBrowseQuery.TagIds = Globals.UrlDecode(this.Page.Request.QueryString["TagIds"]); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"])) { productBrowseQuery.ProductCode = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["productCode"])); } if (!string.IsNullOrWhiteSpace(this.Page.Request.QueryString["importsourceid"]))//新增原产地 { productBrowseQuery.StrImportsourceId = this.Page.Request.QueryString["importsourceid"]; } productBrowseQuery.PageIndex = this.pager == null ? 1 : this.pager.PageIndex; productBrowseQuery.PageSize = this.pager == null ? 5 : this.pager.PageSize; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrderBy"])) { string key = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["sortOrderBy"])); switch (key) { case "SalePrice": break; case "ShowSaleCounts": break; case "AddedDate": break; case "DisplaySequence": break; default: key = "DisplaySequence"; break; } productBrowseQuery.SortBy = Globals.HtmlEncode(key); } else { productBrowseQuery.SortBy = "DisplaySequence"; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrder"])) { string sortOrder = Globals.HtmlEncode(this.Page.Request.QueryString["sortOrder"]); if (!sortOrder.ToLower().Equals("desc") && !sortOrder.ToLower().Equals("asc")) { sortOrder = "Desc"; } productBrowseQuery.SortOrder = (SortAction)System.Enum.Parse(typeof(SortAction), sortOrder); } else { productBrowseQuery.SortOrder = SortAction.Desc; } //筛选是否有货 if (string.IsNullOrEmpty(this.Page.Request.QueryString["Stock"])) { productBrowseQuery.HasStock = false; } else { if (this.Page.Request.QueryString["Stock"].ToString().ToLower() == "has") { productBrowseQuery.HasStock = true; } else { productBrowseQuery.HasStock = false; } } Globals.EntityCoding(productBrowseQuery, true); return(productBrowseQuery); }
public static DbQueryResult GetGroupByProductList(ProductBrowseQuery query) { return(new GroupBuyDao().GetGroupByProductList(query)); }
public static DataSet GetGroupByProductList(ProductBrowseQuery query, out int count) { return(new GroupBuyDao().GetGroupByProductList(query, out count)); }
public static DbQueryResult GetShareProducts(int shareId, ProductBrowseQuery query) { return(new ProductBrowseDao().GetShareProducts(shareId, query)); }
/// <summary> /// 查询搜索集合中的品牌,原产地 /// </summary> /// <param name="query"></param> /// <returns></returns> public static DataTable GetBrowseProductImportSourceIdAndBrandIdList(ProductBrowseQuery query) { return(new ProductBrowseDao().GetBrowseProductImportSourceIdAndBrandIdList(query)); }
public static DbQueryResult GetBrandProducts(int?brandId, ProductBrowseQuery query) //新增分页查询 { return(new ProductBrowseDao().GetBrandProducts(brandId, query)); }
protected static string BuildProductBrowseQuerySearch(ProductBrowseQuery query) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("SaleStatus = {0}", 1); if (!query.IsPrecise) { if (!string.IsNullOrEmpty(query.ProductCode)) { stringBuilder.AppendFormat(" AND LOWER(ProductCode) Like '%{0}%'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } } else { if (!string.IsNullOrEmpty(query.ProductCode)) { stringBuilder.AppendFormat(" AND LOWER(ProductCode)='{0}'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } } if (query.AttributeValues.Count > 0) { foreach (AttributeValueInfo current in query.AttributeValues) { stringBuilder.AppendFormat(" AND ProductId IN ( SELECT ProductId FROM Hishop_ProductAttributes WHERE AttributeId={0} And ValueId={1}) ", current.AttributeId, current.ValueId); } } if (query.BrandId.HasValue) { if (query.BrandId.Value == 0) { stringBuilder.Append(" AND BrandId IS NOT NULL"); } else { stringBuilder.AppendFormat(" AND BrandId = {0}", query.BrandId.Value); } } if (query.MinSalePrice.HasValue) { stringBuilder.AppendFormat(" AND SalePrice >= {0}", query.MinSalePrice.Value); } if (query.MaxSalePrice.HasValue) { stringBuilder.AppendFormat(" AND SalePrice <= {0}", query.MaxSalePrice.Value); } if (!string.IsNullOrEmpty(query.Keywords) && query.Keywords.Trim().Length > 0) { if (!query.IsPrecise) { query.Keywords = DataHelper.CleanSearchString(query.Keywords); string[] array = Regex.Split(query.Keywords.Trim(), "\\s+"); List <string> list = new List <string>(); list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%')", DataHelper.CleanSearchString(array[0]))); int num = 1; while (num < array.Length && num <= 4) { list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%')", DataHelper.CleanSearchString(array[num]))); num++; } stringBuilder.Append(" and (" + string.Join(" and ", list.ToArray()) + ")"); } else { stringBuilder.AppendFormat(" AND ProductName = '{0}'", DataHelper.CleanSearchString(query.Keywords)); } } if (query.CategoryId.HasValue) { CategoryInfo category = CategoryBrowser.GetCategory(query.CategoryId.Value); if (category != null) { stringBuilder.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path); } else { stringBuilder.Append(" and 1>2 "); } } if (!string.IsNullOrEmpty(query.TagIds)) { string[] array2 = query.TagIds.Split(new char[] { '_' }); string[] array3 = array2; for (int i = 0; i < array3.Length; i++) { string text = array3[i]; if (!string.IsNullOrEmpty(text)) { stringBuilder.AppendFormat(" AND ProductId IN(SELECT ProductId FROM Hishop_ProductTag WHERE TagId = {0})", text); } } } return(stringBuilder.ToString()); }
protected ProductBrowseQuery GetProductBrowseQuery() { ProductBrowseQuery productBrowseQuery = new ProductBrowseQuery(); if (!string.IsNullOrEmpty(this.Page.Request.QueryString["categoryId"])) { int value = 0; if (int.TryParse(this.Page.Request.QueryString["categoryId"], out value)) { productBrowseQuery.CategoryId = new int?(value); } } int value2; if (int.TryParse(this.Page.Request.QueryString["brand"], out value2)) { productBrowseQuery.BrandId = new int?(value2); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"])) { System.Collections.Generic.IList <AttributeValueInfo> list = new System.Collections.Generic.List <AttributeValueInfo>(); string text = Globals.UrlDecode(this.Page.Request.QueryString["valueStr"]); text = Globals.HtmlEncode(text); string[] array = text.Split(new char[] { '-' }); if (!string.IsNullOrEmpty(text)) { for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[] { '_' }); if (array2.Length > 0 && !string.IsNullOrEmpty(array2[1]) && array2[1] != "0") { list.Add(new AttributeValueInfo { AttributeId = System.Convert.ToInt32(array2[0]), ValueId = System.Convert.ToInt32(array2[1]) }); } } } productBrowseQuery.AttributeValues = list; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isPrecise"])) { productBrowseQuery.IsPrecise = bool.Parse(Globals.UrlDecode(this.Page.Request.QueryString["isPrecise"])); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["keywords"])) { productBrowseQuery.Keywords = DataHelper.CleanSearchString(Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["keywords"]))); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["minSalePrice"])) { decimal value3 = 0m; if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["minSalePrice"]), out value3)) { productBrowseQuery.MinSalePrice = new decimal?(value3); } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["maxSalePrice"])) { decimal value4 = 0m; if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["maxSalePrice"]), out value4)) { productBrowseQuery.MaxSalePrice = new decimal?(value4); } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["TagIds"])) { productBrowseQuery.TagIds = Globals.UrlDecode(this.Page.Request.QueryString["TagIds"]); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"])) { productBrowseQuery.ProductCode = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["productCode"])); } productBrowseQuery.PageIndex = this.pager.PageIndex; productBrowseQuery.PageSize = this.pager.PageSize; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrderBy"])) { productBrowseQuery.SortBy = Globals.HtmlEncode(this.Page.Request.QueryString["sortOrderBy"]); } else { productBrowseQuery.SortBy = "DisplaySequence"; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrder"])) { productBrowseQuery.SortOrder = (SortAction)System.Enum.Parse(typeof(SortAction), Globals.HtmlEncode(this.Page.Request.QueryString["sortOrder"])); } else { productBrowseQuery.SortOrder = SortAction.Desc; } Globals.EntityCoding(productBrowseQuery, true); return(productBrowseQuery); }
protected static string BuildProductBrowseQuerySearch(ProductBrowseQuery query) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("SaleStatus = {0}", 1); if (!string.IsNullOrEmpty(query.ProductCode)) { builder.AppendFormat(" AND LOWER(ProductCode) Like '%{0}%'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } if (query.AttributeValues.Count > 0) { foreach (AttributeValueInfo info in query.AttributeValues) { builder.AppendFormat(" AND ProductId IN ( SELECT ProductId FROM Hishop_ProductAttributes WHERE AttributeId={0} And ValueId={1}) ", info.AttributeId, info.ValueId); } } if (query.BrandId.HasValue) { if (query.BrandId.Value == 0) { builder.Append(" AND BrandId IS NOT NULL"); } else { builder.AppendFormat(" AND BrandId = {0}", query.BrandId.Value); } } if (query.MinSalePrice.HasValue) { builder.AppendFormat(" AND SalePrice >= {0}", query.MinSalePrice.Value); } if (query.MaxSalePrice.HasValue) { builder.AppendFormat(" AND SalePrice <= {0}", query.MaxSalePrice.Value); } if (!string.IsNullOrEmpty(query.Keywords) && (query.Keywords.Trim().Length > 0)) { if (!query.IsPrecise) { query.Keywords = DataHelper.CleanSearchString(query.Keywords); string[] strArray = Regex.Split(query.Keywords.Trim(), @"\s+"); List <string> list = new List <string>(); list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%')", DataHelper.CleanSearchString(strArray[0]))); for (int i = 1; (i < strArray.Length) && (i <= 4); i++) { list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%')", DataHelper.CleanSearchString(strArray[i]))); } builder.Append(" and (" + string.Join(" and ", list.ToArray()) + ")"); } else { builder.AppendFormat(" AND (ProductName = '{0}' or LOWER(ProductCode)='{0}')", DataHelper.CleanSearchString(query.Keywords)); } } if (query.CategoryId.HasValue) { CategoryInfo category = CategoryBrowser.GetCategory(query.CategoryId.Value); if (category != null) { builder.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path); } else { builder.Append(" and 1>2 "); } } if (!string.IsNullOrEmpty(query.TagIds)) { string[] strArray2 = query.TagIds.Split(new char[] { '_' }); foreach (string str in strArray2) { if (!string.IsNullOrEmpty(str)) { builder.AppendFormat(" AND ProductId IN(SELECT ProductId FROM distro_ProductTag WHERE TagId = {0} AND DistributorUserId={1})", str, HiContext.Current.SiteSettings.UserId); } } } return(builder.ToString()); }
protected override void AttachChildControls() { int.TryParse(this.Page.Request.QueryString["storeId"], out this.storeId); int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId); this.keyWord = DataHelper.CleanSearchString(this.Page.Request.QueryString["keyWord"]); if (!string.IsNullOrWhiteSpace(this.keyWord)) { this.keyWord = HttpUtility.UrlDecode(HttpUtility.UrlDecode(this.keyWord)).Trim(); } this.productIds = this.Page.Request.QueryString["productIds"]; this.imgUrl = (HiImage)this.FindControl("imgUrl"); this.litContent = (Literal)this.FindControl("litContent"); this.rptProducts = (WapTemplatedRepeater)this.FindControl("rptProducts"); this.rptCategories = (WapTemplatedRepeater)this.FindControl("rptCategories"); this.txtTotalPages = (HtmlInputHidden)this.FindControl("txtTotal"); string text = this.Page.Request.QueryString["sort"]; if (string.IsNullOrWhiteSpace(text) || (text.ToLower() != "addeddate" && text.ToLower() != "saleprice" && text.ToLower() != "visticounts" && text.ToLower() != "showsalecounts")) { text = "DisplaySequence"; } string text2 = this.Page.Request.QueryString["order"]; if (string.IsNullOrWhiteSpace(text2)) { text2 = "desc"; } int pageIndex = default(int); if (!int.TryParse(this.Page.Request.QueryString["page"], out pageIndex)) { pageIndex = 1; } int pageSize = default(int); if (!int.TryParse(this.Page.Request.QueryString["size"], out pageSize)) { pageSize = 20; } this.rptCategories.ClientType = base.ClientType; IEnumerable <CategoryInfo> subCategories = CatalogHelper.GetSubCategories(this.categoryId); this.rptCategories.DataSource = subCategories; this.rptCategories.DataBind(); ProductBrowseQuery productBrowseQuery = new ProductBrowseQuery(); productBrowseQuery.PageIndex = pageIndex; productBrowseQuery.PageSize = pageSize; if (this.storeId.ToInt(0) > 0) { productBrowseQuery.StoreId = this.storeId; } if (this.categoryId.ToInt(0) > 0) { productBrowseQuery.Category = CatalogHelper.GetCategory(this.categoryId); } productBrowseQuery.Keywords = this.keyWord; productBrowseQuery.SortBy = "DisplaySequence"; productBrowseQuery.SortOrder = SortAction.Desc; productBrowseQuery.SortBy = text; productBrowseQuery.SortOrder = ((text2 == "asc") ? SortAction.Asc : SortAction.Desc); if (!string.IsNullOrEmpty(this.productIds)) { productBrowseQuery.CanUseProducts = this.productIds; } productBrowseQuery.ProductSaleStatus = ProductSaleStatus.OnSale; DbQueryResult storeProductList = StoresHelper.GetStoreProductList(productBrowseQuery); this.rptProducts.ClientType = base.ClientType; this.rptProducts.DataSource = storeProductList.Data; this.rptProducts.DataBind(); this.txtTotalPages.SetWhenIsNotNull(storeProductList.TotalRecords.ToString()); PageTitle.AddSiteNameTitle("分类搜索页"); }
/// <summary> /// 根据筛选条件获取所有的商品,不做分页 /// </summary> /// <param name="query"></param> /// <returns></returns> public static DataTable GetAllProductList(ProductBrowseQuery query) { return(new ProductBrowseDao().GetAllProductList(query)); }
protected override void AttachChildControls() { #region == 店铺信息 if (!int.TryParse(this.Page.Request.QueryString["supplierId"], out this.supplierId)) { base.GotoResourceNotFound("店铺已不存在"); } //店铺收藏数 this.litSupplierFavCount = (System.Web.UI.WebControls.Literal) this.FindControl("litSupplierFavCount"); //店铺logo this.imgSupplierLogo = (HiImage)this.FindControl("imgSupplierLogo"); this.isCollect = (System.Web.UI.WebControls.Literal) this.FindControl("isCollect"); //店铺名称 this.litSupplierName = (System.Web.UI.WebControls.Literal) this.FindControl("litSupplierName"); //店主名称 this.litSupplierOwner = (System.Web.UI.WebControls.Literal) this.FindControl("litSupplierOwner"); //店铺地址 this.litSupplierAddress = (System.Web.UI.WebControls.Literal) this.FindControl("litSupplierAddress"); //开店时间 this.litSupplierCreateTime = (System.Web.UI.WebControls.Literal) this.FindControl("litSupplierCreateTime"); Member member = HiContext.Current.User as Member; int userId = 0; if (member != null) { userId = member.UserId; } AppSupplierInfo info = SupplierHelper.GetAppSupplier(supplierId, userId); if (info != null) { this.litSupplierFavCount.Text = info.CollectCount > 0 ? info.CollectCount.ToString() : "0"; this.imgSupplierLogo.ImageUrl = info.Logo; this.litSupplierName.Text = info.ShopName; this.litSupplierOwner.Text = info.ShopOwner; //this.isCollect.Text = info.IsCollect.ToString(); if (info.CreateDate.HasValue) { this.litSupplierAddress.Text = RegionHelper.GetFullRegion(info.County, ",").Split(',')[0]; } if (info.County > 0) { this.litSupplierCreateTime.Text = info.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"); } } else { base.GotoResourceNotFound("店铺已不存在"); } #endregion this.imgUrl = (HiImage)this.FindControl("imgUrl"); this.litContent = (System.Web.UI.WebControls.Literal) this.FindControl("litContent"); int.TryParse(this.Page.Request.QueryString["categoryId"], out this.categoryId); int.TryParse(this.Page.Request.QueryString["SupplierId"], out this.supplierId); int.TryParse(this.Page.Request.QueryString["TopicId"], out this.TopicId); int.TryParse(this.Page.Request.QueryString["brandid"], out this.brandid); int.TryParse(this.Page.Request.QueryString["importsourceid"], out this.importsourceid); this.keyWord = this.Page.Request.QueryString["keyWord"]; if (!string.IsNullOrWhiteSpace(this.keyWord)) { this.keyWord = this.keyWord.Trim(); if (HiContext.Current.User.UserId > 0) { HistorySearchHelp.NewSearchHistory(this.keyWord.Trim(), HiContext.Current.User.UserId, Entities.ClientType.VShop); } } this.rptProducts = (VshopTemplatedRepeater)this.FindControl("rptProducts"); this.rptCategories = (VshopTemplatedRepeater)this.FindControl("rptCategories"); this.txtTotalPages = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("txtTotal"); this.litSiblingsCategories = (System.Web.UI.WebControls.Literal) this.FindControl("litSiblingsCategories"); string text = this.Page.Request.QueryString["sort"]; if (string.IsNullOrWhiteSpace(text)) { text = "DisplaySequence"; } string text2 = this.Page.Request.QueryString["order"]; if (string.IsNullOrWhiteSpace(text2)) { text2 = "desc"; } int pageNumber; if (!int.TryParse(this.Page.Request.QueryString["page"], out pageNumber)) { pageNumber = 1; } int maxNum; if (!int.TryParse(this.Page.Request.QueryString["size"], out maxNum)) { maxNum = 8; } //获取其他分类 System.Collections.Generic.IList <CategoryInfo> maxSubCategories = CategoryBrowser.GetMaxSubCategories(this.categoryId, 1000); this.rptCategories.DataSource = maxSubCategories; this.rptCategories.DataBind(); IList <CategoryInfo> siblingsCategories = CategoryBrowser.GetSiblingsCategories(this.categoryId, 1000); //<li><a class="link" href="/Vshop/ProductList.aspx?categoryId=8000036">进口零食</a></li> StringBuilder stringBuilderCategories = new StringBuilder(); foreach (CategoryInfo item in siblingsCategories) { stringBuilderCategories.AppendFormat("<li><a class=\"link\" href=\"/Vshop/ProductList.aspx?categoryId={0}\">{1}</a></li>", item.CategoryId, item.Name); } this.litSiblingsCategories.Text = stringBuilderCategories.ToString(); int num; ProductBrowseQuery query = new ProductBrowseQuery(); if (this.categoryId > 0) { query.StrCategoryId = this.categoryId.ToString(); } if (this.supplierId > 0) { query.supplierid = this.supplierId; } if (this.brandid > 0) { query.StrBrandId = this.brandid.ToString(); } if (this.importsourceid > 0) { query.StrImportsourceId = this.importsourceid.ToString(); } if (!string.IsNullOrWhiteSpace(this.keyWord)) { query.Keywords = this.keyWord; } query.PageIndex = pageNumber; query.PageSize = maxNum; query.SortBy = text; if (text2.ToLower() == "desc") { query.SortOrder = EcShop.Core.Enums.SortAction.Desc; } else { query.SortOrder = EcShop.Core.Enums.SortAction.Asc; } DbQueryResult dr = ProductBrowser.GetCurrBrowseProductList(query); //this.rptProducts.DataSource = ProductBrowser.GetProducts(null, new int?(this.categoryId), new int?(this.supplierId), this.keyWord, pageNumber, maxNum, out num, text, true, text2, true, new int?(this.brandid), new int?(this.importsourceid)); this.rptProducts.DataSource = dr.Data; this.rptProducts.DataBind(); this.txtTotalPages.SetWhenIsNotNull(dr.TotalRecords.ToString()); PageTitle.AddSiteNameTitle("店内搜索"); }
protected ProductBrowseQuery GetProductBrowseQuery() { int num2; ProductBrowseQuery entity = new ProductBrowseQuery(); if (!string.IsNullOrEmpty(this.Page.Request.QueryString["categoryId"])) { int result = 0; if (int.TryParse(this.Page.Request.QueryString["categoryId"], out result)) { entity.CategoryId = new int?(result); } } if (int.TryParse(this.Page.Request.QueryString["brand"], out num2)) { entity.BrandId = new int?(num2); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"])) { IList <AttributeValueInfo> list = new List <AttributeValueInfo>(); string str = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["valueStr"])); string[] strArray = str.Split(new char[] { '-' }); if (!string.IsNullOrEmpty(str)) { for (int i = 0; i < strArray.Length; i++) { string[] strArray2 = strArray[i].Split(new char[] { '_' }); if (((strArray2.Length > 0) && !string.IsNullOrEmpty(strArray2[1])) && (strArray2[1] != "0")) { AttributeValueInfo item = new AttributeValueInfo(); item.AttributeId = Convert.ToInt32(strArray2[0]); item.ValueId = Convert.ToInt32(strArray2[1]); list.Add(item); } } } entity.AttributeValues = list; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["isPrecise"])) { entity.IsPrecise = bool.Parse(Globals.UrlDecode(this.Page.Request.QueryString["isPrecise"])); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["keywords"])) { entity.Keywords = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["keywords"])); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["minSalePrice"])) { decimal num4 = 0M; if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["minSalePrice"]), out num4)) { entity.MinSalePrice = new decimal?(num4); } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["maxSalePrice"])) { decimal num5 = 0M; if (decimal.TryParse(Globals.UrlDecode(this.Page.Request.QueryString["maxSalePrice"]), out num5)) { entity.MaxSalePrice = new decimal?(num5); } } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["productCode"])) { entity.ProductCode = Globals.HtmlEncode(Globals.UrlDecode(this.Page.Request.QueryString["productCode"])); } entity.PageIndex = this.pager.PageIndex; entity.PageSize = this.rptProducts.PageSize; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrderBy"])) { entity.SortBy = Globals.HtmlEncode(this.Page.Request.QueryString["sortOrderBy"]); } else { entity.SortBy = "DisplaySequence"; } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["sortOrder"])) { entity.SortOrder = (SortAction)Enum.Parse(typeof(SortAction), Globals.HtmlEncode(this.Page.Request.QueryString["sortOrder"])); } else { entity.SortOrder = SortAction.Desc; } Globals.EntityCoding(entity, true); return(entity); }
protected void BindSearch() { ProductBrowseQuery productBrowseQuery = this.GetCurrProductBrowseQuery(); productBrowseQuery.supplierid = this.supplierId; //if (this.serach_text != null) //{ // this.serach_text.Value = productBrowseQuery.Keywords; //} //if (search_Subtext != null) //{ // search_Subtext.Value = productBrowseQuery.SubKeywords; //} DbQueryResult browseProductList = ProductBrowser.GetCurrBrowseProductList(productBrowseQuery); this.rptProducts.DataSource = browseProductList.Data; this.rptProducts.DataBind(); #region 获取控件品牌、产地过滤条件 //List<string> search_BrandStr = new List<string>(); //List<string> search_ProducingStr = new List<string>(); //if (common_attributeslist != null) //{ // DataTable dt = ProductBrowser.GetBrowseProductImportSourceIdAndBrandIdList(productBrowseQuery); // foreach (DataRow r in dt.Rows) // { // string str = r["BrandId"].ToString(); // if (!search_BrandStr.Contains(str) && !string.IsNullOrWhiteSpace(str)) // { // search_BrandStr.Add(str); // } // str = r["ImportSourceId"].ToString(); // if (!search_ProducingStr.Contains(str) && !string.IsNullOrWhiteSpace(str) && !str.Equals("0")) // { // search_ProducingStr.Add(str); // } // } // //更新品牌、产地控件显示值 // this.common_attributeslist.search_BrandStr = search_BrandStr; // this.common_attributeslist.search_ProducingStr = search_ProducingStr; //} #endregion this.hotSale = (Common_GoodsList_HotSale)this.FindControl("list_Common_GoodsList_HotSale");//销售排行 if (this.hotSale != null) { int cid = 0; int brandId = 0; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["categoryId"])) { int.TryParse(this.Page.Request.QueryString["categoryId"], out cid); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["brand"])) { int.TryParse(this.Page.Request.QueryString["brand"], out brandId); } this.hotSale.DataSource = ProductBrowser.GetBrowseHotProductList(cid, brandId, supplierId).DBHotSale; this.hotSale.DataBind(); } this.pager.TotalRecords = browseProductList.TotalRecords; int pageCount = browseProductList.TotalRecords / this.pager.PageSize; if (browseProductList.TotalRecords % this.pager.PageSize > 0) { pageCount++; } if (pageCount <= 1) { //this.litSearchResultPage.Text = string.Format("共<span>{0}</span>件商品<span class=\"pager\"><<span class=\"cur-page\">{1}</span>/<span class=\"total-page\">{1}</span>></span>", browseProductList.TotalRecords, pageCount); this.litSearchResultPage.Text = string.Format("<span class=\"fb\">共<span class=\"total-count\">{0}</span>件商品</span><span class=\"pager\"><span class=\"cur-page\">{1}</span>/<span class=\"total-page\">{1}页</span></span>", browseProductList.TotalRecords, pageCount); return; } #region 分页控件代码 int pageIndex = 1; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["pageindex"])) { int.TryParse(this.Page.Request.QueryString["pageindex"], out pageIndex); } if (browseProductList.TotalRecords <= 0) { pageIndex = 0; } string previousPager = ""; string nextPager = ""; Regex regex = new Regex(@"(pageindex=\d+)"); MatchCollection tempMatches = regex.Matches(this.Page.Request.RawUrl); if (tempMatches.Count == 0) { previousPager = this.Page.Request.RawUrl + (this.Page.Request.RawUrl.Contains("?") ? "&" : "?") + "pageindex=1"; if (pageCount > 1) { nextPager = this.Page.Request.RawUrl + (this.Page.Request.RawUrl.Contains("?") ? "&" : "?") + "pageindex=2"; } else { nextPager = previousPager; } } if (tempMatches.Count == 1) { foreach (Match item in tempMatches) { string pagerInfo = item.Value; if (pageIndex <= pageCount) { if ((pageIndex - 1) > 0) { previousPager = this.Page.Request.RawUrl.Replace(pagerInfo, "") + "pageindex=" + (pageIndex - 1); } else { previousPager = this.Page.Request.RawUrl.Replace(pagerInfo, "") + "pageindex=1"; } if ((pageIndex + 1) <= pageCount) { nextPager = this.Page.Request.RawUrl.Replace(pagerInfo, "") + "pageindex=" + (pageIndex + 1); } else { nextPager = this.Page.Request.RawUrl.Replace(pagerInfo, "") + "pageindex=" + pageCount; } } } } #endregion if (pageCount > 1 && pageIndex == 1) { this.litSearchResultPage.Text = string.Format("<span class=\"fb\">共<span>{0}</span>件商品</span><span class=\"pager\"><span class=\"cur-page\">{2}</span>/<span class=\"total-page\">{3}页</span><a class=\"prev-page disabled\" href=\"{1}\">上一页</a><a class=\"next-page\" href=\"{4}\">下一页</a></span>", new object[] { browseProductList.TotalRecords, previousPager, pageIndex, pageCount, nextPager }); } else { this.litSearchResultPage.Text = string.Format("<span class=\"fb\">共<span>{0}</span>件商品</span><span class=\"pager\"><span class=\"cur-page\">{2}</span>/<span class=\"total-page\">{3}页</span><a class=\"prev-page\" href=\"{1}\">上一页</a><a class=\"next-page\" href=\"{4}\">下一页</a></span>", new object[] { browseProductList.TotalRecords, previousPager, pageIndex, pageCount, nextPager }); } }
protected static string BuildUnSaleProductBrowseQuerySearch(ProductBrowseQuery query) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("SaleStatus = {0}", 2); if (!string.IsNullOrEmpty(query.ProductCode)) { builder.AppendFormat(" AND LOWER(ProductCode) Like '%{0}%'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } if (query.AttributeValues.Count > 0) { foreach (AttributeValueInfo info in query.AttributeValues) { builder.AppendFormat(" AND ProductId IN ( SELECT ProductId FROM Hishop_ProductAttributes WHERE AttributeId={0} And ValueId={1}) ", info.AttributeId, info.ValueId); } } if (query.BrandId.HasValue) { if (query.BrandId.Value == 0) { builder.Append(" AND BrandId IS NOT NULL"); } else { builder.AppendFormat(" AND BrandId = {0}", query.BrandId.Value); } } if (query.MinSalePrice.HasValue) { builder.AppendFormat(" AND SalePrice >= {0}", query.MinSalePrice.Value); } if (query.MaxSalePrice.HasValue) { builder.AppendFormat(" AND SalePrice <= {0}", query.MaxSalePrice.Value); } if (!string.IsNullOrEmpty(query.Keywords) && (query.Keywords.Trim().Length > 0)) { if (!query.IsPrecise) { query.Keywords = DataHelper.CleanSearchString(query.Keywords); string[] strArray = Regex.Split(query.Keywords.Trim(), @"\s+"); builder.AppendFormat(" AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[0])); for (int i = 1; (i < strArray.Length) && (i <= 4); i++) { builder.AppendFormat("AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[i])); } } else { builder.AppendFormat(" AND ProductName = '{0}'", DataHelper.CleanSearchString(query.Keywords)); } } if (query.CategoryId.HasValue) { //CategoryInfo category = CategoryBrowser.GetCategory(query.CategoryId.Value); CategoryInfo category = new CategoryInfo(); if (category != null) { builder.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path); } } if (!string.IsNullOrEmpty(query.SubjectType)) { foreach (string str in query.SubjectType.Split(new char[] { ',' })) { builder.AppendFormat(" and ProductId IN (SELECT ProductId FROM Hishop_ProductTag WHERE TagId={0})", str); } } return(builder.ToString()); }
public static DbQueryResult GetCountDownProductList(ProductBrowseQuery query) { return(new CountDownDao().GetCountDownProductList(query)); }
public override DbQueryResult GetCountDownProductList(ProductBrowseQuery query) { string filter = string.Format(" datediff(hh,EndDate,getdate())<0 AND DistributorUserId={1} AND ProductId IN(SELECT ProductId FROM distro_Products WHERE SaleStatus=1 AND DistributorUserId={2})", DateTime.Now, HiContext.Current.SiteSettings.UserId.Value, HiContext.Current.SiteSettings.UserId.Value); return(DataHelper.PagingByTopsort(query.PageIndex, query.PageSize, query.SortBy, query.SortOrder, query.IsCount, "vw_distro_CountDown", "CountDownId", filter, "*")); }
public abstract DbQueryResult GetCountDownProductList(ProductBrowseQuery query);
public static DbQueryResult GetCountDownProductList(ProductBrowseQuery query) { return(ProductProvider.Instance().GetCountDownProductList(query)); }
public abstract DbQueryResult GetUnSaleProductList(ProductBrowseQuery query);
public static DataSet GetGroupByProductList(ProductBrowseQuery query, out int count) { return(ProductProvider.Instance().GetGroupByProductList(query, out count)); }
public static DbQueryResult GetCurrBrowseActiveProductListByTopicId(ProductBrowseQuery query) { return(new PCActiveDao().GetCurrBrowseActiveProductListByTopicId(query)); }
protected string BuildActiveTopicProductBrowseQuerySearch(ProductBrowseQuery query) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("IsApproved = 1 and SaleStatus = {0}", (int)query.ProductSaleStatus); stringBuilder.AppendFormat(" AND SaleStatus = {0}", 1); if (!query.IsPrecise) { if (!string.IsNullOrEmpty(query.ProductCode)) { stringBuilder.AppendFormat(" AND LOWER(ProductCode) Like '%{0}%'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } } else { if (!string.IsNullOrEmpty(query.ProductCode)) { stringBuilder.AppendFormat(" AND LOWER(ProductCode)='{0}'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } } if (query.AttributeValues.Count > 0) { foreach (AttributeValueInfo current in query.AttributeValues) { stringBuilder.AppendFormat(" AND ProductId IN ( SELECT ProductId FROM Ecshop_ProductAttributes WHERE AttributeId={0} And ValueId={1}) ", current.AttributeId, current.ValueId); } } if (!string.IsNullOrWhiteSpace(query.StrBrandId)) { stringBuilder.AppendFormat(" AND BrandId in ({0})", query.StrBrandId); } if (query.MinSalePrice.HasValue) { stringBuilder.AppendFormat(" AND SalePrice >= {0}", query.MinSalePrice.Value); } if (query.MaxSalePrice.HasValue) { stringBuilder.AppendFormat(" AND SalePrice <= {0}", query.MaxSalePrice.Value); } if (!string.IsNullOrEmpty(query.Keywords) && query.Keywords.Trim().Length > 0) { if (!query.IsPrecise) { query.Keywords = DataHelper.CleanSearchString(query.Keywords); string[] array = Regex.Split(query.Keywords.Trim(), "\\s+"); List <string> list = new List <string>(); list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%' or ShopName like '%{0}%')", DataHelper.CleanSearchString(array[0]))); int num = 1; while (num < array.Length && num <= 4) { list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%' or ShopName like '%{0}%')", DataHelper.CleanSearchString(array[num]))); num++; } stringBuilder.Append(" and (" + string.Join(" and ", list.ToArray()) + ")"); } else { stringBuilder.AppendFormat(" AND (ProductName = '{0}' or ShopName = '{0}') ", DataHelper.CleanSearchString(query.Keywords)); } } if (!string.IsNullOrEmpty(query.SubKeywords) && query.SubKeywords.Trim().Length > 0) { if (!query.IsPrecise) { query.SubKeywords = DataHelper.CleanSearchString(query.SubKeywords); string[] array = Regex.Split(query.SubKeywords.Trim(), "\\s+"); List <string> list = new List <string>(); list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%' or ShopName like '%{0}%')", DataHelper.CleanSearchString(array[0]))); int num = 1; while (num < array.Length && num <= 4) { list.Add(string.Format("(replace(ProductName,' ','') LIKE '%{0}%' or LOWER(ProductCode) LIKE '%{0}%' or ShopName like '%{0}%')", DataHelper.CleanSearchString(array[num]))); num++; } stringBuilder.Append(" and (" + string.Join(" and ", list.ToArray()) + ")"); } else { stringBuilder.AppendFormat(" AND (ProductName = '{0}'or ShopName = '{0}')", DataHelper.CleanSearchString(query.SubKeywords)); } } if (!string.IsNullOrWhiteSpace(query.StrCategoryId)) { IList <CategoryInfo> categorys = new CategoryDao().GetListCategoryByIds(query.StrCategoryId); if (categorys != null && categorys.Count > 0) { stringBuilder.Append(" and ( "); foreach (CategoryInfo category in categorys) { stringBuilder.AppendFormat(" MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%' or", category.Path); } stringBuilder.Remove(stringBuilder.ToString().LastIndexOf("or"), 2); stringBuilder.Append(" ) "); } //stringBuilder.AppendFormat(" AND ( MainCategoryPath LIKE 'SELECT Path FROM Ecshop_Categories WHERE CategoryId in ({0})|%' OR ExtendCategoryPath LIKE 'SELECT Path FROM Ecshop_Categories WHERE CategoryId in ({0})|%') ", query.StrCategoryId); } if (!string.IsNullOrWhiteSpace(query.StrImportsourceId))//原产地 { stringBuilder.AppendFormat(" AND ImportsourceId in ({0}) ", query.StrImportsourceId); } if (!string.IsNullOrEmpty(query.TagIds)) { string[] array2 = query.TagIds.Split(new char[] { '_' }); string[] array3 = array2; for (int i = 0; i < array3.Length; i++) { string text = DataHelper.CleanSearchString(array3[i]); if (!string.IsNullOrEmpty(text)) { stringBuilder.AppendFormat(" AND ProductId IN(SELECT ProductId FROM Ecshop_ProductTag WHERE TagId = {0})", text); } } } if (query.HasStock) { stringBuilder.Append(" AND stock>0 "); } if (query.supplierid.HasValue) { stringBuilder.AppendFormat(" AND supplierid={0} ", query.supplierid.Value); } if (query.TopId.HasValue) { if (query.TopId.Value > 0) { stringBuilder.AppendFormat(" AND topicid={0} ", query.TopId.Value); } } return(stringBuilder.ToString()); }
public static DbQueryResult GetUnSaleProductList(ProductBrowseQuery query) { query.ProductSaleStatus = ProductSaleStatus.UnSale; return(new ProductBrowseDao().GetBrowseProductList(query)); }
protected static string BuildProductBrowseQuerySearch(ProductBrowseQuery query) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("SaleStatus = {0}", 1); if (!string.IsNullOrEmpty(query.ProductCode)) { builder.AppendFormat(" AND LOWER(ProductCode) Like '%{0}%'", DataHelper.CleanSearchString(query.ProductCode).ToLower()); } if (query.AttributeValues.Count > 0) { foreach (AttributeValueInfo info in query.AttributeValues) { builder.AppendFormat(" AND ProductId IN ( SELECT ProductId FROM Hishop_ProductAttributes WHERE AttributeId={0} And ValueId={1}) ", info.AttributeId, info.ValueId); } } if (query.BrandId.HasValue) { if (query.BrandId.Value == 0) { builder.Append(" AND BrandId IS NOT NULL"); } else { builder.AppendFormat(" AND BrandId = {0}", query.BrandId.Value); } } if (query.MinSalePrice.HasValue) { builder.AppendFormat(" AND SalePrice >= {0}", query.MinSalePrice.Value); } if (query.MaxSalePrice.HasValue) { builder.AppendFormat(" AND SalePrice <= {0}", query.MaxSalePrice.Value); } if (!string.IsNullOrEmpty(query.Keywords) && (query.Keywords.Trim().Length > 0)) { if (!query.IsPrecise) { query.Keywords = DataHelper.CleanSearchString(query.Keywords); string[] strArray = Regex.Split(query.Keywords.Trim(), @"\s+"); StringBuilder builder2 = new StringBuilder(); builder2.AppendFormat(" OR (LOWER(ProductCode) LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[0])); builder.AppendFormat(" AND ((ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[0])); for (int i = 1; (i < strArray.Length) && (i <= 4); i++) { builder.AppendFormat(" AND ProductName LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[i])); builder2.AppendFormat(" AND LOWER(ProductCode) LIKE '%{0}%'", DataHelper.CleanSearchString(strArray[i])); } builder.Append(")" + builder2.ToString() + "))"); } else { builder.AppendFormat(" AND (ProductName = '{0}' or LOWER(ProductCode)='{0}')", DataHelper.CleanSearchString(query.Keywords)); } } if (query.CategoryId.HasValue) { CategoryInfo category = CategoryBrowser.GetCategory(query.CategoryId.Value); if (category != null) { builder.AppendFormat(" AND ( MainCategoryPath LIKE '{0}|%' OR ExtendCategoryPath LIKE '{0}|%') ", category.Path); } } if (!string.IsNullOrEmpty(query.SubjectType)) { builder.AppendFormat(" AND ProductId IN(SELECT ProductId FROM distro_SubjectProducts WHERE SubjectType = {0} AND DistributorUserId={1})", (int)Enum.Parse(typeof(SubjectType), query.SubjectType), HiContext.Current.SiteSettings.UserId); } return(builder.ToString()); }