mercredi 1 novembre 2017

Password and confirm password condition in JavaFX not working

This is my function button and I dont know why my reg which is an ID in my fxml file , dont want to save it in my SQLite database ; plus-> the if else condition is not working to see if there is really a mismatch of password!! below is the fxml file and a login class where I create a construction of my textfiles ; Please help

@FXML
        public void reg(ActionEvent event){
            if(this.passreg.getText()!= this.passreg2.getText()){
                try{


                }catch (InputMismatchException e){
                    this.label2.setText("Erreur ;Recommence ");
                }
            }else {
                this.label2.setText("Reussie!!! ");
            }
            String sqlInsert2= " INSERT INTO Admin (Username,Password,Email,division) VALUES (?,?,?,?) ";
            try{
                Connection conn =dbConnection.getConnection();
                PreparedStatement stmt = conn.prepareStatement(sqlInsert2);
                stmt.setString(1, this.userreg.getText());
                stmt.setString(2, this.passreg.getText());
                stmt.setString(3, this.emailreg.getText());
                stmt.setString(4,this.combobox2.getText());


                stmt.execute();
                conn.close();
            }catch (SQLException e) {
                e.printStackTrace();
            }


        }

here is the fxml file :

<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                     <children>
                        <Label fx:id="newreg" layoutX="24.0" layoutY="14.0" prefHeight="17.0" prefWidth="145.0" text="Registry " />
                        <TextField fx:id="userreg" layoutX="22.0" layoutY="60.0" prefHeight="25.0" prefWidth="200.0" promptText="Username" />
                        <PasswordField fx:id="passreg" layoutX="24.0" layoutY="97.0" prefHeight="25.0" prefWidth="196.0" promptText="password" />
                        <PasswordField fx:id="passreg2" layoutX="24.0" layoutY="131.0" prefHeight="25.0" prefWidth="197.0" promptText="password" />
                        <Button fx:id="reg" layoutX="24.0" layoutY="188.0" mnemonicParsing="false" onAction="#reg" prefHeight="25.0" prefWidth="73.0" text="Register" />
                        <Label fx:id="label2" layoutX="247.0" layoutY="192.0" prefHeight="17.0" prefWidth="206.0" text="Etat" AnchorPane.rightAnchor="41.0" />
                        <Button fx:id="clear2" layoutX="24.0" layoutY="223.0" mnemonicParsing="false" onAction="#clear2" prefHeight="25.0" prefWidth="73.0" text="Clear" />
                        <TextField fx:id="emailreg" layoutX="247.0" layoutY="60.0" prefHeight="25.0" prefWidth="208.0" promptText="email" />
                        <TextField fx:id="combobox2" layoutX="247.0" layoutY="131.0" prefHeight="25.0" prefWidth="209.0" promptText="Admin/Cassier" />
                     </children></AnchorPane>
              </content>

finally my constructors of my textfiles

public class LoginData {

    private StringProperty userreg;
    private StringProperty passreg;
    private StringProperty passreg2;
    private StringProperty emailreg;
    private StringProperty combobox2;



    public LoginData(String User,String Pass,String Pass2,String Email,String Combo){

        this.userreg= new SimpleStringProperty(User);
        this.passreg= new SimpleStringProperty(Pass);
        this.passreg2=new SimpleStringProperty(Pass2);
        this.emailreg=new SimpleStringProperty(Email);
        this.combobox2=new SimpleStringProperty(Combo);
    }


    public void getUser() {
        userreg.get();
    }

    public void setUser(String newUser) {
        userreg.set(newUser);
    }

    public StringProperty userregProperty(){
        return userreg;
    }

    public void getPass() {
        passreg.get();
    }

    public void setPass(String newPass) {
        passreg.set(newPass);
    }

    public StringProperty passregProperty(){
        return passreg;
    }
    public void getPass2() {
        passreg2.get();
    }

    public void setPass2(String newPass2) {
        passreg2.set(newPass2);
    }

    public StringProperty Pass2Property(){
        return passreg2;
    }
    public void getEmail() {
        emailreg.get();
    }

    public void setEmail(String newEmail) {
        emailreg.set(newEmail);
    }

    public StringProperty emailregProperty(){
        return emailreg;
    }
    public void getCombo() {
        combobox2.get();
    }

    public void setCombo(String newCombo) {
        combobox2.set(newCombo);
    }

    public StringProperty combobox2Property(){
        return combobox2;
    }
}

Aucun commentaire:

Enregistrer un commentaire