From f4d66dc88dc686d99c3cd2bc692759fbc7894f3a Mon Sep 17 00:00:00 2001 From: Nils Dittberner Date: Thu, 19 Nov 2015 15:57:56 +0100 Subject: [PATCH] Fehler beim INSERT von StationsHistorie behoben. Eintraege werden nun korrekt erstellt. --- .../controller/StationsHistorieController.java | 77 ++++++++-------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java index 5d551e1..7465fe3 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java @@ -10,7 +10,6 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; -import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; @@ -26,36 +25,37 @@ import java.util.stream.Collectors; */ public class StationsHistorieController { + @FXML + public Button btnStatHistAbort; + SimpleObjectProperty state = new SimpleObjectProperty<>(State.VIEW); + @FXML + GridPane fields; + @FXML + Button btnStatHistEdit; /** * The station history that is shown in the edit window, or null if a new station history should be created. */ private StationsHistorie stationsHistorieSelected = null; - private MainController mainController; - @FXML private TableViewtblStationsHistorie; - @FXML private Button btnStatHistCancel, btnStatHistSave; - @FXML private Label statHistCreator, statHistCreateTime, statHistEditor, statHistEditTime; - @FXML private TableColumn colStatHistStation; - @FXML private TableColumn colStatHistAufnahmeDatum, colStatHistEntlassungsDatum; - @FXML private DateTimePicker dtTmAufnahme, dtTmEntlassung; - @FXML private ComboBox cmbStation; - @FXML private ComboBox cmbAbteilung; + private SimpleObjectProperty> stationsHistorie = + new SimpleObjectProperty<>(); + public StationsHistorieController(MainController mainController){ this.mainController = mainController; @@ -66,11 +66,6 @@ public class StationsHistorieController { this.state.set(State.EDIT); } - - public enum State { - CREATE, EDIT, VIEW - } - public State getState() { return state.get(); } @@ -79,22 +74,6 @@ public class StationsHistorieController { return state; } - - - SimpleObjectProperty state = new SimpleObjectProperty<>(State.VIEW); - - - public void setStationsHistorie(ObservableList stationsHistorie) { - this.stationsHistorie.set(stationsHistorie); - } - - private SimpleObjectProperty> stationsHistorie = - new SimpleObjectProperty<>(); - - - @FXML - GridPane fields; - @FXML private void initialize() { initColumns(); @@ -119,10 +98,6 @@ public class StationsHistorieController { }); } - @FXML - public Button btnStatHistAbort; - - private void initStationsFilter(){ final String any = "beliebig"; @@ -156,22 +131,17 @@ public class StationsHistorieController { } @FXML - Button btnStatHistEdit; - - - - @FXML - private void clickedCancel(){ - // this.state.set(State.VIEW); + private void clickedCancel() { + // this.state.set(State.VIEW); } @FXML - private void clickedSave(){ - if(getState()==State.CREATE){ + private void clickedSave() { + if (getState() == State.CREATE) { StationsHistorie stationsHistorie = new StationsHistorie(); copyFieldDataIntoStationsHistorie(stationsHistorie); try { - DBHandler.setStationsHistorie(stationsHistorie,false); + DBHandler.setStationsHistorie(stationsHistorie, false); } catch (SQLException e) { e.printStackTrace(); } @@ -180,7 +150,7 @@ public class StationsHistorieController { } @FXML - private void clickedAbort(){ + private void clickedAbort() { state.set(State.VIEW); copyStationsHistorieDataIntoFields(); } @@ -195,12 +165,14 @@ public class StationsHistorieController { return stationsHistorie.get(); } + public void setStationsHistorie(ObservableList stationsHistorie) { + this.stationsHistorie.set(stationsHistorie); + } + public SimpleObjectProperty> stationsHistorieProperty() { return stationsHistorie; } - - public void setStationsHistorieSelected(StationsHistorie stationsHistorie){ this.stationsHistorieSelected=stationsHistorie; if(stationsHistorie==null){ @@ -211,7 +183,6 @@ public class StationsHistorieController { } - private void initColumns(){ // colStatHistStation.setCellValueFactory(new PropertyValueFactory()); colStatHistAufnahmeDatum.setCellValueFactory(new PropertyValueFactory("aufnahmeDatum")); @@ -246,8 +217,10 @@ public class StationsHistorieController { stationsHistorie.setAufnahmeDatum(dtTmAufnahme.getDateTime()); stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime()); stationsHistorie.setStation(cmbStation.getValue()); - stationsHistorie.setFallID(mainController.getFall().getFallID()); + stationsHistorie.setFallID(mainController.getFallController().getFall().getFallID()); stationsHistorie.setStationKey(cmbStation.getValue().getStation()); + stationsHistorie.setErsteller(mainController.getCurrentMitarbeiter().getMitarbID()); + stationsHistorie.setBearbeiter(mainController.getCurrentMitarbeiter().getMitarbID()); } private void clearFields(){ @@ -264,4 +237,8 @@ public class StationsHistorieController { dtTmAufnahme.setDateTime(null); dtTmEntlassung.setDateTime(null); } + + public enum State { + CREATE, EDIT, VIEW + } }