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 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 void Save(Customer customer)
 {
     customer.Save();
 }
    private void InsertCustomer()
    {
        InventorySystem.Business.Customer customer = new InventorySystem.Business.Customer();
        CustomerModule customerModule = new CustomerModule();
        if (ViewState["id"] != null)
            customer.Id = Convert.ToInt32(ViewState["id"]);

        customer.Name = txtCustName.Text;
        customer.Company = txtCustCompName.Text;
        customer.Address = txtCustAddress.Text;
        customer.Website = txtCustWebsite.Text;
        customer.Remarks = txtCustRemarks.Text;
        customer.Email = txtCustEmail.Text;
        customer.Fax = txtCustFaxNo.Text;
        customer.PostCode = txtCustPostalCode.Text;
        //customer.Country = txtCustCountry.Text;
        customer.Country = ddlCountry.TextField;
        customer.PhoneNo = txtCustPhoneNo.Text;
        customer.Rating = RatingExample.CurrentRating;
        customerModule.Save(customer);
    }
        private Customer PopulateReader(IDataReader dr)
        {
            Customer customer = new Customer();
            customer.Id = Convert.ToInt32(dr["id"]);
            customer.Company = dr["Company"].ToString();
            customer.Name = dr["Name"].ToString();
            customer.PhoneNo = dr["PhoneNo"].ToString();
            customer.Email = dr["Email"].ToString();
            customer.Fax = dr["Fax"].ToString();
            customer.Address = dr["Address"].ToString();
            customer.Website = dr["Website"].ToString();
            customer.Remarks = dr["Remarks"].ToString();
            customer.PostCode = dr["PostCode"].ToString();
            customer.Country = dr["Country"].ToString();
            customer.Rating = Int32.Parse(dr["Rating"].ToString());

            return customer;
        }