private void searchOrderBtn_Click(object sender, RoutedEventArgs e)
        {
            string seatIDStr = seatIDTxt.Text.Trim();

            bool success = int.TryParse(seatIDStr, out seatID);

            if (!success)
            {
                errorLbl.Text = "Seat ID is not a number";
            }
            else
            {
                errorLbl.Text = "";
                OrderMediator mediator      = new OrderMediator();
                Order         customerOrder = mediator.getOrderBySeat(seatID);

                if (customerOrder == null)
                {
                    errorLbl.Text = "Seat is empty!";
                    return;
                }
                var orderDetail = mediator.getAllOrderDetail(customerOrder.orderID);
                orderDetailView.ItemsSource = orderDetail;

                totalPrice                 = mediator.getTotalPrice(customerOrder.orderID);
                tax                        = ((totalPrice * 10) / 100);
                totalPriceTxt.Text         = "Total Price = \t\tRp. " + totalPrice.ToString();
                taxTxt.Text                = "Tax = \t\t\tRp. " + tax.ToString();
                totalPriceAfterTaxTxt.Text = "Total Price After Tax = \tRp. " + (totalPrice + tax).ToString();
            }
        }
        private void checkOutButton_Click(object sender, RoutedEventArgs e)
        {
            string paymentStr = paymentTxt.Text.Trim();
            int    payment;

            bool success = int.TryParse(paymentStr, out payment);

            if (!success)
            {
                errorLbl.Text = "Payment must be a number!";
            }
            else if (totalPrice == 0 || tax == 0)
            {
                errorLbl.Text = "Please input Seat ID!";
            }
            else
            {
                int change = (totalPrice + tax) - payment;
                if (change > 0)
                {
                    errorLbl.Text = "Payment is not enough!";
                }
                else if (change <= 0)
                {
                    SeatMediator  mediator      = new SeatMediator();
                    OrderMediator omediator     = new OrderMediator();
                    Order         customerOrder = omediator.getOrderBySeat(seatID);

                    changeTxt.Text = "Change = \t\tRp. " + Math.Abs(change).ToString();

                    RestaurantTransactionMediator tmediator   = new RestaurantTransactionMediator();
                    RestaurantTransactionFactory  tfactory    = new RestaurantTransactionFactory();
                    RestaurantTransaction         transaction = tmediator.addRestaurantTransaction(tfactory.createNewRestaurantTransaction(seatID));
                    if (tmediator.addDetailRestaurantTransaction(transaction.transactionID, customerOrder.orderID) == null)
                    {
                        MessageBox.Show("Checkout failed!");
                    }
                    else
                    {
                        MessageBox.Show("Checkout success!");
                    }

                    //update seat dan ordernya
                    Seat customerSeat = mediator.getSeat(seatID);
                    customerSeat.status  = "Available";
                    customerSeat         = mediator.updateSeat(seatID, customerSeat);
                    customerOrder.status = "Finished";
                    customerOrder        = omediator.updateOrder(customerOrder.orderID, customerOrder);
                }
            }
        }
        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            string seatIDStr = seatIDTxt.Text.Trim();
            string foodIDStr = foodIDTxt.Text.Trim();
            string quantityStr = quantityTxt.Text.Trim();
            int    seatID, foodID, quantity;

            bool success  = int.TryParse(seatIDStr, out seatID);
            bool success2 = int.TryParse(foodIDStr, out foodID);
            bool success3 = int.TryParse(quantityStr, out quantity);

            if (!success)
            {
                errorLbl.Text = "Seat ID must be a number";
            }
            else if (!success2)
            {
                errorLbl.Text = "Food ID must be a number";
            }
            else if (!success3)
            {
                errorLbl.Text = "Quantity must be a number";
            }
            else
            {
                OrderMediator mediator  = new OrderMediator();
                SeatMediator  smediator = new SeatMediator();
                FoodMediator  fmediator = new FoodMediator();
                OrderFactory  factory   = new OrderFactory();

                Order order = mediator.getOrderBySeat(seatID);
                Seat  seat  = smediator.getSeat(seatID);
                Food  food  = fmediator.getFood(foodID);

                if (seat == null)
                {
                    errorLbl.Text = "Seat doesn't exist";
                    return;
                }

                if (food == null)
                {
                    errorLbl.Text = "Food doesn't exist";
                    return;
                }

                if (order == null)
                {
                    mediator.addOrder(factory.createNewOrder(seatID));

                    seat.status = "Unavailable";
                    seat        = smediator.updateSeat(seatID, seat);
                }

                order = mediator.getOrderBySeat(seatID);
                OrderDetail existingOrder = mediator.getOrderDetail(order.orderID, foodID);
                OrderDetail orderDetail;
                if (existingOrder == null)
                {
                    orderDetail = mediator.addOrderDetail(factory.createNewOrderDetail(order.orderID, foodID, quantity));
                }
                else
                {
                    existingOrder.quantity += quantity;
                    orderDetail             = mediator.updateOrderDetail(order.orderID, existingOrder);
                }
                if (orderDetail == null)
                {
                    MessageBox.Show("Input order failed!");
                }
                else
                {
                    MessageBox.Show("Input order success!");
                }
            }
        }