120 lines
3.3 KiB
Java
120 lines
3.3 KiB
Java
/*Schulte*/
|
|
|
|
package com.bib.essensbestellungsverwaltung;
|
|
|
|
import javafx.fxml.FXML;
|
|
import javafx.scene.control.Alert;
|
|
import javafx.scene.control.PasswordField;
|
|
import javafx.scene.control.TextField;
|
|
|
|
public class AdminController {
|
|
|
|
@FXML
|
|
TextField lastname;
|
|
@FXML
|
|
TextField firstname;
|
|
@FXML
|
|
TextField street;
|
|
@FXML
|
|
TextField number;
|
|
@FXML
|
|
TextField city;
|
|
@FXML
|
|
TextField plz;
|
|
@FXML
|
|
TextField email;
|
|
@FXML
|
|
PasswordField password;
|
|
|
|
|
|
|
|
@FXML
|
|
protected void onBtSignUp(){
|
|
|
|
String ln = lastname.getText();
|
|
String fn = firstname.getText();
|
|
String st = street.getText();
|
|
String nr = number.getText();
|
|
String cityString = city.getText();
|
|
String plzString = plz.getText();
|
|
String emailString = email.getText();
|
|
String pw = password.getText();
|
|
|
|
boolean userData = false;
|
|
boolean pwCorrect = false;
|
|
boolean emailCorrect = false;
|
|
|
|
|
|
if(ln.isEmpty() || fn.isEmpty() || st.isEmpty() ||nr.isEmpty() || cityString.isEmpty() || plzString.isEmpty()){
|
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
alert.setTitle("Felder");
|
|
alert.setHeaderText("Felder nicht ausgefüllt");
|
|
alert.setContentText("Bitte füllen sie alle Felder aus");
|
|
alert.showAndWait();
|
|
}
|
|
else {
|
|
userData = true;
|
|
}
|
|
|
|
|
|
if(!pw.matches("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}$")){
|
|
|
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
alert.setTitle("Passwort");
|
|
alert.setHeaderText("Ungültiges Passwort");
|
|
alert.setContentText("Das Passwort benötigt mindestens: \n-8 Zeichen\n-einen Kleinbuchstaben\n-einen Großbuchstaben\n-ein Sonderzeichen\n-kein Leerzeichen");
|
|
password.setText("");
|
|
alert.showAndWait();
|
|
}
|
|
else {
|
|
pwCorrect = true;
|
|
}
|
|
|
|
if(!emailString.matches("^(.+)@(\\S+)$")){
|
|
Alert alert = new Alert(Alert.AlertType.ERROR);
|
|
alert.setTitle("E-Mail");
|
|
alert.setHeaderText("Ungültige E-Mail Adresse");
|
|
alert.setContentText("Bitte geben sie eine gültige E-Mail Adresse an");
|
|
email.setText("");
|
|
alert.showAndWait();
|
|
}
|
|
else{
|
|
emailCorrect = true;
|
|
}
|
|
|
|
//String[] userData = new String[]{ln,fn,pw,emailString};
|
|
//String[] addressData = new String[]{st,nr,plzString,cityString};
|
|
|
|
|
|
if(emailCorrect && pwCorrect && userData) {
|
|
Address address = new Address(st, nr, plzString, cityString);
|
|
Worker worker = new Worker(ln, fn, pw, emailString, address);
|
|
|
|
|
|
System.out.println(AccountMgr.createWorker(worker));
|
|
|
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
|
alert.setTitle("Bestätigung");
|
|
alert.setHeaderText("Bestätigung");
|
|
alert.setContentText("Mitarbeiter " + fn + " " + ln + " wurde Erfolgreich angelegt");
|
|
alert.showAndWait();
|
|
}
|
|
|
|
}
|
|
|
|
@FXML
|
|
protected void onBtCancel(){
|
|
|
|
lastname.setText("");
|
|
firstname.setText("");
|
|
street.setText("");
|
|
number.setText("");
|
|
city.setText("");
|
|
plz.setText("");
|
|
email.setText("");
|
|
password.setText("");
|
|
|
|
}
|
|
|
|
|
|
} |