コード例 #1
0
        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.SmallUnitID);

                model.AttrLists = new List<ProductAttr>();
                model.SaleAttrs = new List<ProductAttr>();

                model.Providers = new ProvidersEntity();
                if (!string.IsNullOrEmpty(model.ProdiverID))
                {
                    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;
                    }
                }

                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);
                    model.ProductDetails.Add(detail);
                }
            }

            return model;
        }
コード例 #2
0
        public List<Products> GetProductsAll(string categoryid, string prodiverid, string beginprice, string endprice, int ispublic, string keyWords, string orderby, bool isasc, int pageSize, int pageIndex, ref int totalCount, ref int pageCount)
        {
            var dal = new ProductsDAL();
            DataSet ds = dal.GetProductsAll(categoryid, prodiverid, beginprice, endprice, ispublic, keyWords, orderby, isasc ? 1 : 0, pageSize, pageIndex, ref totalCount, ref pageCount);

            List<Products> list = new List<Products>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Products model = new Products();
                model.FillData(dr);
                if (!string.IsNullOrEmpty(model.SmallUnitID))
                {
                    model.UnitName = GetUnitByID(model.SmallUnitID).UnitName;
                }
                model.IsPublicStr = CommonBusiness.GetEnumDesc((EnumProductPublicStatus)model.IsPublic);
                list.Add(model);
            }
            return list;
        }
コード例 #3
0
        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 = GetCategoryDetailByID(model.CategoryID);
                model.SmallUnit = GetUnitByID(model.SmallUnitID);

                if (!string.IsNullOrEmpty(model.ProdiverID))
                {
                    model.Providers = ProvidersBusiness.BaseBusiness.GetProviderByID(model.ProdiverID);
                }

                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;
        }
コード例 #4
0
        public List<Products> GetProductStocks(string keywords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string agentid, string clientid)
        {
            DataSet ds = StockDAL.BaseProvider.GetProductStocks(keywords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid);

            List<Products> list = new List<Products>();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                Products model = new Products();
                model.FillData(dr);
                list.Add(model);
            }
            return list;
        }