public List <ProductDetail> GetFilterProducts(string categoryid, List <FilterAttr> Attrs, int doctype, string beginprice, string endprice, int ispublic, string keyWords, string orderby, bool isasc, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientID) { var dal = new ProductsDAL(); StringBuilder attrbuild = new StringBuilder(); StringBuilder salebuild = new StringBuilder(); foreach (var attr in Attrs) { if (attr.Type == EnumAttrType.Parameter) { attrbuild.Append(" and p.ValueList like '%" + attr.ValueID + "%'"); } else if (attr.Type == EnumAttrType.Specification) { salebuild.Append(" and AttrValue like '%" + attr.ValueID + "%'"); } } DataSet ds = dal.GetFilterProducts(categoryid, attrbuild.ToString(), salebuild.ToString(), doctype, beginprice, endprice, ispublic, keyWords, orderby, isasc ? 1 : 0, pageSize, pageIndex, ref totalCount, ref pageCount, clientID); List <ProductDetail> list = new List <ProductDetail>(); foreach (DataRow dr in ds.Tables[0].Rows) { ProductDetail model = new ProductDetail(); model.FillData(dr); list.Add(model); } return(list); }
public List <ProductDetail> GetProductDetails(string wareid, string keywords, string agentid, string clientid) { DataSet ds = ProductsDAL.BaseProvider.GetProductDetails(wareid, keywords, clientid); List <ProductDetail> list = new List <ProductDetail>(); foreach (DataRow dr in ds.Tables[0].Rows) { ProductDetail model = new ProductDetail(); model.FillData(dr); model.SaleAttrValueString = ""; if (!string.IsNullOrEmpty(model.SaleAttrValue)) { string[] attrs = model.SaleAttrValue.Split(','); foreach (string attrid in attrs) { if (!string.IsNullOrEmpty(attrid)) { var attr = new ProductsBusiness().GetProductAttrByID(attrid.Split(':')[0], clientid); var value = attr.AttrValues.Where(m => m.ValueID == attrid.Split(':')[1]).FirstOrDefault(); if (attr != null && value != null) { model.SaleAttrValueString += attr.AttrName + ":" + value.ValueName + ","; } } } if (model.SaleAttrValueString.Length > 0) { model.SaleAttrValueString = model.SaleAttrValueString.Substring(0, model.SaleAttrValueString.Length - 1); } } list.Add(model); } return(list); }
public Products GetProductByID(string productid, string clientid) { var dal = new ProductsDAL(); DataSet ds = dal.GetProductByID(productid); Products model = new Products(); if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0) { model.FillData(ds.Tables["Product"].Rows[0]); model.Category = GetCategoryByID(model.CategoryID); model.SmallUnit = GetUnitByID(model.UnitID); if (!string.IsNullOrEmpty(model.ProviderID)) { model.Providers = ProvidersBusiness.BaseBusiness.GetProviderByID(model.ProviderID); } model.ProductDetails = new List <ProductDetail>(); foreach (DataRow item in ds.Tables["Details"].Rows) { //子产品 ProductDetail detail = new ProductDetail(); detail.FillData(item); model.ProductDetails.Add(detail); } } return(model); }
public Products GetProductByID(string productid) { var dal = new ProductsDAL(); DataSet ds = dal.GetProductByID(productid); Products model = new Products(); if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0) { model.FillData(ds.Tables["Product"].Rows[0]); model.Category = GetCategoryDetailByID(model.CategoryID); var bigunit = new ProductUnit(); bigunit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.BigUnitID + "'").FirstOrDefault()); model.BigUnit = bigunit; var smallunit = new ProductUnit(); smallunit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.SmallUnitID + "'").FirstOrDefault()); model.SmallUnit = smallunit; model.ProductDetails = new List <ProductDetail>(); foreach (DataRow item in ds.Tables["Details"].Rows) { //子产品 ProductDetail detail = new ProductDetail(); detail.FillData(item); Dictionary <string, string> attrs = new Dictionary <string, string>(); foreach (string attr in detail.SaleAttrValue.Split(',')) { if (!string.IsNullOrEmpty(attr)) { attrs.Add(attr.Split(':')[0], attr.Split(':')[1]); } } detail.SaleAttrValueString = ""; foreach (var attr in model.Category.SaleAttrs) { if (attrs.ContainsKey(attr.AttrID)) { detail.SaleAttrValueString += attr.AttrName + ":" + attr.AttrValues.Where(a => a.ValueID.ToLower() == attrs[attr.AttrID].ToLower()).FirstOrDefault().ValueName + ","; } } if (detail.SaleAttrValueString.Length > 0) { detail.SaleAttrValueString = detail.SaleAttrValueString.Substring(0, detail.SaleAttrValueString.Length - 1); } model.ProductDetails.Add(detail); } } return(model); }
/// <summary> /// 获取购物车列表 /// </summary> public static List <ProductDetail> GetShoppingCart(EnumDocType ordertype, string guid, string userid) { DataTable dt = ShoppingCartDAL.GetShoppingCart((int)ordertype, guid, userid); List <ProductDetail> list = new List <ProductDetail>(); foreach (DataRow dr in dt.Rows) { ProductDetail model = new ProductDetail(); model.FillData(dr); list.Add(model); } return(list); }
public List <ProductDetail> GetProductDetailStocks(string productid, string clientid) { DataTable dt = StockDAL.BaseProvider.GetProductDetailStocks(productid, clientid); List <ProductDetail> list = new List <ProductDetail>(); foreach (DataRow dr in dt.Rows) { ProductDetail model = new ProductDetail(); model.FillData(dr); list.Add(model); } return(list); }
public List <ProductDetail> GetProductDetails(string wareid, string keywords, string clientid) { DataSet ds = ProductsDAL.BaseProvider.GetProductDetails(wareid, keywords, clientid); List <ProductDetail> list = new List <ProductDetail>(); foreach (DataRow dr in ds.Tables[0].Rows) { ProductDetail model = new ProductDetail(); model.FillData(dr); list.Add(model); } return(list); }
/// <summary> /// 获取购物车列表 /// </summary> public static List <ProductDetail> GetShoppingCart(EnumDocType ordertype, string guid, string userid) { DataTable dt = ShoppingCartDAL.GetShoppingCart((int)ordertype, guid, userid); List <ProductDetail> list = new List <ProductDetail>(); foreach (DataRow dr in dt.Rows) { ProductDetail model = new ProductDetail(); model.FillData(dr); if (!string.IsNullOrEmpty(model.UnitID)) { model.UnitName = new ProductsBusiness().GetUnitByID(model.UnitID).UnitName; } list.Add(model); } return(list); }
/// <summary> /// 获取产品信息(加入购物车页面) /// </summary> /// <param name="productid"></param> /// <returns></returns> public Products GetProductByIDForDetails(string productid) { var dal = new ProductsDAL(); DataSet ds = dal.GetProductByIDForDetails(productid); Products model = new Products(); if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0) { model.FillData(ds.Tables["Product"].Rows[0]); //单位 model.BigUnit = new ProductUnit(); model.BigUnit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.BigUnitID + "'").FirstOrDefault()); model.SmallUnit = new ProductUnit(); model.SmallUnit.FillData(ds.Tables["Unit"].Select("UnitID='" + model.SmallUnitID + "'").FirstOrDefault()); model.AttrLists = new List <ProductAttr>(); model.SaleAttrs = new List <ProductAttr>(); foreach (DataRow attrtr in ds.Tables["Attrs"].Rows) { ProductAttr attrModel = new ProductAttr(); attrModel.FillData(attrtr); attrModel.AttrValues = new List <AttrValue>(); //参数 if (attrModel.Type == (int)EnumAttrType.Parameter) { foreach (DataRow valuetr in ds.Tables["Values"].Select("AttrID='" + attrModel.AttrID + "'")) { AttrValue valueModel = new AttrValue(); valueModel.FillData(valuetr); if (model.AttrValueList.IndexOf(valueModel.ValueID) >= 0) { attrModel.AttrValues.Add(valueModel); model.AttrLists.Add(attrModel); break; } } } else { model.SaleAttrs.Add(attrModel); } } model.ProductDetails = new List <ProductDetail>(); foreach (DataRow item in ds.Tables["Details"].Rows) { ProductDetail detail = new ProductDetail(); detail.FillData(item); //填充存在的规格 foreach (var attrModel in model.SaleAttrs) { foreach (DataRow valuetr in ds.Tables["Values"].Select("AttrID='" + attrModel.AttrID + "'")) { AttrValue valueModel = new AttrValue(); valueModel.FillData(valuetr); if (detail.AttrValue.IndexOf(valueModel.ValueID) >= 0) { if (attrModel.AttrValues.Where(v => v.ValueID == valueModel.ValueID).Count() == 0) { attrModel.AttrValues.Add(valueModel); } break; } } } model.ProductDetails.Add(detail); } } return(model); }
public Products GetProductByIDForDetails(string productid, string clientid) { var dal = new ProductsDAL(); DataSet ds = dal.GetProductByIDForDetails(productid, clientid); Products model = new Products(); if (ds.Tables.Contains("Product") && ds.Tables["Product"].Rows.Count > 0) { model.FillData(ds.Tables["Product"].Rows[0]); model.SmallUnit = GetUnitByID(model.UnitID); model.AttrLists = new List <ProductAttr>(); model.SaleAttrs = new List <ProductAttr>(); model.Providers = new ProvidersEntity(); if (!string.IsNullOrEmpty(model.ProviderID)) { model.Providers.FillData(ds.Tables["Providers"].Rows[0]); if (!string.IsNullOrEmpty(model.Providers.CityCode)) { var city = CommonBusiness.GetCityByCode(model.Providers.CityCode); model.Providers.Address = city.Description + model.Providers.Address; } } if (!string.IsNullOrEmpty(model.CategoryID)) { var category = GetCategoryByID(model.CategoryID); foreach (var attr in category.AttrLists) { ProductAttr attrModel = new ProductAttr(); attrModel.AttrName = attr.AttrName; attrModel.AttrValues = new List <AttrValue>(); foreach (var value in attr.AttrValues) { if (model.AttrValueList.IndexOf(value.ValueID) >= 0) { attrModel.AttrValues.Add(value); model.AttrLists.Add(attrModel); break; } } } model.SaleAttrs = category.SaleAttrs; } model.ProductDetails = new List <ProductDetail>(); foreach (DataRow item in ds.Tables["Details"].Rows) { ProductDetail detail = new ProductDetail(); detail.FillData(item); detail.DetailStocks = new List <ProductStock>(); foreach (var stocktr in ds.Tables["Stocks"].Select("ProductDetailID='" + detail.ProductDetailID + "'")) { ProductStock stock = new ProductStock(); stock.FillData(stocktr); detail.DetailStocks.Add(stock); } model.ProductDetails.Add(detail); } } return(model); }