From 75b275198a81404501e66295f3097cb1638fa2dc Mon Sep 17 00:00:00 2001 From: arminribic Date: Mon, 20 May 2024 10:28:17 +0200 Subject: [PATCH] #24 Logik implementiert und UI fertig gestellt --- db/nursingHome.db | Bin 28672 -> 28672 bytes .../medication/AllMedicationController.java | 19 ++++++++++++++++++ .../DeprecatedMedicationController.java | 18 +++++++++++++++++ .../medication/MedicationModalController.java | 1 + .../medication/database/MedicationDao.java | 6 +++--- .../nhplus/medication/AllMedicationView.fxml | 7 +++++++ .../medication/DeprecatedMedicationView.fxml | 9 ++++----- 7 files changed, 52 insertions(+), 8 deletions(-) diff --git a/db/nursingHome.db b/db/nursingHome.db index 577251236000a6007c68f368cf242e40da163013..ee002a5ffa95ad100437ebe124804f61849f2f44 100644 GIT binary patch delta 314 zcmZp8z}WDBae}nq83qOhb|8jhT-7Uw)h|H+nI3XE)< zqqs5{8T~dN=6=q|=(Bk>Z#*Mc02^3uV~+1;5&m}qe5)8(_-Bjpzv92oKbwEYW%` z^t{yK%+lQAlGMba#1bxMW=`pV{IblH{5&2eW=?tM)SR5soc!Wc2}Wj4bKlgGwEUvn d%)E@sl%o9PjGX+U%#=+5yZ9M7Chv}S1pw?nR5}0v diff --git a/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java b/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java index 547d30f..8c2ca83 100644 --- a/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java +++ b/src/main/java/de/hitec/nhplus/medication/AllMedicationController.java @@ -18,6 +18,7 @@ import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; +import javafx.scene.control.Button; import javafx.scene.control.SelectionModel; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; @@ -48,6 +49,8 @@ public class AllMedicationController { private TableColumn columnAdministrationMethod; @FXML private TableColumn columnCurrentStock; + @FXML + public Button buttonChangeAvailable; private final ObservableList medications = FXCollections.observableArrayList(); private MedicationDao dao; @@ -120,6 +123,22 @@ public class AllMedicationController { } } + @FXML + public void handleChangeAvailable() { + Medication selectedItem = tableView.getSelectionModel().getSelectedItem(); + if (selectedItem == null) { + return; + } + + try { + selectedItem.setIsDeprecated(true); + this.dao.update(selectedItem); + } catch (SQLException exception) { + exception.printStackTrace(); + } + readAllAndShowInTableView(); + } + /** * Internal method to create a {@link MedicationModalController MedicationModal}. * diff --git a/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java b/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java index fe38fe7..d992fe9 100644 --- a/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java +++ b/src/main/java/de/hitec/nhplus/medication/DeprecatedMedicationController.java @@ -6,6 +6,7 @@ import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; +import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.PropertyValueFactory; @@ -31,6 +32,8 @@ public class DeprecatedMedicationController { private TableColumn columnAdministrationMethod; @FXML private TableColumn columnCurrentStock; + @FXML + public Button buttonChangeAvailable; private final ObservableList medications = FXCollections.observableArrayList(); private MedicationDao dao; @@ -75,5 +78,20 @@ public class DeprecatedMedicationController { exception.printStackTrace(); } } + @FXML + public void handleChangeAvailable(){ + Medication selectedItem = tableView.getSelectionModel().getSelectedItem(); + if (selectedItem == null) { + return; + } + + try { + selectedItem.setIsDeprecated(false); + this.dao.update(selectedItem); + } catch (SQLException exception) { + exception.printStackTrace(); + } + readAllAndShowInTableView(); + } } diff --git a/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java b/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java index 9489737..ab80e1d 100644 --- a/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java +++ b/src/main/java/de/hitec/nhplus/medication/MedicationModalController.java @@ -39,6 +39,7 @@ public class MedicationModalController { @FXML public Button buttonSave; + private Stage stage; private Medication medication; private final ObservableList ingredients = FXCollections.observableArrayList(); diff --git a/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java b/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java index 41f5f7d..f4f4655 100644 --- a/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java +++ b/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java @@ -86,7 +86,7 @@ public class MedicationDao implements Dao { SELECT medication.*, medication_ingredient.name FROM medication LEFT JOIN medication_ingredient ON medication.id = medication_ingredient.id - WHERE isDeprecated = false + WHERE medication.isDeprecated = false """; ResultSet result = connection.prepareStatement(SQL).executeQuery(); @@ -134,7 +134,7 @@ public class MedicationDao implements Dao { SELECT medication.*, medication_ingredient.name FROM medication LEFT JOIN medication_ingredient ON medication.id = medication_ingredient.id - WHERE isDeprecated = true + WHERE medication.isDeprecated = true """; ResultSet result = connection.prepareStatement(SQL).executeQuery(); @@ -196,7 +196,7 @@ public class MedicationDao implements Dao { preparedStatement.setString(4, medication.getAdministrationMethod()); preparedStatement.setInt(5, medication.getCurrentStock()); preparedStatement.setInt(6, medication.getId()); - preparedStatement.setBoolean(6, medication.isDeprecated()); + preparedStatement.setBoolean(7, medication.isDeprecated()); preparedStatement.executeUpdate(); final String ingredientDeleteSQL = """ diff --git a/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml b/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml index 157caac..d9456b9 100644 --- a/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml +++ b/src/main/resources/de/hitec/nhplus/medication/AllMedicationView.fxml @@ -75,6 +75,13 @@ prefWidth="90.0" text="Löschen" /> +