//Thêm bàn public void Add(Table table) { listtable.ListTable.Add(table); string fullpath = $@"{path}\{filename}"; ReadorWriteFile <Listtable> .WriteData(fullpath, listtable); }
// Đọc dữ liệu file chứa danh sách các bàn public Listtable ReadFile() { string fullpath = $@"{path}\{filename}"; ReadorWriteFile <Listtable> .ReadData(fullpath, ref listtable); return(listtable); }
// in bill public void PrintBill(Table table) { string billname = $"{DateTime.Now.ToString("ddMMyyyyhhmm")}_table_{table.TableId}"; ReadorWriteFile <Table> .WriteData($@"{path}\{billname}", table); string fulllink = $@"{path}\{filename}"; ReadorWriteFile <Listtable> .WriteData(fulllink, listtable); }
// Thêm đồ uống private static void UpdateTable() { try { Console.WriteLine("Enter id of table you want to add: "); int id = int.Parse(Console.ReadLine()); Table _table = admin.Check(id); if (_table != null) { if (_table.Status == 1) { do { _table.drinks.Add(Newdrink()); int ind = admin.listtable.ListTable.IndexOf(_table); admin.listtable.ListTable[ind].drinks = _table.drinks; string fulllink = $@"{path}\{filename}"; ReadorWriteFile<Listtable>.WriteData(fulllink, admin.listtable); Console.Clear(); Console.WriteLine(_table.ToString()); Console.WriteLine("Successfully"); Console.Write("Do you want to add more? y/n: "); } while (Console.ReadLine().ToLower() == "y"); } else { Console.WriteLine(_table.ToString()); Console.WriteLine("This table has already been paid or cancel!"); } } else { Console.WriteLine("Not found!"); } } catch (Exception e) { Console.WriteLine($"{e.GetType()}, {e.Message}"); UpdateTable(); } }