Esempio n. 1
0
        public ICollection <Category> GetCategories()
        {
            DataSet ds = StoreDbDataSet.ReadDataSet();
            ObservableCollection <Category> categories = new ObservableCollection <Category>();

            foreach (DataRow dr in ds.Tables["Categories"].Rows)
            {
                categories.Add(new Category((string)dr["CategoryName"], (int)dr["CategoryID"]));
            }
            return(categories);
        }
Esempio n. 2
0
        public Product GetProduct(int ID)
        {
            DataSet ds         = StoreDbDataSet.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"], (int)productRow["CategoryID"],
                                             (string)productRow["CategoryName"], (string)productRow["ProductImage"]);

            return(product);
        }
Esempio n. 3
0
        public ICollection <Product> GetProducts()
        {
            DataSet ds = StoreDbDataSet.ReadDataSet();

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

            foreach (DataRow productRow in ds.Tables["Products"].Rows)
            {
                products.Add(new Product(modelName: (string)productRow["ModelName"],
                                         year: (string)productRow["Year"], engineCapacity:
                                         (string)productRow["EngineCapacity"], description: (string)productRow["Description"]));
            }
            return(products);
        }
Esempio n. 4
0
        public ICollection <Product> GetProducts()
        {
            DataSet ds = StoreDbDataSet.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"], (int)productRow["CategoryID"],
                                         (string)productRow["CategoryName"], (string)productRow["ProductImage"]));
            }
            return(products);
        }
Esempio n. 5
0
        public ICollection <Category> GetCategoriesAndProducts()
        {
            DataSet      ds = StoreDbDataSet.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);
        }