Example #1
0
        public List <Product> GetAll()
        {
            try
            {
                string         sql       = "SELECT P.Id, P.Naam, P.Prijs, P.Grootte, P.Kleur, P.Beschrijving, P.Voorraad, C.Naam, P.CategorieId, P.Actief FROM Product as P INNER JOIN Categorie as C ON P.CategorieId = C.Id";
                List <Product> producten = new List <Product>();

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                };

                ExecuteSql(sql, parameters);

                DataSet result = ExecuteSql(sql, parameters);

                if (result != null && result.Tables[0].Rows.Count > 0)
                {
                    for (int x = 0; x < result.Tables[0].Rows.Count; x++)
                    {
                        Product p = DataSetParser.DataSetToProduct(result, x);
                        producten.Add(p);
                    }
                }

                return(producten);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #2
0
        public List <Product> Zoeken(string Zoekterm)
        {
            List <Product> productList = new List <Product>();

            try
            {
                string sql = "SELECT P.Id, P.Naam, P.Prijs, P.Grootte, P.Kleur, P.Beschrijving, P.Voorraad, C.Naam, P.CategorieId, P.Actief FROM Product as P INNER JOIN Categorie as C ON P.CategorieId = C.Id WHERE CHARINDEX(@zoekterm, P.Naam) > 0 ORDER BY P.Naam";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("zoekterm", Zoekterm),
                };

                DataSet results = ExecuteSql(sql, parameters);

                for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                {
                    Product p = DataSetParser.DataSetToProduct(results, x);
                    productList.Add(p);
                }
                return(productList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #3
0
        public List <Product> GetAllGames()
        {
            List <Product> productList = new List <Product>();

            try
            {
                string sql = "select Product.ProductID , Product.CategorieId, Product.Omschrijving,Product.naam,Product.Aantal, Product.Prijs, Product.Soort,Product.Actief,Product.Tweedehands,Product.Naam, Product.ImagePath from Product where CategorieId <= 9";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                };

                DataSet results = ExecuteSql(sql, parameters);

                for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                {
                    Product p = DataSetParser.DataSetToProduct(results, x);
                    productList.Add(p);
                }
                return(productList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #4
0
        public List <Product> Zoeken(string zoekterm)
        {
            List <Product> productList = new List <Product>();

            try
            {
                string sql = "SELECT Product.ProductID , Product.CategorieId, Product.Omschrijving, Product.naam, Product.Aantal, Product.Prijs, Product.Soort, Product.Actief, Product.Tweedehands, Categorie.Naam, Product.ImagePath FROM Product INNER JOIN Categorie ON Product.CategorieID = Categorie.CategorieID WHERE CHARINDEX(@zoekterm, Product.Naam) > 0 ORDER BY Product.Naam";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Zoekterm", zoekterm),
                };

                DataSet results = ExecuteSql(sql, parameters);

                for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                {
                    Product p = DataSetParser.DataSetToProduct(results, x);
                    productList.Add(p);
                }
                return(productList);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #5
0
        public Product GetById(long id)
        {
            try
            {
                string sql = "SELECT P.Id, P.Naam, P.Prijs, P.Grootte, P.Kleur, P.Beschrijving, P.Voorraad, C.Naam, P.CategorieId, P.Actief FROM Product as P INNER JOIN Categorie as C ON P.CategorieId = C.Id WHERE P.Id = @Id";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("Id", id.ToString()),
                };

                DataSet results = ExecuteSql(sql, parameters);
                Product p       = DataSetParser.DataSetToProduct(results, 0);
                return(p);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #6
0
        public Product GetById(long id)
        {
            try
            {
                string sql = "SELECT Product.ProductID , Product.CategorieId, Product.Omschrijving,Product.naam,Product.Aantal, Product.Prijs, Product.Soort,Product.Actief,Product.Tweedehands,Categorie.Naam, Product.ImagePath FROM Product INNER JOIN Categorie ON Product.CategorieID = Categorie.CategorieID WHERE ProductID =  @productID";

                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("productID", id.ToString()),
                };

                DataSet results = ExecuteSql(sql, parameters);
                Product p       = DataSetParser.DataSetToProduct(results, 0);
                return(p);
            }
            catch (Exception e)
            {
                throw e;
            }
        }