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