예제 #1
0
        public Customer GetById(int id)
        {
            try
            {
                string sql = "SELECT Firstname, Lastname, Address, Woonplaats, Postcode, Email, Geboortedatum, Telefoonnummer FROM Customer WHERE CustomerID = @CustomerID";
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("@CustomerID", id.ToString())
                };

                DataSet  results = ExecuteSql(sql, parameters);
                Customer c       = DataSetParser.DataSetToCustomer(results, 0);
                return(c);
            }
            catch
            {
                return(null);
            }
        }
예제 #2
0
        public List <Customer> GetAll()
        {
            List <Customer> CustomerList = new List <Customer>();

            try
            {
                string sql = "SELECT CustomerId, FirstName, LastName, Address, Woonplaats, Postcode, Email, GeboorteDatum, Telefoonnummer FROM Customer";

                DataSet results = ExecuteSql(sql, new List <KeyValuePair <string, string> >());

                for (int x = 0; x < results.Tables[0].Rows.Count; x++)
                {
                    Customer c = DataSetParser.DataSetToCustomer(results, x);
                    CustomerList.Add(c);
                }
                return(CustomerList);
            }
            catch
            {
                return(null);
            }
        }