Compare commits
2 commits
930eba22e1
...
942577a86a
Author | SHA1 | Date | |
---|---|---|---|
942577a86a | |||
60c47098c6 |
3 changed files with 69 additions and 16 deletions
|
@ -1,12 +1,15 @@
|
||||||
package de.hitec.nhplus.medication;
|
package de.hitec.nhplus.medication;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import de.hitec.nhplus.Main;
|
import de.hitec.nhplus.Main;
|
||||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||||
import de.hitec.nhplus.medication.database.MedicationDao;
|
import de.hitec.nhplus.medication.database.MedicationDao;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
@ -16,10 +19,6 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The controller for viewing all {@link Medication}s.
|
* The controller for viewing all {@link Medication}s.
|
||||||
*
|
*
|
||||||
|
@ -84,6 +83,15 @@ public class AllMedicationController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createMedication(Medication medication) {
|
||||||
|
dao = DaoFactory.getInstance().createMedicationDAO();
|
||||||
|
try {
|
||||||
|
dao.create(medication);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleNewMedication() {
|
public void handleNewMedication() {
|
||||||
try {
|
try {
|
||||||
|
@ -95,7 +103,7 @@ public class AllMedicationController {
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
|
|
||||||
MedicationModalController controller = loader.getController();
|
MedicationModalController controller = loader.getController();
|
||||||
controller.initialize(null);
|
controller.initialize(stage, this, null);
|
||||||
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.setTitle("NHPlus - Neues Medikament");
|
stage.setTitle("NHPlus - Neues Medikament");
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package de.hitec.nhplus.medication;
|
package de.hitec.nhplus.medication;
|
||||||
|
|
||||||
|
import de.hitec.nhplus.treatment.AllTreatmentController;
|
||||||
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.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.control.TextArea;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MedicationModalController {
|
public class MedicationModalController {
|
||||||
|
@ -11,13 +16,27 @@ public class MedicationModalController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public ListView<Ingredient> listViewIngredients;
|
public ListView<Ingredient> listViewIngredients;
|
||||||
|
@FXML
|
||||||
|
public TextField textFieldName;
|
||||||
|
@FXML
|
||||||
|
public TextField textFieldManufacturer;
|
||||||
|
@FXML
|
||||||
|
public TextField textFieldAdministrationMethod;
|
||||||
|
@FXML
|
||||||
|
public TextField textFieldCurrentStock;
|
||||||
|
@FXML
|
||||||
|
public TextArea textAreaPossibleSideEffects;
|
||||||
|
|
||||||
|
private Stage stage;
|
||||||
|
|
||||||
private Medication medication;
|
private Medication medication;
|
||||||
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
private final ObservableList<Ingredient> ingredients = FXCollections.observableArrayList();
|
||||||
private AllMedicationController controller;
|
private AllMedicationController controller;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize(Medication medication) {
|
public void initialize(Stage stage, AllMedicationController controller, Medication medication) {
|
||||||
|
this.stage = stage;
|
||||||
|
this.controller=controller;
|
||||||
this.medication = medication != null ? medication : new Medication(
|
this.medication = medication != null ? medication : new Medication(
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
|
@ -35,10 +54,25 @@ public class MedicationModalController {
|
||||||
|
|
||||||
private void showData(){
|
private void showData(){
|
||||||
ingredients.setAll(medication.getIngredients());
|
ingredients.setAll(medication.getIngredients());
|
||||||
|
textFieldName.setText(medication.getName());
|
||||||
|
textFieldManufacturer.setText(medication.getManufacturer());
|
||||||
|
textFieldAdministrationMethod.setText(medication.getAdministrationMethod());
|
||||||
|
textFieldCurrentStock.setText(String.valueOf(medication.getCurrentStock()));
|
||||||
|
textAreaPossibleSideEffects.setText(medication.getPossibleSideEffects());
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleSave() {
|
public void handleSave() {
|
||||||
|
this.medication.setName(textFieldName.getText());
|
||||||
|
this.medication.setManufacturer(textFieldManufacturer.getText());
|
||||||
|
this.medication.setAdministrationMethod(textFieldAdministrationMethod.getText());
|
||||||
|
this.medication.setCurrentStock(Integer.parseInt(textFieldCurrentStock.getText()));
|
||||||
|
this.medication.setPossibleSideEffects(textAreaPossibleSideEffects.getText());
|
||||||
|
this.medication.setIngredients(ingredients);
|
||||||
|
|
||||||
|
controller.createMedication(medication);
|
||||||
|
controller.readAllAndShowInTableView();
|
||||||
|
stage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
text="Name:"
|
text="Name:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
fx:id="textFieldName"
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
/>
|
/>
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
text="Hersteller:"
|
text="Hersteller:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
fx:id="textFieldManufacturer"
|
||||||
GridPane.rowIndex="0"
|
GridPane.rowIndex="0"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
/>
|
/>
|
||||||
|
@ -51,6 +53,7 @@
|
||||||
text="Verabreichungsmethode:"
|
text="Verabreichungsmethode:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
fx:id="textFieldAdministrationMethod"
|
||||||
GridPane.rowIndex="1"
|
GridPane.rowIndex="1"
|
||||||
GridPane.columnIndex="1"
|
GridPane.columnIndex="1"
|
||||||
/>
|
/>
|
||||||
|
@ -60,6 +63,7 @@
|
||||||
text="Lagerbestand:"
|
text="Lagerbestand:"
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
|
fx:id="textFieldCurrentStock"
|
||||||
GridPane.rowIndex="1"
|
GridPane.rowIndex="1"
|
||||||
GridPane.columnIndex="4"
|
GridPane.columnIndex="4"
|
||||||
/>
|
/>
|
||||||
|
@ -102,7 +106,14 @@
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</left>
|
</left>
|
||||||
<center>
|
<center>
|
||||||
<TextArea/>
|
<BorderPane>
|
||||||
|
<top>
|
||||||
|
<Label text="Nebenwirkungen"/>
|
||||||
|
</top>
|
||||||
|
<center>
|
||||||
|
<TextArea fx:id="textAreaPossibleSideEffects"/>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
||||||
</center>
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</center>
|
</center>
|
||||||
|
|
Loading…
Reference in a new issue