static void Main(string[] args) { UserInfo User = new UserInfo(1, "Kymbatya", "*****@*****.**", "Utka city"); OrderDetails Order1 = new OrderDetails(1, 1, "RetakeCalc", 150, 1); OrderDetails Order2 = new OrderDetails(1, 2, "RetakePP", 200, 1); Booking Book = new Booking(User); Book.OrderList.Add(Order1); Book.OrderList.Add(Order2); UserInfo User2 = new UserInfo(2, "Alesha", "*****@*****.**", "Utka city"); OrderDetails Order21 = new OrderDetails(2, 1, "ACM", 150, 1); OrderDetails Order22 = new OrderDetails(2, 2, "IBM", 200, 1); Booking Book2 = new Booking(User2); Book2.OrderList.Add(Order21); Book2.OrderList.Add(Order22); BookList Books = new BookList(); Books.Books.Add(Book); Books.Books.Add(Book2); Books.SaveDB(Books); Books.Show(); Console.ReadKey(); }
public void SaveDB(BookList Books) { FileStream fs = new FileStream("bookings.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite); XmlSerializer xs = new XmlSerializer(typeof(BookList)); xs.Serialize(fs, Books); fs.Close(); }
public void Show() { FileStream fs = new FileStream("bookings.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite); XmlSerializer xs = new XmlSerializer(typeof(BookList)); BookList books = xs.Deserialize(fs) as BookList; fs.Close(); for (int i = 0; i < books.Books.Count; i++) { Console.WriteLine("User {0}: ", i); for (int j = 0; j < books.Books[i].OrderList.Count; j++) { Console.WriteLine(Books[i].OrderList[j].OrderID); Console.WriteLine(Books[i].OrderList[j].ItemID); Console.WriteLine(Books[i].OrderList[j].ItemName); Console.WriteLine(Books[i].OrderList[j].Total); } } }