#24 Logik implementiert und UI fertig gestellt
Some checks failed
Quality Check / Linting Check (push) Failing after 12s
Quality Check / Javadoc Check (push) Successful in 21s

This commit is contained in:
arminribic 2024-05-20 10:28:17 +02:00
parent 8e6cb5885e
commit 75b275198a
7 changed files with 52 additions and 8 deletions

Binary file not shown.

View file

@ -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<Medication, String> columnAdministrationMethod;
@FXML
private TableColumn<Medication, Integer> columnCurrentStock;
@FXML
public Button buttonChangeAvailable;
private final ObservableList<Medication> 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}.
*

View file

@ -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<Medication, String> columnAdministrationMethod;
@FXML
private TableColumn<Medication, Integer> columnCurrentStock;
@FXML
public Button buttonChangeAvailable;
private final ObservableList<Medication> 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();
}
}

View file

@ -39,6 +39,7 @@ public class MedicationModalController {
@FXML
public Button buttonSave;
private Stage stage;
private Medication medication;
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();

View file

@ -86,7 +86,7 @@ public class MedicationDao implements Dao<Medication> {
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<Medication> {
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<Medication> {
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 = """

View file

@ -75,6 +75,13 @@
prefWidth="90.0"
text="Löschen"
/>
<Button
fx:id="buttonChangeAvailable"
mnemonicParsing="false"
onAction="#handleChangeAvailable"
prefWidth="155.0"
text="Veraltet-Status ändern"
/>
</HBox>
</right>
</BorderPane>

View file

@ -62,14 +62,13 @@
</BorderPane.margin>
<right>
<HBox spacing="8.0">
<!--
<Button
fx:id="buttonDelete"
fx:id="buttonChangeAvailable"
mnemonicParsing="false"
prefWidth="90.0"
text="Löschen"
prefWidth="155.0"
onAction="#handleChangeAvailable"
text="Veraltet-Status ändern"
/>
-->
</HBox>
</right>
</BorderPane>