Ejemplo n.º 1
0
  public void confirmItem(ActionEvent actionEvent) {
    orderBox.setDisable(true);
    subtotalLabel.setText("Order subtotal for " + myOrders.size() + " items:");
    subtotalBox.setText(String.valueOf(Order.getRunningTotal()));

    if (myOrders.size() < numberOfOrders) {
      IDLabel.setText("Enter Book ID for Item #" + (myOrders.size() + 1) + ":");
      quantityLabel.setText("Enter quantity for Item #" + (myOrders.size() + 1) + ":");
      infoLabel.setText(String.format("Item #%d info", myOrders.size() + 1));

      processBtn.setText(String.format("Process Item #%d", myOrders.size() + 1));
      confirmBtn.setText(String.format("Confirm Item #%d", myOrders.size() + 1));
      processBtn.setDisable(false);
    }

    IDBox.setText("");
    quantityBox.setText("");

    confirmBtn.setDisable(true);
    viewBtn.setDisable(false);
    finishBtn.setDisable(false);
    Alert alert =
        new Alert(
            Alert.AlertType.INFORMATION,
            "Item #" + (myOrders.size()) + " accepted",
            ButtonType.YES);
    alert.show();
  }
Ejemplo n.º 2
0
  public void newOrder(ActionEvent actionEvent) {
    Order.resetOrder();
    numberOfOrders = 0;
    myOrders = new ArrayList<>();

    processBtn.setDisable(false);
    confirmBtn.setDisable(true);
    viewBtn.setDisable(true);
    finishBtn.setDisable(true);
    orderBox.setDisable(false);

    orderBox.setText("");
    IDBox.setText("");
    quantityBox.setText("");
    infoBox.setText("");
    subtotalBox.setText("");

    IDLabel.setText("Enter Book ID for Item #" + (myOrders.size() + 1) + ":");
    quantityLabel.setText("Enter quantity for Item #" + (myOrders.size() + 1) + ":");
    infoLabel.setText(String.format("Item #%d info", myOrders.size() + 1));

    processBtn.setText(String.format("Process Item #%d", myOrders.size() + 1));
    confirmBtn.setText(String.format("Confirm Item #%d", myOrders.size() + 1));
    subtotalLabel.setText("Order subtotal for " + myOrders.size() + " items:");
  }
Ejemplo n.º 3
0
  public void processItem(ActionEvent actionEvent) {
    if (!orderBox.getText().equals("")
        && !IDBox.getText().equals("")
        && !quantityBox.getText().equals("")) {
      numberOfOrders = Integer.parseInt(orderBox.getText());
      int quantity = Integer.parseInt(quantityBox.getText());
      String ID = IDBox.getText();

      BookEntry book = BookDatabase.search(ID);

      if (myOrders == null) {
        myOrders = new ArrayList<>();
      }

      Alert alert = new Alert(Alert.AlertType.ERROR, "Book ID " + ID + " not found", ButtonType.OK);

      if (book != null) {
        myOrders.add(new Order(book, quantity));
        infoBox.setText(myOrders.get(myOrders.size() - 1).toString());
        processBtn.setDisable(true);
        confirmBtn.setDisable(false);
      } else alert.show();
    }
  }