static void Main(string[] args) { //Customer customer1 = new Customer("Terry", "Jackson", "630-744-6969", "*****@*****.**"); //Customer customer2 = new Customer("Jason", "Voorhees", "630-744-6969", "*****@*****.**"); //List<Customer> customers = new List<Customer>(); //customers.Add(customer1); //customers.Add(customer2); //CustomerObjectToSerialize objectToSerialize = new CustomerObjectToSerialize(); //objectToSerialize.Customers = customers; CustomerSerializer serializer = new CustomerSerializer(); //serializer.SerializeObject("outputFile.txt", objectToSerialize); CustomerObjectToSerialize objectToSerialize = new CustomerObjectToSerialize(); objectToSerialize = serializer.DeSerializeObject("outputFile.txt"); List <Customer> customersFromFile = new List <Customer>(); customersFromFile = objectToSerialize.Customers; Customer customer3 = new Customer("Peter", "Jackson", "630-666-6969", "*****@*****.**"); customer3.AddFine(23.65m); customersFromFile.Add(customer3); foreach (Customer customer in customersFromFile) { Console.WriteLine(customer.ToString()); } }
public static ListView PopulateMainCustomersViewList(ListView l) { List <Customer> customersFromFile = new List <Customer>(); CustomerSerializer serializer = new CustomerSerializer(); CustomerObjectToSerialize serializedCustomers = new CustomerObjectToSerialize(); serializedCustomers = serializer.DeSerializeObject("customers.txt"); customersFromFile = serializedCustomers.Customers; foreach (Customer c in customersFromFile) { ListViewItem itm; string[] cust = new String[4]; cust[0] = c.GetAccountNumber().ToString(); cust[1] = c.GetFirstName() + " " + c.GetLastName(); cust[2] = c.GetPhoneNumber(); cust[3] = c.GetEmailAddress(); itm = new ListViewItem(cust); l.Items.Add(itm); } return(l); }
public static List <Customer> getCustomersList() { CustomerSerializer serializer = new CustomerSerializer(); CustomerObjectToSerialize serializedCustomers = new CustomerObjectToSerialize(); serializedCustomers = serializer.DeSerializeObject("customers.txt"); List <Customer> customersFromFile = new List <Customer>(); customersFromFile = serializedCustomers.Customers; return(customersFromFile); }
public static ComboBox PopulateCustomersComboBox(ComboBox c) { List <Customer> customersFromFile = new List <Customer>(); CustomerSerializer serializer = new CustomerSerializer(); CustomerObjectToSerialize serializedCustomers = new CustomerObjectToSerialize(); serializedCustomers = serializer.DeSerializeObject("customers.txt"); customersFromFile = serializedCustomers.Customers; foreach (Customer cus in customersFromFile) { c.Items.Add(cus.GetAccountNumber().ToString() + " " + cus.GetName()); } return(c); }
public static bool AddCustomerToExistingList(Customer c) { bool success = false; CustomerSerializer serializer = new CustomerSerializer(); CustomerObjectToSerialize serializedCustomers = new CustomerObjectToSerialize(); serializedCustomers = serializer.DeSerializeObject("customers.txt"); List <Customer> customersFromFile = new List <Customer>(); customersFromFile = serializedCustomers.Customers; customersFromFile.Add(c); CustomerObjectToSerialize newSerializedCustomers = new CustomerObjectToSerialize(); newSerializedCustomers.Customers = customersFromFile; serializer.SerializeObject("customers.txt", newSerializedCustomers); success = true; return(success); }
public static Customer GetCustomer(int id) { List <Customer> customersFromFile = new List <Customer>(); int index = 0; CustomerSerializer serializer = new CustomerSerializer(); CustomerObjectToSerialize serializedCustomers = new CustomerObjectToSerialize(); serializedCustomers = serializer.DeSerializeObject("customers.txt"); customersFromFile = serializedCustomers.Customers; foreach (Customer c in customersFromFile) { if (c.GetAccountNumber() == id) { break; } index++; } return(customersFromFile[index]); }