//constructor //retrieves all customers from the table so they can be viewed by staff public clsCustomerCollection() { int index = 0; int recordCount = 0; clsDataConnection database = new clsDataConnection(); database.Execute("sproc_CustomerTable_SelectAll"); recordCount = database.Count; //while records exist while (index < recordCount) { clsCustomer aCustomer = new clsCustomer(); aCustomer.CustomerID = Convert.ToInt32(database.DataTable.Rows[index]["CustomerId"]); aCustomer.name = Convert.ToString(database.DataTable.Rows[index]["FirstName"]); aCustomer.surname = Convert.ToString(database.DataTable.Rows[index]["SurName"]); aCustomer.DOB = Convert.ToDateTime(database.DataTable.Rows[index]["DateOfBirth"]); aCustomer.PhoneNumber = Convert.ToInt32(database.DataTable.Rows[index]["PhoneNumber"]); aCustomer.email = Convert.ToString(database.DataTable.Rows[index]["Email"]); aCustomer.Address = Convert.ToString(database.DataTable.Rows[index]["Address"]); mCustomerList.Add(aCustomer); index++; } }
public void setCustomer(clsCustomer newCustomer) { thisCustomer = newCustomer; }