singup mit Datebase verbunden und new Adresse

This commit is contained in:
Reshad Meher 2023-02-01 09:48:55 +01:00
parent 3613e246c9
commit 846c2c392a
8 changed files with 177 additions and 166 deletions

View File

@ -1,34 +0,0 @@
package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
public class HelloController {
/**
* @autor: Reshad Meher
* Username, Passwort , login
*/
@FXML
private TextField unsernameEingabe;
@FXML
private TextField passwortEingabe;
@FXML
private Label lblAusgabe;
@FXML
protected void onLoginButtonClick() {
String benutzerEingabe = unsernameEingabe.getText();
String kennwortEingabe = passwortEingabe.getText();
if(benutzerEingabe.contains("Reshad") && kennwortEingabe.contains("test123")){
lblAusgabe.setText("Herzlich Willkommen, " + benutzerEingabe + "!");
}else {
Alert alert = new Alert(Alert.AlertType.ERROR,
"Die Benutzername oder Passwort ist falsch");
alert.showAndWait();
}
unsernameEingabe.setText("");
passwortEingabe.setText("");
}
}

View File

@ -1,3 +1,4 @@
/*Reshad Meher*/
package com.bib.essensbestellungsverwaltung; package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -6,10 +7,8 @@ import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.PasswordField; import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
public class LoginController { public class LoginController {
@FXML @FXML
@ -17,26 +16,27 @@ public class LoginController {
@FXML @FXML
private PasswordField pfPassword; private PasswordField pfPassword;
HashMap<String,String> benutzerMap = new HashMap<String,String>();
@FXML @FXML
protected void onBtLoginClick() throws IOException { protected void onBtLoginClick() throws IOException {
benutzerMap.put("Reshad","1234");
String email = tfEmail.getText(); String email = tfEmail.getText();
String password = pfPassword.getText(); String password = pfPassword.getText();
if(benutzerMap.containsKey(email) && benutzerMap.containsValue(password)){ long loginPruefen = AccountMgr.login(email,password);
// if user is worker: StartViewApplication.changeScene("workerMenu-view.fxml"); if(loginPruefen > 0){
StartViewApplication.changeScene("parentMenu-view.fxml"); FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("menue-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 950,480);
StartViewApplication.primary.setScene(scene);
}else { }else {
Alert alert = new Alert(Alert.AlertType.ERROR,"Email oder Passwort ist falsch"); Alert alert = new Alert(Alert.AlertType.ERROR,"Email oder Passwort ist falsch");
alert.showAndWait(); alert.showAndWait();
} }
tfEmail.setText(""); tfEmail.setText("");
pfPassword.setText(""); pfPassword.setText("");
} }
@FXML @FXML
protected void changeToSignUp() throws IOException { protected void onBtSingnupClick() throws IOException {
StartViewApplication.changeScene("signUp-view.fxml"); FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("signUp-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 950,480);
StartViewApplication.primary.setScene(scene);
} }
} }

View File

@ -1,12 +0,0 @@
package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import java.io.IOException;
import java.util.Objects;
public class SceneController {
}

View File

@ -1,4 +1,6 @@
/** Reshad Meher*/ /**
* @autor: Reshad Meher
*/
package com.bib.essensbestellungsverwaltung; package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -7,21 +9,92 @@ import javafx.scene.Scene;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.PasswordField; import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
public class SingUpController { public class SingUpController {
@FXML
private TextField tfName;
@FXML
private TextField tfVorname;
@FXML
private TextField tfEmail;
@FXML
private PasswordField pfPasswort;
@FXML
private TextField tfPLZ;
@FXML
private TextField tfStadt;
@FXML
private TextField tfStrasse;
@FXML
private TextField tfHausnummer;
@FXML @FXML
private void onKontoErstellenBtClick(){ private void onKontoErstellenBtClick(){
String name = tfName.getText();
String vorname = tfVorname.getText();
String email = tfEmail.getText();
String passwort = pfPasswort.getText();
String plz = tfPLZ.getText();
String stadt = tfStadt.getText();
String strasse = tfStrasse.getText();
String hausnummer = tfHausnummer.getText();
Alert alert;
if(name.isEmpty() || vorname.isEmpty() || email.isEmpty() || passwort.isEmpty() || plz.isEmpty() ||
stadt.isEmpty() || strasse.isEmpty() || hausnummer.isEmpty()){
if(name.isEmpty()){
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Name' ist leer.");
alert.showAndWait();
} else if (vorname.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 (passwort.isEmpty()) {
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Passwort' ist leer.");
alert.showAndWait();
} else if (plz.isEmpty()) {
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Postleitzahl' ist leer.");
alert.showAndWait();
} else if (stadt.isEmpty()) {
alert = new Alert(Alert.AlertType.ERROR," Die Eingabefeld 'Stadt' ist leer.");
alert.showAndWait();
} else if (strasse.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(strasse,hausnummer,plz,stadt);
User newUser = new User(name,vorname,passwort,email,newAdresse);
long creatNewUser = AccountMgr.createUser(newUser);
if (creatNewUser > 0){
alert = new Alert(Alert.AlertType.CONFIRMATION,"Ihrer Daten wurde gespeichert.");
alert.showAndWait();
}
tfName.setText("");
tfVorname.setText("");
tfEmail.setText("");
pfPasswort.setText("");
tfPLZ.setText("");
tfStadt.setText("");
tfStrasse.setText("");
tfHausnummer.setText("");
}
} }
@FXML @FXML
private void onAnmeldenBtClick() throws IOException { private void onAnmeldenBtClick() throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 950,480);
StartViewApplication.primary.setScene(scene);
} }
} }

View File

@ -1,4 +0,0 @@
package com.bib.essensbestellungsverwaltung;
public class StartPageController {
}

View File

@ -7,7 +7,6 @@ package com.bib.essensbestellungsverwaltung;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -15,17 +14,14 @@ import java.io.IOException;
public class StartViewApplication extends Application { public class StartViewApplication extends Application {
public static Stage primary; public static Stage primary;
@Override @Override
public void start(Stage stage) throws IOException { public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 1200, 750); Scene scene = new Scene(fxmlLoader.load(), 950,480);
primary = stage; primary = stage;
stage.setTitle("Essen Bestellung im Kindergarten"); stage.setTitle("Essen Bestellung im Kindergarten");
stage.setScene(scene); stage.setScene(scene);
stage.show(); stage.show();
} }
public static void main(String[] args) { public static void main(String[] args) {
@ -36,9 +32,4 @@ public class StartViewApplication extends Application {
//Database.deleteSample(); //Database.deleteSample();
launch(); launch();
} }
public static void changeScene(String scene) throws IOException {
Parent p = FXMLLoader.load(StartViewApplication.class.getResource(scene));
primary.getScene().setRoot(p);
}
} }

View File

@ -56,7 +56,7 @@
<font> <font>
<Font name="Microsoft Tai Le Bold" size="12.0" /> <Font name="Microsoft Tai Le Bold" size="12.0" />
</font></Button> </font></Button>
<Button id="btSignUp" mnemonicParsing="false" prefHeight="25.0" prefWidth="101.0" style="-fx-background-color: tranparent;" text="Sign up" textFill="#7c7b7b" underline="true" onAction="#changeToSignUp" /> <Button id="btSignUp" mnemonicParsing="false" prefHeight="25.0" prefWidth="101.0" style="-fx-background-color: tranparent;" text="Sign up" textFill="#7c7b7b" underline="true" onAction="#onBtSingnupClick" />
</children> </children>
</HBox> </HBox>
</children> </children>

View File

@ -31,7 +31,7 @@
<Circle fill="#93c4f23d" layoutY="258.0" radius="106.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" /> <Circle fill="#93c4f23d" layoutY="258.0" radius="106.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" />
<VBox layoutX="262.0" prefHeight="400.0" prefWidth="364.0" style="-fx-background-color: white;"> <VBox layoutX="262.0" prefHeight="400.0" prefWidth="364.0" style="-fx-background-color: white;">
<children> <children>
<TextField fx:id="tfEmail" alignment="TOP_LEFT" prefHeight="26.0" prefWidth="282.0" promptText="Name" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfName" alignment="TOP_LEFT" prefHeight="26.0" prefWidth="282.0" promptText="Name" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<effect> <effect>
<Blend /> <Blend />
</effect> </effect>
@ -42,7 +42,7 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin> </VBox.margin>
</TextField> </TextField>
<TextField fx:id="tfBestätigungEmail" promptText="Vorname" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfVorname" promptText="Vorname" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<effect> <effect>
<Blend /> <Blend />
</effect> </effect>
@ -53,21 +53,18 @@
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin> </VBox.margin>
</TextField> </TextField>
<PasswordField fx:id="pfPasswort" accessibleRole="TEXT_FIELD" promptText="Email" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfEmail" promptText="Email" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<font>
<Font name="Microsoft Tai Le Bold" size="12.0" />
</font>
<opaqueInsets>
<Insets />
</opaqueInsets>
<effect> <effect>
<Blend /> <Blend />
</effect> </effect>
<font>
<Font name="Microsoft Tai Le Bold" size="12.0" />
</font>
<VBox.margin> <VBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</VBox.margin> </VBox.margin>
</PasswordField> </TextField>
<PasswordField fx:id="pfBestätigungPassowrt" promptText="Passwort" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <PasswordField fx:id="pfPasswort" accessibleRole="TEXT_FIELD" promptText="Passwort" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<font> <font>
<Font name="Microsoft Tai Le Bold" size="12.0" /> <Font name="Microsoft Tai Le Bold" size="12.0" />
</font> </font>
@ -83,7 +80,7 @@
</PasswordField> </PasswordField>
<HBox prefHeight="100.0" prefWidth="200.0"> <HBox prefHeight="100.0" prefWidth="200.0">
<children> <children>
<TextField prefHeight="35.0" prefWidth="92.0" promptText="PLZ" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfPLZ" prefHeight="35.0" prefWidth="92.0" promptText="PLZ" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<HBox.margin> <HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin> </HBox.margin>
@ -91,7 +88,7 @@
<Font name="Microsoft Tai Le Bold" size="12.0" /> <Font name="Microsoft Tai Le Bold" size="12.0" />
</font> </font>
</TextField> </TextField>
<TextField prefHeight="35.0" prefWidth="182.0" promptText="Stadt" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfStadt" prefHeight="35.0" prefWidth="182.0" promptText="Stadt" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<HBox.margin> <HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin> </HBox.margin>
@ -103,7 +100,7 @@
</HBox> </HBox>
<HBox prefHeight="100.0" prefWidth="200.0"> <HBox prefHeight="100.0" prefWidth="200.0">
<children> <children>
<TextField prefHeight="27.0" prefWidth="134.0" promptText="Straße" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfStrasse" prefHeight="27.0" prefWidth="134.0" promptText="Straße" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<HBox.margin> <HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin> </HBox.margin>
@ -111,7 +108,7 @@
<Font name="Microsoft Tai Le Bold" size="12.0" /> <Font name="Microsoft Tai Le Bold" size="12.0" />
</font> </font>
</TextField> </TextField>
<TextField prefHeight="27.0" prefWidth="99.0" promptText="Hausnummer" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;"> <TextField fx:id="tfHausnummer" prefHeight="27.0" prefWidth="99.0" promptText="Hausnummer" style="-fx-background-color: transparent; -fx-border-color: lightgray; -fx-border-width: 0 0 1 0;">
<HBox.margin> <HBox.margin>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</HBox.margin> </HBox.margin>