public List <CustomerGateway> GetCustomers() { List <CustomerGateway> results = null; using (SqlConnection conn = new SqlConnection(customer.GetConnectionString())) { SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandText = customer.selectAllStatement; conn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) { results = new List <CustomerGateway>(); } while (reader.Read()) { CustomerGateway cust = new CustomerGateway(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDateTime(3), reader.GetString(4)); results.Add(cust); } } return(results); }
public List <CustomerGateway> GetCustomerByFirstName() { List <CustomerGateway> results = null; using (SqlConnection conn = new SqlConnection(customer.GetConnectionString())) { SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandText = customer.selectByNameStatement; sqlCmd.Parameters.Add(new SqlParameter("FirstName", customer.FirstName)); conn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) { results = new List <CustomerGateway>(); } while (reader.Read()) { CustomerGateway cust = new CustomerGateway(Convert.ToInt32(reader.GetDecimal(0)), reader.GetString(1), reader.GetString(2), reader.GetDateTime(3), reader.GetString(4)); results.Add(cust); } } return(results); }
static void Main(string[] args) { CustomerGateway eklenecek = new CustomerGateway(); eklenecek.Country = "Türkiye"; eklenecek.DateOfBorn = Convert.ToDateTime("1990-03-28"); eklenecek.FirstName = "Hasan"; eklenecek.LastName = "Mehmet"; int customerId=eklenecek.AddCustomer(); CustomerGateway guncellenecek = new CustomerGateway(); guncellenecek.Id = customerId; guncellenecek.Country = "Türkiye"; guncellenecek.DateOfBorn = Convert.ToDateTime("1989-03-28"); guncellenecek.FirstName = "Hasan"; guncellenecek.LastName = "Mehmet"; guncellenecek.UpdateCustomer(); CustomerGateway silinecek = new CustomerGateway(); silinecek.Id = customerId; silinecek.RemoveCustomer(); CustomerGateway singleRow = new CustomerGateway(); singleRow.Id = 5; CustomerFinder finder = new CustomerFinder(singleRow); finder.GetCustomerbyId(); }
static void Main(string[] args) { CustomerGateway eklenecek = new CustomerGateway(); eklenecek.Country = "Türkiye"; eklenecek.DateOfBorn = Convert.ToDateTime("1990-03-28"); eklenecek.FirstName = "Hasan"; eklenecek.LastName = "Mehmet"; int customerId = eklenecek.AddCustomer(); CustomerGateway guncellenecek = new CustomerGateway(); guncellenecek.Id = customerId; guncellenecek.Country = "Türkiye"; guncellenecek.DateOfBorn = Convert.ToDateTime("1989-03-28"); guncellenecek.FirstName = "Hasan"; guncellenecek.LastName = "Mehmet"; guncellenecek.UpdateCustomer(); CustomerGateway silinecek = new CustomerGateway(); silinecek.Id = customerId; silinecek.RemoveCustomer(); CustomerGateway singleRow = new CustomerGateway(); singleRow.Id = 5; CustomerFinder finder = new CustomerFinder(singleRow); finder.GetCustomerbyId(); }
public List<CustomerGateway> GetCustomerByFirstName() { List<CustomerGateway> results = null; using (SqlConnection conn = new SqlConnection(customer.GetConnectionString())) { SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandText = customer.selectByNameStatement; sqlCmd.Parameters.Add(new SqlParameter("FirstName", customer.FirstName)); conn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) results = new List<CustomerGateway>(); while (reader.Read()) { CustomerGateway cust = new CustomerGateway(Convert.ToInt32(reader.GetDecimal(0)), reader.GetString(1), reader.GetString(2), reader.GetDateTime(3), reader.GetString(4)); results.Add(cust); } } return results; }
public CustomerGateway GetCustomerbyId() { CustomerGateway cust = null; using (SqlConnection conn = new SqlConnection(customer.GetConnectionString())) { SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandText = customer.selectByIdStatement; sqlCmd.Parameters.Add(new SqlParameter("Id", customer.Id)); conn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { cust = new CustomerGateway(); cust.Id = reader.GetInt32(0); cust.FirstName = reader.GetString(1); cust.LastName = reader.GetString(2); cust.DateOfBorn = reader.GetDateTime(3); cust.Country = reader.GetString(4); } } return cust; }
public CustomerGateway GetCustomerbyId() { CustomerGateway cust = null; using (SqlConnection conn = new SqlConnection(customer.GetConnectionString())) { SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandText = customer.selectByIdStatement; sqlCmd.Parameters.Add(new SqlParameter("Id", customer.Id)); conn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { cust = new CustomerGateway(); cust.Id = reader.GetInt32(0); cust.FirstName = reader.GetString(1); cust.LastName = reader.GetString(2); cust.DateOfBorn = reader.GetDateTime(3); cust.Country = reader.GetString(4); } } return(cust); }
public CustomerFinder(CustomerGateway customer) { this.customer = customer; }
public CustomerFinder(CustomerGateway customer) { this.customer = customer; }
public List<CustomerGateway> GetCustomers() { List<CustomerGateway> results = null; using (SqlConnection conn = new SqlConnection(customer.GetConnectionString())) { SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = conn; sqlCmd.CommandText = customer.selectAllStatement; conn.Open(); SqlDataReader reader = sqlCmd.ExecuteReader(CommandBehavior.CloseConnection); if (reader.HasRows) results = new List<CustomerGateway>(); while (reader.Read()) { CustomerGateway cust = new CustomerGateway(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDateTime(3), reader.GetString(4)); results.Add(cust); } } return results; }
public Customer(CustomerGateway customerGateway) { this.customerGateway = customerGateway; }
public Customer(CustomerGateway customerGateway) { this.customerGateway = customerGateway; }