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