Ejemplo n.º 1
0
        private void viewRestaurantIncomeBtn_Click(object sender, RoutedEventArgs e)
        {
            RestaurantTransactionMediator mediator = new RestaurantTransactionMediator();

            transactionView.ItemsSource = mediator.getAllRestaurantTransaction();
            totalIncomeLbl.Text         = "Total Income = Rp. " + mediator.getRestaurantIncome().ToString();

            transactionIDTxt.Visibility      = Visibility.Visible;
            transactionIDLbl.Visibility      = Visibility.Visible;
            transactionDetailView.Visibility = Visibility.Visible;
        }
        public RestaurantTransaction createNewRestaurantTransaction(int seatID)
        {
            RestaurantTransactionMediator mediator = new RestaurantTransactionMediator();

            RestaurantTransaction transaction = new RestaurantTransaction();

            transaction.transactionID = mediator.getLastID() + 1;
            transaction.employeeID    = Session.getSession().employee.employeeID;
            transaction.seatID        = seatID;
            transaction.purchaseDate  = DateTime.Now;

            return(transaction);
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
        private void transactionIDTxt_TextChanged(object sender, TextChangedEventArgs e)
        {
            string transactionIDStr = transactionIDTxt.Text.Trim();
            int    transactionID;

            bool success = int.TryParse(transactionIDStr, out transactionID);

            if (!success && transactionIDTxt.Text != "")
            {
                errorLbl.Text = "Transaction ID is not a number";
            }
            else
            {
                errorLbl.Text = "";
                RestaurantTransactionMediator mediator = new RestaurantTransactionMediator();
                if (mediator.getAllDetailRestaurantTransaction(transactionID) == null)
                {
                    transactionDetailView.ItemsSource = null;
                    return;
                }
                transactionDetailView.ItemsSource = mediator.getAllDetailRestaurantTransaction(transactionID);
            }
        }