Exemple #1
0
        public Product GetProduct(int ID)
        {
            DataSet ds         = StoreDbDataSet.ReadDataSet();
            DataRow productRow = ds.Tables["Products"].Select($"ProductID = {ID}")[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);
        }
Exemple #2
0
        public ICollection <Category> GetCategories()
        {
            DataSet ds = StoreDbDataSet.ReadDataSet();

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

            foreach (DataRow categoryRow in ds.Tables["Categories"].Rows)
            {
                categories.Add(new Category(categoryRow["CategoryName"].ToString(), (int)categoryRow["CategoryID"]));
            }
            return(categories);
        }
Exemple #3
0
        public ICollection <Product> GetProducts()
        {
            DataSet ds = StoreDbDataSet.ReadDataSet();

            DataRow[] productRows = ds.Tables["Products"].Select();
            ObservableCollection <Product> products = new ObservableCollection <Product>();

            foreach (DataRow productRow in productRows)
            {
                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);
        }
Exemple #4
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);
        }