| @@ -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; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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) { | ||||
|  | ||||
|     } | ||||
| } | ||||
| @@ -52,4 +52,13 @@ public class User { | ||||
|     public Address getAddress() { | ||||
|         return address; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * | ||||
|      * @author Reshad Meher | ||||
|      */ | ||||
|     public User (String password){ | ||||
|         this.password = password; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user