add: change Scenes

This commit is contained in:
Johannes Kantz 2023-01-31 07:41:21 +01:00 committed by Reshad Meher
parent c08b0aece5
commit d02acb89a4
5 changed files with 28 additions and 109 deletions

View File

@ -1,4 +1,4 @@
/*Reshad Meher*/ /*Richard Reiswich*/
package com.bib.essensbestellungsverwaltung; package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXML; import javafx.fxml.FXML;
@ -7,8 +7,10 @@ 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 java.io.IOException; import javafx.stage.Stage;
import java.io.IOException;
import java.util.HashMap;
public class LoginController { public class LoginController {
@FXML @FXML
@ -16,27 +18,26 @@ 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();
long loginPruefen = AccountMgr.login(email,password); if(benutzerMap.containsKey(email) && benutzerMap.containsValue(password)){
if(loginPruefen > 0){ // if user is worker: StartViewApplication.changeScene("workerMenu-view.fxml");
FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("menue-view.fxml")); StartViewApplication.changeScene("parentMenu-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 onBtSingnupClick() throws IOException { protected void changeToSignUp() throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("signUp-view.fxml")); StartViewApplication.changeScene("signUp-view.fxml");
Scene scene = new Scene(fxmlLoader.load(), 950,480);
StartViewApplication.primary.setScene(scene);
} }
} }

View File

@ -55,8 +55,7 @@ public class ParentMenuController {
@FXML @FXML
public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { public void onAusloggenClick(MouseEvent mouseEvent) throws IOException {
Parent p = FXMLLoader.load(StartViewApplication.class.getResource("workerMenu-view.fxml")); StartViewApplication.changeScene("workerMenu-view.fxml");
StartViewApplication.primary.getScene().setRoot(p);
} }
private void changePage(String page) { private void changePage(String page) {

View File

@ -1,100 +1,11 @@
/**
* @autor: Reshad Meher
*/
package com.bib.essensbestellungsverwaltung; package com.bib.essensbestellungsverwaltung;
import javafx.fxml.FXML; import javafx.event.ActionEvent;
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;
import java.util.HashMap;
public class SingUpController { public class SingUpController {
@FXML public void onKontoErstellenBtClick(ActionEvent actionEvent) {
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
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 { public void onAnmeldenBtClick(ActionEvent actionEvent) {
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
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

@ -7,6 +7,7 @@ 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;
@ -14,10 +15,11 @@ 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,900); Scene scene = new Scene(fxmlLoader.load(), 1200, 750);
primary = stage; primary = stage;
stage.setTitle("Essen Bestellung im Kindergarten"); stage.setTitle("Essen Bestellung im Kindergarten");
stage.setScene(scene); stage.setScene(scene);
@ -34,4 +36,9 @@ 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

@ -40,6 +40,7 @@ public class WorkerMenuController {
@FXML @FXML
public void onWochenplanClick(MouseEvent mouseEvent) { public void onWochenplanClick(MouseEvent mouseEvent) {
changePage("createFoodplan-view.fxml");
setButtonActive(wochenplanButton); setButtonActive(wochenplanButton);
} }
@ -59,6 +60,7 @@ public class WorkerMenuController {
@FXML @FXML
public void onMahlzeitClick(MouseEvent mouseEvent) { public void onMahlzeitClick(MouseEvent mouseEvent) {
changePage("createFood-view.fxml");
setButtonActive(mahlzeitButton); setButtonActive(mahlzeitButton);
} }
@ -69,8 +71,7 @@ public class WorkerMenuController {
@FXML @FXML
public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { public void onAusloggenClick(MouseEvent mouseEvent) throws IOException {
Parent p = FXMLLoader.load(StartViewApplication.class.getResource("parentMenu-view.fxml")); StartViewApplication.changeScene("parentMenu-view.fxml");
StartViewApplication.primary.getScene().setRoot(p);
} }
private void changePage(String page) { private void changePage(String page) {