浏览代码

Fehler beim INSERT von StationsHistorie behoben. Eintraege werden nun korrekt erstellt.

testBranch
Nils Dittberner 10 年前
父节点
当前提交
f4d66dc88d
共有 1 个文件被更改,包括 27 次插入50 次删除
  1. +27
    -50
      src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java

+ 27
- 50
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.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList; import javafx.collections.transformation.FilteredList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
@@ -26,36 +25,37 @@ import java.util.stream.Collectors;
*/ */
public class StationsHistorieController { public class StationsHistorieController {


@FXML
public Button btnStatHistAbort;
SimpleObjectProperty<State> 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. * 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 StationsHistorie stationsHistorieSelected = null;

private MainController mainController; private MainController mainController;

@FXML @FXML
private TableView<StationsHistorie>tblStationsHistorie; private TableView<StationsHistorie>tblStationsHistorie;

@FXML @FXML
private Button btnStatHistCancel, btnStatHistSave; private Button btnStatHistCancel, btnStatHistSave;

@FXML @FXML
private Label statHistCreator, statHistCreateTime, statHistEditor, statHistEditTime; private Label statHistCreator, statHistCreateTime, statHistEditor, statHistEditTime;

@FXML @FXML
private TableColumn<StationsHistorie,String> colStatHistStation; private TableColumn<StationsHistorie,String> colStatHistStation;

@FXML @FXML
private TableColumn<StationsHistorie,LocalDate> colStatHistAufnahmeDatum, colStatHistEntlassungsDatum; private TableColumn<StationsHistorie,LocalDate> colStatHistAufnahmeDatum, colStatHistEntlassungsDatum;

@FXML @FXML
private DateTimePicker dtTmAufnahme, dtTmEntlassung; private DateTimePicker dtTmAufnahme, dtTmEntlassung;

@FXML @FXML
private ComboBox<Station> cmbStation; private ComboBox<Station> cmbStation;

@FXML @FXML
private ComboBox<String> cmbAbteilung; private ComboBox<String> cmbAbteilung;
private SimpleObjectProperty<ObservableList<StationsHistorie>> stationsHistorie =
new SimpleObjectProperty<>();



public StationsHistorieController(MainController mainController){ public StationsHistorieController(MainController mainController){
this.mainController = mainController; this.mainController = mainController;
@@ -66,11 +66,6 @@ public class StationsHistorieController {
this.state.set(State.EDIT); this.state.set(State.EDIT);
} }



public enum State {
CREATE, EDIT, VIEW
}

public State getState() { public State getState() {
return state.get(); return state.get();
} }
@@ -79,22 +74,6 @@ public class StationsHistorieController {
return state; return state;
} }




SimpleObjectProperty<State> state = new SimpleObjectProperty<>(State.VIEW);


public void setStationsHistorie(ObservableList<StationsHistorie> stationsHistorie) {
this.stationsHistorie.set(stationsHistorie);
}

private SimpleObjectProperty<ObservableList<StationsHistorie>> stationsHistorie =
new SimpleObjectProperty<>();


@FXML
GridPane fields;

@FXML @FXML
private void initialize() { private void initialize() {
initColumns(); initColumns();
@@ -119,10 +98,6 @@ public class StationsHistorieController {
}); });
} }


@FXML
public Button btnStatHistAbort;


private void initStationsFilter(){ private void initStationsFilter(){
final String any = "beliebig"; final String any = "beliebig";


@@ -156,22 +131,17 @@ public class StationsHistorieController {
} }


@FXML @FXML
Button btnStatHistEdit;



@FXML
private void clickedCancel(){
// this.state.set(State.VIEW);
private void clickedCancel() {
// this.state.set(State.VIEW);
} }


@FXML @FXML
private void clickedSave(){
if(getState()==State.CREATE){
private void clickedSave() {
if (getState() == State.CREATE) {
StationsHistorie stationsHistorie = new StationsHistorie(); StationsHistorie stationsHistorie = new StationsHistorie();
copyFieldDataIntoStationsHistorie(stationsHistorie); copyFieldDataIntoStationsHistorie(stationsHistorie);
try { try {
DBHandler.setStationsHistorie(stationsHistorie,false);
DBHandler.setStationsHistorie(stationsHistorie, false);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -180,7 +150,7 @@ public class StationsHistorieController {
} }


@FXML @FXML
private void clickedAbort(){
private void clickedAbort() {
state.set(State.VIEW); state.set(State.VIEW);
copyStationsHistorieDataIntoFields(); copyStationsHistorieDataIntoFields();
} }
@@ -195,12 +165,14 @@ public class StationsHistorieController {
return stationsHistorie.get(); return stationsHistorie.get();
} }


public void setStationsHistorie(ObservableList<StationsHistorie> stationsHistorie) {
this.stationsHistorie.set(stationsHistorie);
}

public SimpleObjectProperty<ObservableList<StationsHistorie>> stationsHistorieProperty() { public SimpleObjectProperty<ObservableList<StationsHistorie>> stationsHistorieProperty() {
return stationsHistorie; return stationsHistorie;
} }




public void setStationsHistorieSelected(StationsHistorie stationsHistorie){ public void setStationsHistorieSelected(StationsHistorie stationsHistorie){
this.stationsHistorieSelected=stationsHistorie; this.stationsHistorieSelected=stationsHistorie;
if(stationsHistorie==null){ if(stationsHistorie==null){
@@ -211,7 +183,6 @@ public class StationsHistorieController {


} }



private void initColumns(){ private void initColumns(){
// colStatHistStation.setCellValueFactory(new PropertyValueFactory<StationsHistorie, String>()); // colStatHistStation.setCellValueFactory(new PropertyValueFactory<StationsHistorie, String>());
colStatHistAufnahmeDatum.setCellValueFactory(new PropertyValueFactory<StationsHistorie, LocalDate>("aufnahmeDatum")); colStatHistAufnahmeDatum.setCellValueFactory(new PropertyValueFactory<StationsHistorie, LocalDate>("aufnahmeDatum"));
@@ -246,8 +217,10 @@ public class StationsHistorieController {
stationsHistorie.setAufnahmeDatum(dtTmAufnahme.getDateTime()); stationsHistorie.setAufnahmeDatum(dtTmAufnahme.getDateTime());
stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime()); stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime());
stationsHistorie.setStation(cmbStation.getValue()); stationsHistorie.setStation(cmbStation.getValue());
stationsHistorie.setFallID(mainController.getFall().getFallID());
stationsHistorie.setFallID(mainController.getFallController().getFall().getFallID());
stationsHistorie.setStationKey(cmbStation.getValue().getStation()); stationsHistorie.setStationKey(cmbStation.getValue().getStation());
stationsHistorie.setErsteller(mainController.getCurrentMitarbeiter().getMitarbID());
stationsHistorie.setBearbeiter(mainController.getCurrentMitarbeiter().getMitarbID());
} }


private void clearFields(){ private void clearFields(){
@@ -264,4 +237,8 @@ public class StationsHistorieController {
dtTmAufnahme.setDateTime(null); dtTmAufnahme.setDateTime(null);
dtTmEntlassung.setDateTime(null); dtTmEntlassung.setDateTime(null);
} }

public enum State {
CREATE, EDIT, VIEW
}
} }

正在加载...
取消
保存