/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
 */
package presentation;

import acces_aux_donnes.praticienSQL;
import java.util.ArrayList;

/**
 *
 * @author emile.lalorcey
 */
public class jffConnexion extends javax.swing.JFrame {
    int profession;
    /**
     * Creates new form jffConnexion
     */
    public jffConnexion(int indice) {
        initComponents();
        this.profession = indice;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPFond = new javax.swing.JPanel();
        jLBonjour = new javax.swing.JLabel();
        jLIdentifiant = new javax.swing.JLabel();
        jTFIdentifiant = new javax.swing.JTextField();
        jLmdp = new javax.swing.JLabel();
        jPFmdp = new javax.swing.JPasswordField();
        jBquitter = new javax.swing.JButton();
        jBValider = new javax.swing.JButton();
        jLLogo = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLBonjour.setText("Bonjour veuillez vous identifier :");

        jLIdentifiant.setText("Identifiant :");

        jTFIdentifiant.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFIdentifiantActionPerformed(evt);
            }
        });

        jLmdp.setText("Mot de passe :");

        jPFmdp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPFmdpActionPerformed(evt);
            }
        });

        jBquitter.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/quitter.png"))); // NOI18N
        jBquitter.setText("Quitter");

        jBValider.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/valider.png"))); // NOI18N
        jBValider.setText("Valider");
        jBValider.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBValiderActionPerformed(evt);
            }
        });

        jLLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/logodetoure.gif"))); // NOI18N

        javax.swing.GroupLayout jPFondLayout = new javax.swing.GroupLayout(jPFond);
        jPFond.setLayout(jPFondLayout);
        jPFondLayout.setHorizontalGroup(
            jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPFondLayout.createSequentialGroup()
                .addGap(141, 141, 141)
                .addComponent(jBquitter)
                .addGap(18, 18, 18)
                .addComponent(jBValider)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPFondLayout.createSequentialGroup()
                .addGap(109, 109, 109)
                .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPFondLayout.createSequentialGroup()
                        .addComponent(jLBonjour)
                        .addGap(8, 8, 8))
                    .addGroup(jPFondLayout.createSequentialGroup()
                        .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPFondLayout.createSequentialGroup()
                                .addComponent(jLmdp, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(jPFondLayout.createSequentialGroup()
                                .addComponent(jLIdentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(19, 19, 19)))
                        .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTFIdentifiant, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
                            .addComponent(jPFmdp))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLLogo)
                .addGap(26, 26, 26))
        );
        jPFondLayout.setVerticalGroup(
            jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPFondLayout.createSequentialGroup()
                .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPFondLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jLBonjour))
                    .addGroup(jPFondLayout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jLLogo)))
                .addGap(29, 29, 29)
                .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLIdentifiant)
                    .addComponent(jTFIdentifiant, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(34, 34, 34)
                .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLmdp)
                    .addComponent(jPFmdp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 79, Short.MAX_VALUE)
                .addGroup(jPFondLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBquitter)
                    .addComponent(jBValider))
                .addGap(45, 45, 45))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(jPFond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(26, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 6, Short.MAX_VALUE)
                .addComponent(jPFond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTFIdentifiantActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFIdentifiantActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTFIdentifiantActionPerformed

    private void jPFmdpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPFmdpActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPFmdpActionPerformed

    private void jBValiderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBValiderActionPerformed
        String identifiant = jTFIdentifiant.getText();
        String mdp = String.valueOf(jPFmdp.getPassword());
        praticienSQL testPraticien = new praticienSQL();
        ArrayList<String>lePraticien = testPraticien.rechercherPraticien(identifiant,mdp);
        if (lePraticien.get(0) != null){
            System.out.print("TEST REUSSIE");
            new jffFamilleMedoc().setVisible(true);
        }else {
            System.out.print("TEST EMILE RACISTE");
        } 
    }//GEN-LAST:event_jBValiderActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(jffConnexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(jffConnexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(jffConnexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(jffConnexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jffConnexion(1).setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBValider;
    private javax.swing.JButton jBquitter;
    private javax.swing.JLabel jLBonjour;
    private javax.swing.JLabel jLIdentifiant;
    private javax.swing.JLabel jLLogo;
    private javax.swing.JLabel jLmdp;
    private javax.swing.JPasswordField jPFmdp;
    private javax.swing.JPanel jPFond;
    private javax.swing.JTextField jTFIdentifiant;
    // End of variables declaration//GEN-END:variables
}
