public bool Delete(string id)
 {
     using (CustomerDataAdapter adapter = new CustomerDataAdapter())
     {
         return adapter.DeleteCustomer(id);
     }
 }
 public Customer GetCustomerByEmail(string email)
 {
     Customer customer = new Customer();
     IDataReader dr = new CustomerDataAdapter().GetCustomerByEmail(email);
     if (dr.Read())
     {
         customer = PopulateReader(dr);
     }
     dr.Close();
     return customer;
 }
 public bool Insert(Customer customer)
 {
     using (CustomerDataAdapter adapter = new CustomerDataAdapter())
     {
         return adapter.InsertCustomer(customer.Company,
                                                         customer.Name, customer.PhoneNo, customer.Email,
                                                         customer.Fax,
                                                         customer.Address, customer.Website, customer.Remarks,
                                                         customer.PostCode
                                                         , customer.Country, customer.Rating);
     }
 }
        public string GetMaxId()
        {
            string maxid = string.Empty;
            IDataReader dr = new CustomerDataAdapter().GetMaxId();

            while (dr.Read())
            {
                maxid = dr["id"].ToString();
            }
            dr.Close();
            return maxid;
        }
 public Customer GetCustomersById(int id)
 {
     Customer customer = new Customer();
     using (IDataReader dr = new CustomerDataAdapter().GetCustomerByCode(id))
     {
         if (dr.Read())
         {
             customer = PopulateReader(dr);
         }
         dr.Close();
     }
     return customer;
 }
        public CustomerCollection GetCustomers()
        {
            CustomerCollection customers = new CustomerCollection();

            using(IDataReader dr = new CustomerDataAdapter().GetCustomers())
            {
            while (dr.Read())
            {
                customers.Add(PopulateReader(dr));
            }
            dr.Close();
            }
            return customers;
        }
        public bool IsCustomerExist(int id)
        {
            bool exist = false;

            using (IDataReader dr = new CustomerDataAdapter().GetCustomerByCode(id))
            {
                if (dr.Read())
                    exist = true;

                dr.Close();
            }

            return exist;
        }