From c3b47d5c3693875bd15d33cf722d583730440409 Mon Sep 17 00:00:00 2001 From: Malte Schulze Hobeling Date: Mon, 6 Feb 2023 09:59:09 +0100 Subject: [PATCH] From main: Reshad Meher: sanitized c46eff1dda --- .../AccountMgr.java | 27 +++ .../SettingsController.java | 149 ++++++++++++++ .../bib/essensbestellungsverwaltung/User.java | 9 + .../parentMenue.css | 26 +++ .../settingsMenue.fxml | 183 ++++++++++++++++++ 5 files changed, 394 insertions(+) create mode 100644 src/main/java/com/bib/essensbestellungsverwaltung/SettingsController.java create mode 100644 src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue.css create mode 100644 src/main/resources/com/bib/essensbestellungsverwaltung/settingsMenue.fxml diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java b/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java index ca6a3cf..b113d41 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/AccountMgr.java @@ -457,4 +457,31 @@ public class AccountMgr { String[] priceD = { "1", String.valueOf((int) (price * 100)) }; Database.update("price", priceH, priceD); } + + + /** + * update password in User table + * @param password User + * @return update password + * @author Reshad Meher + */ + protected static long updatePassword( User password) { + + String[] pwH = {"password"}; + String[] pwD = {password.getPassword()}; + long updates = Database.update("user",pwH,pwD); + return updates; + } + /** + * update adress in User table + * @param address Adresss + * @return update Adrssse + * @author Reshad Meher + */ + protected static long updateAdreess(Address address ){ + String[] adH = {"stree","numbrt","plz","city"}; + String[] adD = {address.getStreet(),address.getNumber(),address.getPlz(),address.getCity()}; + long updates = Database.update("user",adH,adD); + return updates; + } } diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/SettingsController.java b/src/main/java/com/bib/essensbestellungsverwaltung/SettingsController.java new file mode 100644 index 0000000..a16d714 --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/SettingsController.java @@ -0,0 +1,149 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.TextField; + +import java.io.IOException; +/** + * @author Reshad Meher + */ + +public class SettingsController { + + @FXML + private TextField tfOldPassword; + @FXML + private TextField tfNewPassword; + @FXML + private TextField tfConfirmNewPasword; + @FXML + private TextField tfPostCode; + @FXML + private TextField tfStreet; + @FXML + private TextField tfCity; + @FXML + private TextField tfHousNumber; + + Alert alert; + @FXML + private void onPasswordChangClick(){ + String oldPassword = tfOldPassword.getText(); + String newPassword = tfNewPassword.getText(); + String confirmNewPassword = tfConfirmNewPasword.getText(); + if(!oldPassword.isEmpty() && !newPassword.isEmpty() && !confirmNewPassword.isEmpty()){ + if(!newPassword.equals(confirmNewPassword)){ + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Passwort"); + alert.setHeaderText("Ihre neue Passwort und Bestätigung passt nicht. Nochmal versuchen"); + alert.showAndWait(); + }else { + User userPassword = new User(newPassword); + long UpdateUserPassword = AccountMgr.updatePassword(userPassword); + if (UpdateUserPassword > 0){ + alert.setTitle("Passwort"); + alert.setHeaderText("Ihre Passwort erfolgreich geändert"); + alert.showAndWait(); + } + else { + alert.setTitle("Passwort"); + alert.setHeaderText("nei"); + alert.showAndWait(); + } + } + + tfOldPassword.setText(""); + tfNewPassword.setText(""); + tfConfirmNewPasword.setText(""); + } + else { + if(oldPassword.isEmpty()){ + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Passwort"); + alert.setHeaderText("Ihre aktuelles Passwort ist leer."); + alert.showAndWait(); + }else if(newPassword.isEmpty()){ + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Passwort"); + alert.setHeaderText("Ihre neues Passwort ist leer."); + alert.showAndWait(); + }if(confirmNewPassword.isEmpty()){ + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Passwort"); + alert.setHeaderText("Ihre neue Passwort Bestätigung ist leer."); + alert.showAndWait(); + }else{ + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Passwort"); + alert.setHeaderText("Ihre Passwort wurde nicht geändert"); + alert.showAndWait(); + } + + } + } + + @FXML + private void onChangAdressClick(){ + String postCode = tfPostCode.getText(); + String street = tfStreet.getText(); + String city = tfCity.getText(); + String housNumber = tfHousNumber.getText(); + if (!postCode.isEmpty() && !street.isEmpty() && !city.isEmpty() && !housNumber.isEmpty()) { + Address userAdress = new Address(street,housNumber,postCode,city); + long UpdateUserAdress = AccountMgr.updateAdreess(userAdress); + if (UpdateUserAdress > 0) { + alert.setTitle("Adresse"); + alert.setHeaderText("Ihre Adresse erfolgreich geändert"); + alert.showAndWait(); + + tfPostCode.setText(""); + tfStreet.setText(""); + tfCity.setText(""); + tfHousNumber.setText(""); + } + + }else { + if (postCode.isEmpty()) { + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Adresse"); + alert.setHeaderText("Postleitzahl ist leer."); + alert.showAndWait(); + } else if (street.isEmpty()) { + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Adresse"); + alert.setHeaderText("Straß ist leer."); + alert.showAndWait(); + } else if (city.isEmpty()) { + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Adresse"); + alert.setHeaderText("Statd ist leer."); + alert.showAndWait(); + } else if (housNumber.isEmpty()) { + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Adresse"); + alert.setHeaderText("Hausnumer ist leer."); + alert.showAndWait(); + } else { + alert = new Alert(Alert.AlertType.WARNING); + alert.setTitle("Adresse"); + alert.setHeaderText("Ihre Adresse wurde nicht geändert"); + alert.showAndWait(); + } + } + } + @FXML + private void onLogOutBtClick() throws IOException{ + + FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 950,700); + StartViewApplication.primary.setScene(scene); + } + + public void onSettingBtClick(ActionEvent actionEvent) { + + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/User.java b/src/main/java/com/bib/essensbestellungsverwaltung/User.java index fb89351..98f3160 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/User.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/User.java @@ -52,4 +52,13 @@ public class User { public Address getAddress() { return address; } + + + /** + * + * @author Reshad Meher + */ + public User (String password){ + this.password = password; + } } diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue.css b/src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue.css new file mode 100644 index 0000000..c43feb3 --- /dev/null +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue.css @@ -0,0 +1,26 @@ +#contentContainer{ + -fx-background-color: #add8e6; +} + +#contentContainer2{ + -fx-background-color: lightblue; +} + +#contentButton{ + -fx-background-color: transparent; +} + +#contentButton:hover{ + -fx-underline: true; + -fx-background-color: #78939d; + -fx-text-fill: white; +} + +#btLogOut{ + -fx-background-color: transparent; + -fx-pref-height: 40px; +} + +#btLogOut:hover{ + -fx-underline: true; +} \ No newline at end of file diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/settingsMenue.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/settingsMenue.fxml new file mode 100644 index 0000000..27fb275 --- /dev/null +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/settingsMenue.fxml @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +