public DataTable GetProductList(int CategoryID, int PageIndex, int BrandID, decimal[] PriceRange, int OrderType, Hashtable Parameters, out int RecordCount, out int PageCount) { string where = String.Empty; int i = 0; if (Parameters != null) { foreach (string key in Parameters.Keys) { CategoryParaModel para = new CategoryParaModelBll().GetModel(Convert.ToInt32(key), CategoryID); if (i == Parameters.Count - 1) { where += String.Format(" and (pdproductpara.paraid = {0} and pdproductpara.paravalue like '%{1}%') ", key, para.ParaValues.Split(',')[Convert.ToInt32(Parameters[key])]); } else { where += String.Format(" and (pdproductpara.paraid = {0} and pdproductpara.paravalue like '%{1}%') ", key, para.ParaValues.Split(',')[Convert.ToInt32(Parameters[key])]); } i++; } } if (BrandID != 0) { where += " and pdproduct.brandid=" + BrandID; } if (PriceRange != null && PriceRange.Length == 2) { where += String.Format(" and pdproduct.merchantprice >= {0} and pdproduct.merchantprice <= {1}", PriceRange[0], PriceRange[1] + 0.99M); } string CategoryPath = Convert.ToString(GetCategoryInfo(CategoryID)["catepath"]); where += String.Format(" and pdproduct.catepath like '{0}%'", CategoryPath); where += " and pdproduct.status = 1"; SearchPageInfo pageInfo = new SearchPageInfo(); pageInfo.TableName = "pdproductpara"; pageInfo.PriKeyName = "productid"; pageInfo.FieldNames = "pdproduct.productid,paraid,paravalue,productname,pdcategory.cateid,pdcategory.catepath,tradeprice,merchantprice,reduceprice,stock,smallimage,mediumimage,largeimage,keywords,brief,pageview,inserttime,changetime,pdproduct.status,score"; pageInfo.TotalFieldStr = ""; pageInfo.PageSize = Config.ListPageSize; pageInfo.PageIndex = PageIndex; pageInfo.OrderType = GetOrderString(OrderType); pageInfo.StrWhere = "1=1 " + where; pageInfo.StrJoin = " inner join pdproduct on pdproduct.productid=pdproductpara.productid inner join pdcategory on pdproduct.cateid=pdcategory.cateid "; DataTable dt = CommDataHelper.GetDataFromMultiTablesByPage(pageInfo).Tables[0]; RecordCount = pageInfo.TotalItem; PageCount = pageInfo.TotalPage; return(dt); }
private void ShowProducts(string pids) { ProductModelBll pbll = new ProductModelBll(); List <ProductModel> plist = pbll.GetModelList("productId in (" + pids + ")"); string[] vals = (from p in plist select p.ProductName).ToArray(); AddTH("<span>产品基本情况</span>", plist.Count + 1); AddTR("商品名称", (from p in plist orderby p.ProductId select p.ProductName).ToArray(), true); AddTR("产品图片", (from p in plist orderby p.ProductId select "<img class='productPi' src='" + p.SmallImage + "'/>").ToArray(), false); AddTR("产品编号", (from p in plist orderby p.ProductId select p.ProductId.ToString()).ToArray(), false); AddTR("市场价", (from p in plist orderby p.ProductId select p.TradePrice.ToString("F2")).ToArray(), false); AddTR("鼎鼎价", (from p in plist orderby p.ProductId select p.MerchantPrice.ToString("F2")).ToArray(), false); AddTR("库存状态", (from p in plist orderby p.ProductId select p.Stock > 0 ? "现货" : "补货中").ToArray(), false); AddTH("<span>详细参数</span>", plist.Count + 1); int cateNum = (from p in plist select p.CateId).Distinct().ToArray().Length; if (cateNum > 1) { AddTR("商品不属于同一个分类,无法比较", plist.Count + 1); } else { int cateId = plist[0].CateId; CategoryParaModelBll pabll = new CategoryParaModelBll(); List <CategoryParaModel> cplist = pabll.GetModelList("cateId=" + cateId); ProductParaModelBll ppabll = new ProductParaModelBll(); List <ProductParaModel> ppalist = ppabll.GetModelList("productId in (" + pids + ")"); foreach (CategoryParaModel cpmodel in cplist) { string title = cpmodel.ParaName; string[] pvals = (from p in ppalist where p.ParaId == cpmodel.ParaId orderby p.ProductId select p.ParaValue).ToArray(); AddTR(title, pvals, false); } } }
private void InitConditionItems(int cateId) { BrandCategoryRelationBll bcrbll = new BrandCategoryRelationBll(); this.cblBrands.DataSource = bcrbll.GetCategoryBrandList(cateId); this.cblBrands.DataTextField = "BrandName"; this.cblBrands.DataValueField = "BrandId"; this.cblBrands.DataBind(); NoName.NetShop.Product.BLL.CategoryModelBll cbll = new CategoryModelBll(); this.cblSubCate.DataSource = cbll.GetSubCategory(cateId); this.cblSubCate.DataTextField = "CateName"; this.cblSubCate.DataValueField = "CateId"; this.cblSubCate.DataBind(); CategoryParaModelBll cpbll = new CategoryParaModelBll(); List <CategoryParaModel> plist = cpbll.GetModelList("status=1 and paratype=1 and cateid=" + cateId); rpItems.DataSource = plist; rpItems.DataBind(); }