Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. @FXML
  2. public void addProductToOrder(){
  3.  
  4. String nameOfProduct=selectedProduct.getSelectionModel().getSelectedItem().getName();
  5. String count = countOfProduct.getText();
  6. int amountOfProduct = Integer.parseInt(count);
  7. double priceOfProduct =selectedProduct.getSelectionModel().getSelectedItem().getPrice();
  8. Product product = new Product(nameOfProduct,amountOfProduct,priceOfProduct);
  9.  
  10. if(DataBase.getInstance().reduceProductAmountIfPossible(selectedProduct.getSelectionModel().getSelectedItem(),amountOfProduct)){
  11. tableViewOrder.getItems().add(product);
  12. }
  13. else{
  14.  
  15. Alert alert = new Alert(Alert.AlertType.ERROR);
  16. alert.setHeaderText("Nie mamy tyle towaru");
  17. alert.showAndWait();
  18. }
  19. costOfOrder.setText(sumOfOrder()+ " zł");
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement