private void bestelBtn_Click(object sender, EventArgs e) { orderService = new Order_Service(); tableService = new Table_Service(); order.EmployeeId = employee.Id; billService = new Bill_Service(); try { bill = billService.GetBillByTableId(tafel.Number); } catch (Exception d) { orders = new List <Order>(); bill = new Bill(DateTime.Now, tafel, orders, employee, false); billService.AddBill(bill); MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information); orderService.AddOrderWhereBillIdIs(order, bill.Id); tafel.Occupied = true; tableService.ModifyTable(tafel); return; } if (bill.Payed == false) { orderService.AddOrderWhereBillIdIs(order, bill.Id); MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { orders = new List <Order>(); bill = new Bill(DateTime.Now, tafel, orders, employee, false); billService.AddBill(bill); MessageBox.Show("Bestelling is geplaatst.", "Attentie", MessageBoxButtons.OK, MessageBoxIcon.Information); orderService.AddOrderWhereBillIdIs(order, bill.Id); tafel.Occupied = true; tableService.ModifyTable(tafel); } foreach (Dish dish in order.Dishes) { dishService = new Dish_Service(); dishService.ModifyStock(dish.Id, dish.Stock - 1); } foreach (Drink drink in order.Drinks) { drinkService = new Drink_Service(); drinkService.ModifyStock(drink.Id, drink.Stock - 1); } order = new Order(); }
private void Bill_btnPay_Click(object sender, EventArgs e) { Bill bill = bill_service.GetBillByTableId(tableId); bill_service.ModifyBillToPayed(bill); table.Occupied = false; table_service.ModifyTable(table); Bill_btnAfrekenen_Click(null, null); }