Ejemplo n.º 1
0
        private void Btn_BestellingPlaatsen_Click(object sender, EventArgs e) //bestellingen versturen naar db
        {
            int recentOrderID = 0;

            if (listViewWinkelwagen.Items.Count == 0) //check of alle velden zijn ingevuld
            {
                MessageBox.Show("Vul alle velden in.", "Foutmelding", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Table            currentTable     = Table.GetTable();
                MenuItem_Service menuItem_Service = MenuItem_Service.GetMenuItemService();
                Table_Service    table_Service    = Table_Service.GetTableService();
                Login_Service    s = Login_Service.GetLoginService();
                int reservationID  = table_Service.GetReservationID(currentTable.currentTable.TableID); //reservationID vinden van betreffende tafel
                if (reservationID == 0)
                {
                    MessageBox.Show("Er is geen reservering voor deze tafel.", "Foutmelding", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    Order_Service service = Order_Service.GetOrderService();
                    if (service.PlaceOrder(reservationID, s.CurrentEmployee.Id))
                    {
                        recentOrderID = GetMostRecentOrderID();
                        List <MenuOrder> menuOrders    = new List <MenuOrder>();
                        MenuOrder_DAO    menuOrder_DAO = new MenuOrder_DAO();
                        foreach (ListViewItem li in listViewWinkelwagen.Items) //Lijst met MenuOrders maken vanuit winkelwagen
                        {
                            Model.MenuOrder menuOrder = new MenuOrder(int.Parse(li.SubItems[1].Text), recentOrderID, menuItem_Service.GetMenuItemID(li.Text));
                            menuOrders.Add(menuOrder);
                        }
                        foreach (MenuOrder menuOrder in menuOrders) //lijst met menuOrders naar db sturen
                        {
                            menuOrder_DAO.PlaceMenuOrder(menuOrder.Amount, menuOrder.OrderID, menuOrder.MenuItemID);
                            menuOrder_DAO.UpdateStock(menuOrder.Amount, menuOrder.MenuItemID);
                        }
                        OrderPlaced();
                        this.Refresh(); //zet scherm weer op default
                    }
                    else
                    {
                        MessageBox.Show("Niet gelukt om de order te maken.", "Foutmelding", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private int GetMostRecentOrderID()
        {
            Order_Service order_Service = Order_Service.GetOrderService();

            return(order_Service.GetMostRecentOrderID());
        }