Пример #1
0
        public Product GetProduct(int ID)
        {
            DataSet ds         = StoreDB2.ReadDataSet();
            DataRow productRow = ds.Tables["Products"].Select("ProductID = " + ID.ToString())[0];
            Product product    = new Product((string)productRow["ModelNumber"],
                                             (string)productRow["ModelName"], (decimal)productRow["UnitCost"],
                                             (string)productRow["Description"], (string)productRow["CategoryName"],
                                             (string)productRow["ProductImage"]);

            return(product);
        }
Пример #2
0
        public ICollection <Product> GetProducts()
        {
            DataSet ds = StoreDB2.ReadDataSet();

            ObservableCollection <Product> products = new ObservableCollection <Product>();

            foreach (DataRow productRow in ds.Tables["Products"].Rows)
            {
                products.Add(new Product((string)productRow["ModelNumber"],
                                         (string)productRow["ModelName"], (decimal)productRow["UnitCost"],
                                         (string)productRow["Description"], (string)productRow["CategoryName"],
                                         (string)productRow["ProductImage"]));
            }
            return(products);
        }
Пример #3
0
        public ICollection <Category> GetCategoriesAndProducts()
        {
            DataSet      ds = StoreDB2.ReadDataSet();
            DataRelation relCategoryProduct = ds.Relations[0];

            ObservableCollection <Category> categories = new ObservableCollection <Category>();

            foreach (DataRow categoryRow in ds.Tables["Categories"].Rows)
            {
                ObservableCollection <Product> products = new ObservableCollection <Product>();
                foreach (DataRow productRow in categoryRow.GetChildRows(relCategoryProduct))
                {
                    products.Add(new Product(productRow["ModelNumber"].ToString(),
                                             productRow["ModelName"].ToString(), (decimal)productRow["UnitCost"],
                                             productRow["Description"].ToString()));
                }
                categories.Add(new Category(categoryRow["CategoryName"].ToString(), products));
            }
            return(categories);
        }
Пример #4
0
 public DataSet GetCategoriesAndProducts()
 {
     return(StoreDB2.ReadDataSet());
 }
Пример #5
0
 public DataTable GetProducts()
 {
     return(StoreDB2.ReadDataSet().Tables[0]);
 }