// Get all customers public List <Product> getAll() { BangazonConnection conn = new BangazonConnection(); List <Product> list = new List <Product> (); // Execute the query to retrieve all customers conn.execute(@"select IdProduct, Name, Description, Price, IdProductType from Product" , (SqliteDataReader reader) => { while (reader.Read()) { list.Add(new Product { IdProduct = reader.GetInt32(0), Name = reader [1].ToString(), Description = reader [2].ToString(), Price = reader.GetDouble(3), IdProductType = reader.GetInt32(4) }); } } ); return(list); }
// Get a single customer public Customer get(int IdCustomer) { BangazonConnection conn = new BangazonConnection(); Customer c = null; conn.execute(@"select IdCustomer, FirstName, LastName, StreetAddress, City, StateProvince, PostalCode, PhoneNumber from customers where IdCustomer = " + IdCustomer, (SqliteDataReader reader) => { while (reader.Read()) { c = new Customer { id = reader.GetInt32(0), FirstName = reader [1].ToString(), LastName = reader [2].ToString(), StreetAddress = reader [3].ToString(), City = reader [4].ToString(), StateProvince = reader [5].ToString(), PostalCode = reader [6].ToString(), PhoneNumber = reader [7].ToString() }; } }); return(c); }
public void save() { string query = string.Format(@" insert into Product (Name, Description, Price, IdProductType) values ('{0}', '{1}', '{2}', 1); " , this.Name, this.Description, this.Price ); BangazonConnection conn = new BangazonConnection(); conn.insert(query); }
public void save() { string query = string.Format(@" insert into PaymentOption (IdCustomer, Name, AccountNumber) values ('{0}', '{1}', '{2}'); " , this.IdCustomer, this.Name, this.AccountNumber ); BangazonConnection conn = new BangazonConnection(); conn.insert(query); }
public void save() { string query = string.Format(@" insert into CustomerOrder (OrderNumber, DateCreated, IdCustomer, IdPaymentOption, ShippingMethod, Complete) values ('{0}', '{1}', {2}, {3}, '{4}', {5}); " , this.OrderNumber, this.DateCreated, this.IdCustomer, this.IdPaymentOption, this.ShippingMethod, this.Complete ); BangazonConnection conn = new BangazonConnection(); conn.insert(query); }
public void save() { string query = string.Format(@" insert into Customer (FirstName, LastName, StreetAddress, City, StateProvince, PostalCode, PhoneNumber) values ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}'); " , this.FirstName, this.LastName, this.StreetAddress, this.City, this.StateProvince, this.PostalCode, this.PhoneNumber ); BangazonConnection conn = new BangazonConnection(); conn.insert(query); }
// Get all customers public List <Customer> getAll() { BangazonConnection conn = new BangazonConnection(); List <Customer> list = new List <Customer> (); // Execute the query to retrieve all customers conn.execute(@"select IdCustomer, FirstName, LastName, StreetAddress, City, StateProvince, PostalCode, PhoneNumber from customer" , (SqliteDataReader reader) => { while (reader.Read()) { list.Add(new Customer { id = reader.GetInt32(0), FirstName = reader [1].ToString(), LastName = reader [2].ToString(), StreetAddress = reader [3].ToString(), City = reader [4].ToString(), StateProvince = reader [5].ToString(), PostalCode = reader [6].ToString(), PhoneNumber = reader [7].ToString() }); } } ); return(list); }