static void Main(string[] args) { SalesDatabase db = new Sales501.SalesDatabase(); Console.WriteLine("\n 1) Cashier GUI \n"); Console.WriteLine(" 2) Customer Service \n"); Console.WriteLine(" 3) Rebate \n"); Console.WriteLine(" 4) Console GUI \n"); Console.WriteLine(" 5) Quit \n"); Console.WriteLine("------------------"); char a = '0'; while (a != '5') { Console.Write("Select an option: "); a = Console.ReadLine()[0]; switch (a) { case '1': Console.Write("\nEnter the date(MM/DD): "); DateTime date = new DateTime(); bool successfulDate = false; while (!successfulDate) { try { date = Convert.ToDateTime(Console.ReadLine()); successfulDate = true; } catch (Exception err) { Console.WriteLine("Enter a valid date."); } } CashierModel cm = new CashierModel(db); CashierController cc = new CashierController(cm); CashierGUI cg = new CashierGUI(cm, date, cc.handleRemoveItem, cc.handleAddItem, cc.handleCompleteSale, cc.handleCreateSale); cm.register(cg.update); var t = new Thread(() => cashGUI(cg)); t.Start(); break; case '2': CustomerServiceModel csm = new CustomerServiceModel(db); CustomerServiceController csc = new CustomerServiceController(csm); CustomerServiceGUI csGUI = new CustomerServiceGUI(csm, csc.HandleGetSale, csc.HandleReturnItem); csm.register(csGUI.update); var r = new Thread(() => servGUI(csGUI)); r.Start(); break; case '3': RebateModel rm = new RebateModel(db); RebateController rc = new RebateController(rm); RebateGUI rGUI = new RebateGUI(rm, rc.handleGenerateRebate, rc.handleEnterRebate); rm.register(rGUI.update); var re = new Thread(() => rebateGUI(rGUI)); re.Start(); break; case '4': ConsoleGUI(db); Console.Clear(); Console.WriteLine("\n 1) Cashier GUI \n"); Console.WriteLine(" 2) Customer Service \n"); Console.WriteLine(" 3) Rebate \n"); Console.WriteLine(" 4) Console GUI \n"); Console.WriteLine(" 5) Quit \n"); Console.WriteLine("------------------"); break; case '5': Application.Exit(); break; default: Console.WriteLine("Enter a number 1-5 \n"); a = Console.ReadLine()[0]; break; } } }
static void cashGUI(CashierGUI cg) { Application.Run(cg); }