diff --git a/src/main/java/com/example/vpr_javafx/HelloController.java b/src/main/java/com/example/vpr_javafx/HelloController.java index d8130fe..6e530dd 100644 --- a/src/main/java/com/example/vpr_javafx/HelloController.java +++ b/src/main/java/com/example/vpr_javafx/HelloController.java @@ -13,6 +13,7 @@ import javafx.stage.Stage; import java.io.Console; import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -20,6 +21,7 @@ import java.util.HashMap; import java.util.List; public class HelloController { + @FXML private Label lMonH1; @FXML @@ -84,6 +86,11 @@ public class HelloController { @FXML private TextField tfPhone; + @FXML + public TextField tfName; + @FXML + public TextField tfChild; + @FXML private PasswordField pfPassword; @FXML @@ -235,7 +242,7 @@ public class HelloController { + "k: Nüsse; l: Sellerie;\n" + "m: Fische; n: Lupinen\n\n" + "1: Nitrit-Pökelsalz\n" - + "2:Phosphat\n" + + "2: Phosphat\n" + "3: Nitrat\n" + "4: Antioxidationsmittel\n" + "5: Farbstoff\n" @@ -244,4 +251,26 @@ public class HelloController { + "8: Konservierungsstoff"); } + @FXML + protected void OnRegistrationButton(ActionEvent event) throws IOException + { + Alert alert = new Alert(Alert.AlertType.WARNING); + Data validData = new Data("user.txt"); + + if (tfName.getText().isEmpty() || tfPhone.getText().isEmpty() || tfChild.getText().isEmpty()) + { + alert.setContentText("Registrierungsdaten unvollständig"); + } + else if (validData.validateData(tfPhone, pfPassword)) + { + try (FileWriter writer = new FileWriter("user.txt")){ + writer.write(tfName.getText() + ";" + tfPhone.getText() + ";" + tfChild.getText() + ";" + pfPassword.getText()); + writer.flush(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } } \ No newline at end of file diff --git a/src/main/resources/com/example/vpr_javafx/Registration-view.fxml b/src/main/resources/com/example/vpr_javafx/Registration-view.fxml index 481d6c9..7a41d50 100644 --- a/src/main/resources/com/example/vpr_javafx/Registration-view.fxml +++ b/src/main/resources/com/example/vpr_javafx/Registration-view.fxml @@ -4,34 +4,31 @@ - - - - - - - - - - - - - - - - -