#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.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}.
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public class MedicationModalController {
|
|||
@FXML
|
||||
public Button buttonSave;
|
||||
|
||||
|
||||
private Stage stage;
|
||||
private Medication medication;
|
||||
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
||||
|
|
|
@ -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 = """
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue