示例#1
0
        public List <CustomerEntity> GetCustomersByKeywords(string keywords, string userid, string clientid)
        {
            List <CustomerEntity> list = new List <CustomerEntity>();
            DataSet ds = CustomDAL.BaseProvider.GetCustomersByKeywords(keywords, userid, clientid);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                CustomerEntity model = new CustomerEntity();
                model.FillData(dr);
                model.City = CommonBusiness.GetCityByCode(model.CityCode);
                list.Add(model);
            }
            return(list);
        }
示例#2
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);
        }