public CustomerContainer LoadAllFromBinary() { CustomerContainer cc = new CustomerContainer(); Stream stream = File.Open("customersBin\\Customer_List.dat", FileMode.OpenOrCreate); BinaryFormatter bf = new BinaryFormatter(); try { if (stream.Length > 0) { cc = (CustomerContainer)bf.Deserialize(stream); } else { cc = new CustomerContainer(); } } catch (SerializationException e) { Console.WriteLine(e.Message); } stream.Close(); return(cc); }
public void SaveAllToBinary(CustomerContainer cc) { Stream stream = File.OpenWrite("customersBin\\Customer_List.dat"); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(stream, cc); stream.Close(); }
public void DeleteAll(CustomerContainer cc) { foreach (Customer c in cc.customers) { DeleteCustomer(c); } File.Delete("customersBin\\Customer_List.dat"); }
public void Init() { S = DataManager.S.LoadAllFromBinary(); Console.WriteLine("Customer Count: " + customers.Count); if (customers.Count > 0) { currentID = customers[customers.Count - 1].CustomerID; } else { currentID = 0; } }