public TableOverview(Employee employee) // Employee { InitializeComponent(); this.Employee = employee; Service = new TableOverview_Service(); BtnListTable = new Button[10] { btnTable1, btnTable2, btnTable3, btnTable4, btnTable5, btnTable6, btnTable7, btnTable8, btnTable9, btnTable10 }; BtnListBar = new Button[10] { btnBar1, btnBar2, btnBar3, btnBar4, btnBar5, btnBar6, btnBar7, btnBar8, btnBar9, btnBar10 }; BtnListKitchen = new Button[10] { btnKitchen1, btnKitchen2, btnKitchen3, btnKitchen4, btnKitchen5, btnKitchen6, btnKitchen7, btnKitchen8, btnKitchen9, btnKitchen10 }; ButtonImages = new Dictionary <Images, Image>(); LoadImages(); TableList = Service.GetTableList(); ActiveOrderlist = Service.GetActiveOrderList(); ActiveOrderProductList = Service.GetActiveOrderProductList(); ProductList = Service.GetProductList(); UpdateTableStatus(); ServiceBtnUpdate(); InfoEmployee(); InitializeTimer(); }
/// <summary> /// This method is for the buttons btnTable. This button opens the Order form with the right tablenumber. If the table.Status is 'free' it will set the table.status to 'occupied' and creates a new Order Object. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnTable1_Click(object sender, EventArgs e) { Button btn = (Button)sender; int tableIndex = int.Parse(btn.Text) - 1; TableList = Service.GetTableList(); ChapooModels.Order order; if (TableList[tableIndex].Status == "free") { string message = "Do you want to set this table occupied."; string title = "Assign table"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show(message, title, buttons); if (result == DialogResult.Yes) { order = new ChapooModels.Order(); Service.CreateOrder(Employee.EmployeeId, "new", TableList[tableIndex].TableNumber); TableList[tableIndex].OrderId = Service.GetOrderId(tableIndex + 1); btn.BackgroundImage = ButtonImages[Images.btnTableGreen]; Service.UpdateTableStatus((tableIndex + 1), "occupied"); } } else { TableList[tableIndex].OrderId = Service.GetOrderId(tableIndex + 1); Order orderForm = new Order(Employee, TableList[tableIndex]); this.Hide(); orderForm.ShowDialog(); this.Close(); } }