Example #1
0
        public List <ProductStock> GetProductsByKeywords(string wareid, string keywords, string agentid, string clientid)
        {
            DataSet ds = StockDAL.BaseProvider.GetProductsByKeywords(wareid, keywords, clientid);

            List <ProductStock> list = new List <ProductStock>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ProductStock model = new ProductStock();
                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);
        }
Example #2
0
        public List <ProductStock> GetDetailStocks(string wareid, string keywords, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string clientid)
        {
            DataSet ds = StockDAL.BaseProvider.GetDetailStocks(wareid, keywords, pageSize, pageIndex, ref totalCount, ref pageCount, clientid);

            List <ProductStock> list = new List <ProductStock>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ProductStock model = new ProductStock();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }
Example #3
0
        public List <ProductStock> GetProductsByKeywords(string wareid, string keywords, string clientid)
        {
            DataSet ds = StockDAL.BaseProvider.GetProductsByKeywords(wareid, keywords, clientid);

            List <ProductStock> list = new List <ProductStock>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ProductStock model = new ProductStock();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }
Example #4
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.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);
        }