public static void Neworder() { Console.WriteLine("Tableid "); int.TryParse(Console.ReadLine(), out int id); if (!ace.Check(id)) { Table table = new Table(); table.Tableid = id; bool result = false; do { OrrderDetail order = new OrrderDetail(); Console.WriteLine("Name "); order.Name = Console.ReadLine().ToLower(); Console.WriteLine("Price "); order.Price = long.Parse(Console.ReadLine()); Console.WriteLine("Count "); order.Count = int.Parse(Console.ReadLine()); result = true; Console.WriteLine("Bạn có muốn gọi món tiếp "); int.TryParse(Console.ReadLine(), out int indi); if (indi == 1) { Console.Clear(); Console.WriteLine(table.Tableid); } else { result = false; } bool check = false; foreach (OrrderDetail pb in table.OrrderDetails) { if (pb.Name.ToLower().Equals(order.Name)) { pb.Count += order.Count; check = true; } } if (check == false) { table.OrrderDetails.Add(order); } } while (result); table.Endtime = DateTime.Now.ToString(); ace.NewOrder(table); } else { Console.WriteLine("Is Not Complete"); } }
public static void Update() { Console.WriteLine("Tableid "); int.TryParse(Console.ReadLine(), out int id); if (ace.Check(id)) { bool result = true; do { OrrderDetail order = new OrrderDetail(); Console.WriteLine("Name "); order.Name = Console.ReadLine().ToLower(); Console.WriteLine("Price "); order.Price = long.Parse(Console.ReadLine()); Console.WriteLine("Count "); order.Count = int.Parse(Console.ReadLine()); Console.WriteLine("Bạn có muốn gọi thêm món không"); int.TryParse(Console.ReadLine(), out id); if (id != 1) { result = false; } { Console.Clear(); Console.WriteLine("Tabled " + id); result = true; } bool check = false; foreach (OrrderDetail pb in ace.Tables[id].OrrderDetails) { if (pb.Name.ToLower().Equals(order.Name)) { pb.Count += order.Count; check = true; break; } } if (check == false) { ace.UpdateOrder(order, id); } } while (result); } else { Console.WriteLine("Not complete"); } }
public void UpdateOrder(OrrderDetail newfile, int id) { Tables[id].OrrderDetails.Add(newfile); }