From 8927755462b92e264a773bbae129e4857edb2f63 Mon Sep 17 00:00:00 2001 From: pbs2h21asc Date: Tue, 31 Jan 2023 14:34:37 +0100 Subject: [PATCH] Admin Controller --- .../AdminController.java | 118 +++++++- .../createCoworker-view.fxml | 285 +++++++++--------- 2 files changed, 260 insertions(+), 143 deletions(-) diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java b/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java index 6494355..5092741 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/AdminController.java @@ -1,4 +1,120 @@ +/*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(""); + + } + + +} \ No newline at end of file diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml index 54f3aee..cae69d6 100644 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/createCoworker-view.fxml @@ -3,154 +3,155 @@ + - - - - -