Registrireung weiterentwickelt

This commit is contained in:
Kevin Maier 2023-01-31 14:57:37 +01:00
parent ae62ff5fd7
commit e54ce035e0
2 changed files with 58 additions and 32 deletions

View File

@ -13,6 +13,7 @@ import javafx.stage.Stage;
import java.io.Console; import java.io.Console;
import java.io.File; import java.io.File;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -20,6 +21,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class HelloController { public class HelloController {
@FXML @FXML
private Label lMonH1; private Label lMonH1;
@FXML @FXML
@ -84,6 +86,11 @@ public class HelloController {
@FXML @FXML
private TextField tfPhone; private TextField tfPhone;
@FXML
public TextField tfName;
@FXML
public TextField tfChild;
@FXML @FXML
private PasswordField pfPassword; private PasswordField pfPassword;
@FXML @FXML
@ -235,7 +242,7 @@ public class HelloController {
+ "k: Nüsse; l: Sellerie;\n" + "k: Nüsse; l: Sellerie;\n"
+ "m: Fische; n: Lupinen\n\n" + "m: Fische; n: Lupinen\n\n"
+ "1: Nitrit-Pökelsalz\n" + "1: Nitrit-Pökelsalz\n"
+ "2:Phosphat\n" + "2: Phosphat\n"
+ "3: Nitrat\n" + "3: Nitrat\n"
+ "4: Antioxidationsmittel\n" + "4: Antioxidationsmittel\n"
+ "5: Farbstoff\n" + "5: Farbstoff\n"
@ -244,4 +251,26 @@ public class HelloController {
+ "8: Konservierungsstoff"); + "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();
}
}
}
} }

View File

@ -17,20 +17,17 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label text="Voller Name: " /> <Label text="Voller Name: " />
<Label text="Handynummer: " GridPane.rowIndex="1" /> <Label text="Handynummer: " GridPane.rowIndex="1" />
<Label prefWidth="95.0" text="Passwort: " GridPane.rowIndex="2" /> <Label prefWidth="95.0" text="Passwort: " GridPane.rowIndex="2" />
<Label text="Kind: " GridPane.rowIndex="4" /> <Label text="Kind: " GridPane.rowIndex="3" />
<Button onAction="OnRegistrationButton" mnemonicParsing="false" prefHeight="26.0" prefWidth="90.0" text="Abschicken" translateX="100.0" GridPane.columnIndex="1" GridPane.rowIndex="6" /> <Button mnemonicParsing="false" onAction="#OnRegistrationButton" prefHeight="26.0" prefWidth="90.0" text="Abschicken" translateX="100.0" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Label text="Passwort bestätigen: " GridPane.rowIndex="3" /> <PasswordField fx:id="pfPassword" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<PasswordField GridPane.columnIndex="1" GridPane.rowIndex="2" /> <TextField fx:id="tfName" GridPane.columnIndex="1" />
<PasswordField GridPane.columnIndex="1" GridPane.rowIndex="3" /> <TextField fx:id="tfPhone" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="tfRegisterName" GridPane.columnIndex="1" /> <TextField fx:id="tfChild" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<TextField fx:id="tfRegisterPhone" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="tfRegisterChild" GridPane.columnIndex="1" GridPane.rowIndex="4" />
</children> </children>
</GridPane> </GridPane>
</children> </children>