From d2e41c06f24576ef0d21d79ecdbc15cf6d0ce427 Mon Sep 17 00:00:00 2001 From: Dorian Nemec Date: Fri, 17 May 2024 09:39:21 +0200 Subject: [PATCH] #7 Sperren/Entsperren --- db/nursingHome.db | Bin 28672 -> 28672 bytes .../treatment/AllTreatmentController.java | 23 +++++++++++++++--- .../treatment/LockedTreatmentController.java | 12 +++++++++ .../treatment/database/TreatmentDao.java | 2 +- .../nhplus/treatment/AllTreatmentView.fxml | 6 ++--- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/db/nursingHome.db b/db/nursingHome.db index 262eb5dc15564de7ecafe2545549e545414e66dc..73842f5c58e172082b9eb3ff9c492dcbddf26e0c 100644 GIT binary patch delta 26 icmZp8z}WDBae_3X;Y1l{M#GH>kEIwnH@ish2>}3pK?wW+ delta 26 icmZp8z}WDBae_3X&O{k!MxBibkEIwnHoHjg2>}3ostEA_ diff --git a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java index 3384c3f..df8b368 100644 --- a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java +++ b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java @@ -61,7 +61,7 @@ public class AllTreatmentController { public ComboBox comboBoxNurseSelection; @FXML - private Button buttonDelete; + private Button buttonLock; private final ObservableList treatments = FXCollections.observableArrayList(); private TreatmentDao dao; @@ -100,12 +100,12 @@ public class AllTreatmentController { this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description")); this.tableView.setItems(this.treatments); - this.buttonDelete.setDisable(true); + this.buttonLock.setDisable(true); this.tableView .getSelectionModel() .selectedItemProperty() .addListener((observableValue, oldTreatment, newTreatment) -> - AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null) + AllTreatmentController.this.buttonLock.setDisable(newTreatment == null) ); this.createComboBoxData(); @@ -316,4 +316,21 @@ public class AllTreatmentController { }); } + + @FXML + public void handleLock(){ + Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem(); + if (selectedItem == null){ + return; + } + + try { + selectedItem.setLocked(true); + this.dao.update(selectedItem); + }catch (SQLException exception){ + exception.printStackTrace(); + } + readAllAndShowInTableView(); + } + } diff --git a/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java index c27a624..c993dcb 100644 --- a/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java +++ b/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java @@ -87,9 +87,21 @@ public class LockedTreatmentController { @FXML private void unlockTreatment() { + Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem(); + if (selectedItem == null) { + return; + } + try { + selectedItem.setLocked(false); + this.treatmentDao.update(selectedItem); + } catch (SQLException exception) { + exception.printStackTrace(); + } + readAllAndShowInTableView(); } + } diff --git a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java index ce82860..c5fb88c 100644 --- a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java +++ b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java @@ -71,7 +71,7 @@ public class TreatmentDao extends DaoImp { @Override protected PreparedStatement getReadAllStatement() throws SQLException { - final String SQL = "SELECT * FROM treatment"; + final String SQL = "SELECT * FROM treatment where isLocked = false"; return this.connection.prepareStatement(SQL); } diff --git a/src/main/resources/de/hitec/nhplus/treatment/AllTreatmentView.fxml b/src/main/resources/de/hitec/nhplus/treatment/AllTreatmentView.fxml index 99d5301..4ccbfec 100644 --- a/src/main/resources/de/hitec/nhplus/treatment/AllTreatmentView.fxml +++ b/src/main/resources/de/hitec/nhplus/treatment/AllTreatmentView.fxml @@ -88,11 +88,11 @@