96 lines
3.7 KiB
Java
96 lines
3.7 KiB
Java
package com.bib.essensbestellungsverwaltung;
|
|
import javafx.fxml.FXML;
|
|
import javafx.fxml.FXMLLoader;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.Alert;
|
|
import javafx.scene.control.PasswordField;
|
|
import javafx.scene.control.TextField;
|
|
|
|
import java.io.IOException;
|
|
|
|
public class SingUpController {
|
|
@FXML
|
|
private TextField tfLastName;
|
|
@FXML
|
|
private TextField tfFirstName;
|
|
@FXML
|
|
private TextField tfEmail;
|
|
@FXML
|
|
private PasswordField pfPassword;
|
|
@FXML
|
|
private TextField tfPostCode;
|
|
@FXML
|
|
private TextField tfCity;
|
|
|
|
@FXML
|
|
private TextField tfStreet;
|
|
@FXML
|
|
private TextField tfHousNumber;
|
|
@FXML
|
|
private void onKontoErstellenBtClick(){
|
|
String lastName = tfLastName.getText();
|
|
String firstNanme = tfFirstName.getText();
|
|
String email = tfEmail.getText();
|
|
String password = pfPassword.getText();
|
|
String postCode = tfPostCode.getText();
|
|
String city = tfCity.getText();
|
|
String street = tfStreet.getText();
|
|
String housNumber = tfHousNumber.getText();
|
|
Alert alert;
|
|
if(lastName.isEmpty() || firstNanme.isEmpty() || email.isEmpty() || password.isEmpty() || postCode.isEmpty() ||
|
|
city.isEmpty() || street.isEmpty() || housNumber.isEmpty()){
|
|
|
|
if(lastName.isEmpty()){
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Name' ist leer.");
|
|
alert.showAndWait();
|
|
} else if (firstNanme.isEmpty()) {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Vorname' ist leer.");
|
|
alert.showAndWait();
|
|
} else if (email.isEmpty()) {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'E-Mail' ist leer.");
|
|
alert.showAndWait();
|
|
} else if (password.isEmpty()) {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Passwort' ist leer.");
|
|
alert.showAndWait();
|
|
} else if (postCode.isEmpty()) {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Postleitzahl' ist leer.");
|
|
alert.showAndWait();
|
|
} else if (city.isEmpty()) {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Stadt' ist leer.");
|
|
alert.showAndWait();
|
|
} else if (street.isEmpty()) {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Straße' ist leer.");
|
|
alert.showAndWait();
|
|
}else {
|
|
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Hausnummer' ist leer.");
|
|
alert.showAndWait();
|
|
}
|
|
|
|
}else {
|
|
Address newAdresse = new Address(street,housNumber,postCode,city);
|
|
User newUser = new User(lastName,firstNanme,password,email,newAdresse);
|
|
long creatNewUser = AccountMgr.createUser(newUser);
|
|
if (creatNewUser > 0){
|
|
alert = new Alert(Alert.AlertType.CONFIRMATION,"Ihrer Daten wurde gespeichert.");
|
|
alert.showAndWait();
|
|
}
|
|
tfLastName.setText("");
|
|
tfFirstName.setText("");
|
|
tfEmail.setText("");
|
|
pfPassword.setText("");
|
|
tfPostCode.setText("");
|
|
tfCity.setText("");
|
|
tfStreet.setText("");
|
|
tfHousNumber.setText("");
|
|
}
|
|
|
|
}
|
|
|
|
@FXML
|
|
private void onAnmeldenBtClick() throws IOException {
|
|
FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml"));
|
|
Scene scene = new Scene(fxmlLoader.load(), 950,700);
|
|
StartViewApplication.primary.setScene(scene);
|
|
}
|
|
}
|