add: change Scenes
This commit is contained in:
parent
c08b0aece5
commit
d02acb89a4
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,7 @@ public class ParentMenuController {
|
||||
|
||||
@FXML
|
||||
public void onAusloggenClick(MouseEvent mouseEvent) throws IOException {
|
||||
Parent p = FXMLLoader.load(StartViewApplication.class.getResource("workerMenu-view.fxml"));
|
||||
StartViewApplication.primary.getScene().setRoot(p);
|
||||
StartViewApplication.changeScene("workerMenu-view.fxml");
|
||||
}
|
||||
|
||||
private void changePage(String page) {
|
||||
|
@ -1,100 +1,11 @@
|
||||
/**
|
||||
* @autor: Reshad Meher
|
||||
*/
|
||||
package com.bib.essensbestellungsverwaltung;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
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;
|
||||
import javafx.event.ActionEvent;
|
||||
|
||||
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
|
||||
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("");
|
||||
}
|
||||
|
||||
public void onKontoErstellenBtClick(ActionEvent actionEvent) {
|
||||
}
|
||||
|
||||
@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);
|
||||
public void onAnmeldenBtClick(ActionEvent actionEvent) {
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ package com.bib.essensbestellungsverwaltung;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
@ -14,10 +15,11 @@ import java.io.IOException;
|
||||
|
||||
public class StartViewApplication extends Application {
|
||||
public static Stage primary;
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
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;
|
||||
stage.setTitle("Essen Bestellung im Kindergarten");
|
||||
stage.setScene(scene);
|
||||
@ -34,4 +36,9 @@ public class StartViewApplication extends Application {
|
||||
//Database.deleteSample();
|
||||
launch();
|
||||
}
|
||||
|
||||
public static void changeScene(String scene) throws IOException {
|
||||
Parent p = FXMLLoader.load(StartViewApplication.class.getResource(scene));
|
||||
primary.getScene().setRoot(p);
|
||||
}
|
||||
}
|
@ -40,6 +40,7 @@ public class WorkerMenuController {
|
||||
|
||||
@FXML
|
||||
public void onWochenplanClick(MouseEvent mouseEvent) {
|
||||
changePage("createFoodplan-view.fxml");
|
||||
setButtonActive(wochenplanButton);
|
||||
}
|
||||
|
||||
@ -59,6 +60,7 @@ public class WorkerMenuController {
|
||||
|
||||
@FXML
|
||||
public void onMahlzeitClick(MouseEvent mouseEvent) {
|
||||
changePage("createFood-view.fxml");
|
||||
setButtonActive(mahlzeitButton);
|
||||
}
|
||||
|
||||
@ -69,8 +71,7 @@ public class WorkerMenuController {
|
||||
|
||||
@FXML
|
||||
public void onAusloggenClick(MouseEvent mouseEvent) throws IOException {
|
||||
Parent p = FXMLLoader.load(StartViewApplication.class.getResource("parentMenu-view.fxml"));
|
||||
StartViewApplication.primary.getScene().setRoot(p);
|
||||
StartViewApplication.changeScene("parentMenu-view.fxml");
|
||||
}
|
||||
|
||||
private void changePage(String page) {
|
||||
|
Loading…
Reference in New Issue
Block a user