diff --git a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java index 055c4be..03c5990 100644 --- a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java +++ b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java @@ -312,6 +312,8 @@ public class AllTreatmentController { @FXML public void handleLock(){ Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem(); + LocalDate today = LocalDate.now(); + if (selectedItem == null){ return; } @@ -322,6 +324,13 @@ public class AllTreatmentController { }catch (SQLException exception){ exception.printStackTrace(); } + if (selectedItem.calculateDeleteDate().isBefore(today) || selectedItem.calculateDeleteDate().equals(today)){ + try { + dao.delete(selectedItem.getId()); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } readAllAndShowInTableView(); }