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 eeb8658..383f769 100644
--- a/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java
+++ b/src/main/java/de/uniluebeck/mi/projmi6/controller/StationsHistorieController.java
@@ -166,9 +166,14 @@ public class StationsHistorieController {
@FXML
private void clickedSave() {
+
+
if (getState() == State.CREATE) {
StationsHistorie stationsHistorie = new StationsHistorie();
copyFieldDataIntoStationsHistorie(stationsHistorie);
+ if(!validateData(stationsHistorie)){
+ return;
+ }
try {
DBHandler.setStationsHistorie(stationsHistorie, false);
} catch (SQLException e) {
@@ -177,6 +182,9 @@ public class StationsHistorieController {
mainController.refreshCaseData();
} else {
copyFieldDataIntoStationsHistorie(stationsHistorieSelected);
+ if(!validateData(stationsHistorieSelected)){
+ return;
+ }
try {
DBHandler.setStationsHistorie(stationsHistorieSelected, true);
} catch (SQLException e) {
@@ -290,11 +298,45 @@ public class StationsHistorieController {
stationsHistorie.setEntlassungsDatum(dtTmEntlassung.getDateTime());
stationsHistorie.setStation(cmbStation.getValue());
stationsHistorie.setFallID(mainController.getFallController().getFall().getFallID());
- stationsHistorie.setStationKey(cmbStation.getValue().getStation());
+ if(cmbStation.getValue()!= null){
+ stationsHistorie.setStationKey(cmbStation.getValue().getStation());
+ }else{
+ stationsHistorie.setStationKey(null);
+ }
stationsHistorie.setErsteller(mainController.getCurrentMitarbeiter().getMitarbID());
stationsHistorie.setBearbeiter(mainController.getCurrentMitarbeiter().getMitarbID());
}
+
+ private void showMessage(String title, String message) {
+ Alert alert = new Alert(Alert.AlertType.INFORMATION);
+ alert.setTitle("Ung\u00fcltige Daten!");
+ alert.setHeaderText(title);
+ alert.setContentText(message);
+ alert.initModality(Modality.APPLICATION_MODAL);
+ alert.showAndWait();
+ }
+
+
+ private boolean validateData(StationsHistorie stationsHistorie){
+ if(stationsHistorie.getStationKey()==null){
+ showMessage("Keine Station ausgew\00e4hlt!", "Bitte Station und nicht nur Abteilung ausw\00e4hlen!");
+ return false;
+ }
+ if(stationsHistorie.getAufnahmeDatum()==null){
+ showMessage("Aufnahmedatum fehlt!", "Bitte den Beginn des Stationsaufenthalts angeben!");
+ return false;
+ }
+ if(stationsHistorie.getEntlassungsDatum() != null &&
+ stationsHistorie.getAufnahmeDatum().isAfter(stationsHistorie.getEntlassungsDatum())){
+ showMessage("Aufnahmedatum liegt hinter Entlassungsdatum!", "Bitte die eingegebenen Daten nocheinmal kontrollieren!");
+ return false;
+ }
+
+
+ return true;
+ }
+
private void clearFields(){
statHistCreateTime.setText("");
diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java
index e680c1c..c8dfe6f 100644
--- a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java
+++ b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java
@@ -8,7 +8,7 @@ import java.sql.SQLException;
* MySQL Connection Factory.
*/
public class MySqlConnectionFactory {
- public static final String URL = "jdbc:mysql://141.83.20.84:3306/pmiw15g06_v01";
+ public static final String URL = "jdbc:mysql://localhost:3306/pmiw15g06_v01";
public static final String USER = "pmiw15g06";
public static final String PASS = "AX3yQSYJSH43PrSz";
public static final String DRIVER = "com.mysql.jdbc.Driver";
diff --git a/src/main/resources/fall.fxml b/src/main/resources/fall.fxml
index addce52..59a5224 100644
--- a/src/main/resources/fall.fxml
+++ b/src/main/resources/fall.fxml
@@ -40,7 +40,7 @@
-
+