Admin Controller

This commit is contained in:
pbs2h21asc 2023-01-31 14:34:37 +01:00
parent 636ac5ed3a
commit 8927755462
2 changed files with 260 additions and 143 deletions

View File

@ -1,4 +1,120 @@
/*Schulte*/
package com.bib.essensbestellungsverwaltung; 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 { 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("");
}
}

View File

@ -3,154 +3,155 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.TextField?> <?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?> <?import javafx.scene.text.Font?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="479.0" prefWidth="719.0" stylesheets="@createCoworker.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="860.0" prefWidth="850.0" stylesheets="@createCoworker.css" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.bib.essensbestellungsverwaltung.AdminController">
<children> <children>
<Label layoutX="301.0" layoutY="49.0" /> <Label layoutX="301.0" layoutY="49.0" />
<Label layoutX="230.0" layoutY="30.0" prefHeight="28.0" prefWidth="220.0" text="Mitarbeiter hinzufügen"> <Label layoutX="223.0" layoutY="76.0" prefHeight="28.0" prefWidth="220.0" text="Mitarbeiter hinzufügen">
<font> <font>
<Font size="18.0" /> <Font size="18.0" />
</font> </font>
</Label> </Label>
<VBox layoutX="119.0" layoutY="95.0" prefHeight="317.0" prefWidth="331.0"> <VBox layoutX="223.0" layoutY="149.0" prefHeight="317.0" prefWidth="514.0">
<children> <children>
<HBox prefHeight="43.0" prefWidth="331.0"> <HBox prefHeight="43.0" prefWidth="331.0">
<children> <children>
<Label prefHeight="17.0" prefWidth="116.0" text="Nachname"> <Label prefHeight="17.0" prefWidth="116.0" text="Nachname">
<font> <font>
<Font size="16.0" /> <Font size="16.0" />
</font> </font>
</Label> </Label>
<TextField prefHeight="25.0" prefWidth="194.0" /> <TextField fx:id="lastname" prefHeight="25.0" prefWidth="194.0" />
</children> </children>
</HBox> </HBox>
<HBox prefHeight="60.0" prefWidth="331.0"> <HBox prefHeight="60.0" prefWidth="331.0">
<children> <children>
<Label prefHeight="35.0" prefWidth="118.0" text="Vorname"> <Label prefHeight="35.0" prefWidth="118.0" text="Vorname">
<padding> <padding>
<Insets top="10.0" />
</padding>
<font>
<Font size="16.0" />
</font>
</Label>
<TextField fx:id="firstname" prefHeight="25.0" prefWidth="193.0">
<HBox.margin>
<Insets top="10.0" />
</HBox.margin>
</TextField>
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="35.0" prefWidth="116.0" text="Straße">
<font>
<Font size="16.0" />
</font>
<padding>
<Insets top="10.0" />
</padding>
</Label>
<TextField fx:id="street" prefHeight="25.0" prefWidth="195.0">
<HBox.margin>
<Insets top="10.0" />
</HBox.margin>
</TextField>
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="25.0" prefWidth="118.0" text="Hausnummer">
<font>
<Font size="16.0" />
</font>
<padding>
<Insets top="10.0" />
</padding>
</Label>
<TextField fx:id="number" prefHeight="25.0" prefWidth="87.0">
<HBox.margin>
<Insets top="10.0" />
</HBox.margin>
</TextField>
</children>
</HBox>
<HBox prefHeight="24.0" prefWidth="331.0">
<children>
<Label prefHeight="25.0" prefWidth="118.0" text="PLZ">
<font>
<Font size="16.0" />
</font>
</Label>
<TextField fx:id="plz" prefHeight="25.0" prefWidth="87.0">
<HBox.margin>
<Insets />
</HBox.margin>
</TextField>
</children>
<padding>
<Insets top="10.0" /> <Insets top="10.0" />
</padding> </padding>
<font> </HBox>
<Font size="16.0" /> <HBox prefHeight="100.0" prefWidth="200.0">
</font> <children>
</Label> <Label prefHeight="35.0" prefWidth="120.0" text="Stadt">
<TextField prefHeight="25.0" prefWidth="193.0"> <font>
<HBox.margin> <Font size="16.0" />
</font>
</Label>
<TextField fx:id="city" prefHeight="13.0" prefWidth="194.0">
<HBox.margin>
<Insets top="5.0" />
</HBox.margin>
</TextField>
</children>
<padding>
<Insets top="10.0" /> <Insets top="10.0" />
</HBox.margin> </padding>
</TextField> </HBox>
</children> <HBox prefHeight="100.0" prefWidth="200.0">
</HBox> <children>
<HBox prefHeight="100.0" prefWidth="200.0"> <Label prefHeight="35.0" prefWidth="117.0" text="Email">
<children> <font>
<Label prefHeight="35.0" prefWidth="116.0" text="Straße"> <Font size="16.0" />
<font> </font>
<Font size="16.0" /> <padding>
</font> <Insets top="10.0" />
<padding> </padding>
<Insets top="10.0" /> </Label>
</padding> <TextField fx:id="email" prefHeight="25.0" prefWidth="196.0">
</Label> <HBox.margin>
<TextField prefHeight="25.0" prefWidth="195.0"> <Insets top="10.0" />
<HBox.margin> </HBox.margin>
<Insets top="10.0" /> </TextField>
</HBox.margin> </children>
</TextField> </HBox>
</children> <HBox prefHeight="100.0" prefWidth="471.0">
</HBox> <children>
<HBox prefHeight="100.0" prefWidth="200.0"> <Label prefHeight="35.0" prefWidth="122.0" text="Passwort">
<children> <font>
<Label prefHeight="25.0" prefWidth="118.0" text="Hausnummer"> <Font size="16.0" />
<font> </font>
<Font size="16.0" /> <padding>
</font> <Insets top="10.0" />
<padding> </padding>
<Insets top="10.0" /> </Label>
</padding> <PasswordField fx:id="password" accessibleRole="PASSWORD_FIELD" prefHeight="25.0" prefWidth="194.0">
</Label> <HBox.margin>
<TextField prefHeight="25.0" prefWidth="87.0"> <Insets top="10.0" />
<HBox.margin> </HBox.margin>
<Insets top="10.0" /> </PasswordField>
</HBox.margin> </children>
</TextField> </HBox>
</children> </children>
</HBox> </VBox>
<HBox prefHeight="24.0" prefWidth="331.0"> <Button id="btCreateCoworker" fx:id="btCreateCoworker" layoutX="216.0" layoutY="533.0" mnemonicParsing="false" onAction="#onBtSignUp" prefHeight="44.0" prefWidth="158.0" text="Mitarbeiter hinzufügen" />
<children> <Button id="btCancelCoworker" fx:id="btCancelCoworker" layoutX="443.0" layoutY="533.0" mnemonicParsing="false" onAction="#onBtCancel" prefHeight="44.0" prefWidth="158.0" text="Abbrechen" />
<Label prefHeight="25.0" prefWidth="118.0" text="PLZ"> </children>
<font>
<Font size="16.0" />
</font>
</Label>
<TextField prefHeight="25.0" prefWidth="87.0">
<HBox.margin>
<Insets />
</HBox.margin>
</TextField>
</children>
<padding>
<Insets top="10.0" />
</padding>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="35.0" prefWidth="120.0" text="Stadt">
<font>
<Font size="16.0" />
</font>
</Label>
<TextField prefHeight="13.0" prefWidth="194.0">
<HBox.margin>
<Insets top="5.0" />
</HBox.margin>
</TextField>
</children>
<padding>
<Insets top="10.0" />
</padding>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="35.0" prefWidth="117.0" text="Email">
<font>
<Font size="16.0" />
</font>
<padding>
<Insets top="10.0" />
</padding>
</Label>
<TextField prefHeight="25.0" prefWidth="196.0">
<HBox.margin>
<Insets top="10.0" />
</HBox.margin>
</TextField>
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Label prefHeight="35.0" prefWidth="122.0" text="Passwort">
<font>
<Font size="16.0" />
</font>
<padding>
<Insets top="10.0" />
</padding>
</Label>
<TextField prefHeight="25.0" prefWidth="194.0">
<HBox.margin>
<Insets top="10.0" />
</HBox.margin>
</TextField>
</children>
</HBox>
</children>
</VBox>
<Button id="btCreateCoworker" layoutX="119.0" layoutY="412.0" mnemonicParsing="false" prefHeight="44.0" prefWidth="158.0" text="Mitarbeiter hinzufügen" />
<Button id="btCancelCoworker" layoutX="357.0" layoutY="412.0" mnemonicParsing="false" prefHeight="44.0" prefWidth="158.0" text="Abbrechen" />
</children>
</AnchorPane> </AnchorPane>