Esempio n. 1
0
 private void NewTableOrder(Table table)
 {
     ChapeauLogic.OrderService orderService = new ChapeauLogic.OrderService();
     if (table.status == OrderStatus.free.ToString())
     {
         DialogResult dialog = MessageBox.Show("Do you want to make a reservation?", "Reservation", MessageBoxButtons.YesNo);
         if (dialog == DialogResult.Yes)
         {
             table.status = OrderStatus.reserved.ToString();
             orderService.UpdateTable(table);
             TableStatusCheck(table);
         }
         else
         {
             this.Hide();
             MenuStartPage orderSelect = new MenuStartPage(Employee, table);
             orderSelect.ShowDialog();
             this.Close();
         }
     }
     else if (table.status == OrderStatus.reserved.ToString())
     {
         DialogResult dialog = MessageBox.Show("Is the table ready to order or would you like to cancel Reservation?", "Reservation", MessageBoxButtons.YesNoCancel);
         if (dialog == DialogResult.Yes)
         {
             this.Hide();
             MenuStartPage orderSelect = new MenuStartPage(Employee, table);
             orderSelect.ShowDialog();
             this.Close();
         }
         else if (dialog == DialogResult.Cancel)
         {
             table.status = OrderStatus.free.ToString();
             orderService.UpdateTable(table);
             TableStatusCheck(table);
         }
     }
     else
     {
         DialogResult dialog = MessageBox.Show("View Order", "View", MessageBoxButtons.YesNo);
         if (dialog == DialogResult.Yes)
         {
             this.Hide();
             Payment viewOrder = new Payment(Employee, table);
             viewOrder.ShowDialog();
             this.Close();
         }
     }
 }
        private void btn_Confirm_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < gridV_Drinks.Rows.Count; i++)
            {
                OrderMenuItem item = new OrderMenuItem()
                {
                    menuItemID = int.Parse(gridV_Drinks.Rows[i].Cells[0].Value.ToString()),
                    price      = double.Parse(gridV_Drinks.Rows[i].Cells[2].Value.ToString()),
                    quantity   = int.Parse(gridV_Drinks.Rows[i].Cells[3].Value.ToString()),
                    comments   = "No comment",
                };
                orderMenuItems.Add(item);
            }

            try
            {
                orderServices.NewOrder(table, employee);
                table.status = OrderStatus.occupied.ToString();
                orderServices.UpdateTable(table);

                Order order = orderServices.getId(table, employee);
                foreach (OrderMenuItem menuItems in orderMenuItems)
                {
                    orderServices.InsertMenu(menuItems, order.OrderID);
                    orderServices.UpdateStock(menuItems);
                }
                ;

                this.Hide();
                TablePage waiterPage = new TablePage(employee);
                waiterPage.ShowDialog();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }