Ejemplo n.º 1
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;
        }