#24 Logik implementiert und UI fertig gestellt
This commit is contained in:
parent
8e6cb5885e
commit
75b275198a
7 changed files with 52 additions and 8 deletions
Binary file not shown.
|
@ -18,6 +18,7 @@ import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.SelectionModel;
|
import javafx.scene.control.SelectionModel;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
|
@ -48,6 +49,8 @@ public class AllMedicationController {
|
||||||
private TableColumn<Medication, String> columnAdministrationMethod;
|
private TableColumn<Medication, String> columnAdministrationMethod;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Medication, Integer> columnCurrentStock;
|
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||||
|
@FXML
|
||||||
|
public Button buttonChangeAvailable;
|
||||||
|
|
||||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||||
private MedicationDao dao;
|
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}.
|
* Internal method to create a {@link MedicationModalController MedicationModal}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
|
@ -31,6 +32,8 @@ public class DeprecatedMedicationController {
|
||||||
private TableColumn<Medication, String> columnAdministrationMethod;
|
private TableColumn<Medication, String> columnAdministrationMethod;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Medication, Integer> columnCurrentStock;
|
private TableColumn<Medication, Integer> columnCurrentStock;
|
||||||
|
@FXML
|
||||||
|
public Button buttonChangeAvailable;
|
||||||
|
|
||||||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||||
private MedicationDao dao;
|
private MedicationDao dao;
|
||||||
|
@ -75,5 +78,20 @@ public class DeprecatedMedicationController {
|
||||||
exception.printStackTrace();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ public class MedicationModalController {
|
||||||
@FXML
|
@FXML
|
||||||
public Button buttonSave;
|
public Button buttonSave;
|
||||||
|
|
||||||
|
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Medication medication;
|
private Medication medication;
|
||||||
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
SELECT medication.*, medication_ingredient.name
|
SELECT medication.*, medication_ingredient.name
|
||||||
FROM medication LEFT JOIN
|
FROM medication LEFT JOIN
|
||||||
medication_ingredient ON medication.id = medication_ingredient.id
|
medication_ingredient ON medication.id = medication_ingredient.id
|
||||||
WHERE isDeprecated = false
|
WHERE medication.isDeprecated = false
|
||||||
""";
|
""";
|
||||||
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
SELECT medication.*, medication_ingredient.name
|
SELECT medication.*, medication_ingredient.name
|
||||||
FROM medication LEFT JOIN
|
FROM medication LEFT JOIN
|
||||||
medication_ingredient ON medication.id = medication_ingredient.id
|
medication_ingredient ON medication.id = medication_ingredient.id
|
||||||
WHERE isDeprecated = true
|
WHERE medication.isDeprecated = true
|
||||||
""";
|
""";
|
||||||
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
ResultSet result = connection.prepareStatement(SQL).executeQuery();
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ public class MedicationDao implements Dao<Medication> {
|
||||||
preparedStatement.setString(4, medication.getAdministrationMethod());
|
preparedStatement.setString(4, medication.getAdministrationMethod());
|
||||||
preparedStatement.setInt(5, medication.getCurrentStock());
|
preparedStatement.setInt(5, medication.getCurrentStock());
|
||||||
preparedStatement.setInt(6, medication.getId());
|
preparedStatement.setInt(6, medication.getId());
|
||||||
preparedStatement.setBoolean(6, medication.isDeprecated());
|
preparedStatement.setBoolean(7, medication.isDeprecated());
|
||||||
preparedStatement.executeUpdate();
|
preparedStatement.executeUpdate();
|
||||||
|
|
||||||
final String ingredientDeleteSQL = """
|
final String ingredientDeleteSQL = """
|
||||||
|
|
|
@ -75,6 +75,13 @@
|
||||||
prefWidth="90.0"
|
prefWidth="90.0"
|
||||||
text="Löschen"
|
text="Löschen"
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
fx:id="buttonChangeAvailable"
|
||||||
|
mnemonicParsing="false"
|
||||||
|
onAction="#handleChangeAvailable"
|
||||||
|
prefWidth="155.0"
|
||||||
|
text="Veraltet-Status ändern"
|
||||||
|
/>
|
||||||
</HBox>
|
</HBox>
|
||||||
</right>
|
</right>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
|
|
@ -62,14 +62,13 @@
|
||||||
</BorderPane.margin>
|
</BorderPane.margin>
|
||||||
<right>
|
<right>
|
||||||
<HBox spacing="8.0">
|
<HBox spacing="8.0">
|
||||||
<!--
|
|
||||||
<Button
|
<Button
|
||||||
fx:id="buttonDelete"
|
fx:id="buttonChangeAvailable"
|
||||||
mnemonicParsing="false"
|
mnemonicParsing="false"
|
||||||
prefWidth="90.0"
|
prefWidth="155.0"
|
||||||
text="Löschen"
|
onAction="#handleChangeAvailable"
|
||||||
|
text="Veraltet-Status ändern"
|
||||||
/>
|
/>
|
||||||
-->
|
|
||||||
</HBox>
|
</HBox>
|
||||||
</right>
|
</right>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
|
Loading…
Reference in a new issue