Gui.admin.NouveauConsulterinfoAdherent.java Source code

Java tutorial

Introduction

Here is the source code for Gui.admin.NouveauConsulterinfoAdherent.java

Source

    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */

    package Gui.admin;

import Entit.Adherent;
    import javax.mail.Message;
    import javax.mail.Transport;
    import javax.mail.PasswordAuthentication;
    import java.util.Properties;
    import javax.mail.Session;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;

    import com.itextpdf.text.BaseColor;
    import com.itextpdf.text.DocumentException;
    import com.itextpdf.text.FontFactory;
    import com.itextpdf.text.Image;
    import com.itextpdf.text.PageSize;
    import com.itextpdf.text.Paragraph;
    import com.itextpdf.text.pdf.PdfPCell;
    import com.itextpdf.text.pdf.PdfPTable;
    import com.itextpdf.text.pdf.PdfWriter;
    import com.tn.connect.MyConnection;
    import com.tn.doa.AdherentDAO;
    import com.tn.tableModel.gestionAdherent;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.awt.HeadlessException;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.Date;
    import java.util.List;
    import javax.swing.JOptionPane;
    import net.proteanit.sql.DbUtils;
    import java.text.*;
    import javax.swing.JTable;

    /**
     *
     * @author majdi
     */
    public class NouveauConsulterinfoAdherent extends javax.swing.JPanel {

        /**
         * Creates new form ConsulterinfoAdherent
         */
        public NouveauConsulterinfoAdherent() {
            initComponents();
            // findCombo();
            update_table();
            updateButton.setVisible(false);
        }

        /**
         * 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() {

            jScrollPane6 = new javax.swing.JScrollPane();
            adherentTable = new javax.swing.JTable();
            jPanel1 = new javax.swing.JPanel();
            FromText = new javax.swing.JTextField();
            ToText = new javax.swing.JTextField();
            SubjectText = new javax.swing.JTextField();
            jScrollPane1 = new javax.swing.JScrollPane();
            EmailText = new javax.swing.JTextArea();
            fromLabel = new javax.swing.JLabel();
            toLabel = new javax.swing.JLabel();
            SubjectLabel = new javax.swing.JLabel();
            MailBoutton = new javax.swing.JButton();
            jPanel3 = new javax.swing.JPanel();
            jPanel2 = new javax.swing.JPanel();
            idadherent_lbl = new javax.swing.JLabel();
            idadherenttxt = new javax.swing.JTextField();
            nom_lbl = new javax.swing.JLabel();
            nomadherentTxt = new javax.swing.JTextField();
            prenomadherent_lbl = new javax.swing.JLabel();
            prenomAdhrentTxt = new javax.swing.JTextField();
            adresseaderent_lbl = new javax.swing.JLabel();
            adresseAdherentTxt = new javax.swing.JTextField();
            telAdherentTXT = new javax.swing.JTextField();
            tel_lbl = new javax.swing.JLabel();
            nbr_recl_lbl = new javax.swing.JLabel();
            nbrReclamationsTxt = new javax.swing.JTextField();
            mdpAdherentTXT = new javax.swing.JPasswordField();
            jLabel1 = new javax.swing.JLabel();
            jPanel4 = new javax.swing.JPanel();
            jLabel4 = new javax.swing.JLabel();
            txtSearchAdherent = new javax.swing.JTextField();
            jLabel5 = new javax.swing.JLabel();
            name_comboBox = new javax.swing.JComboBox();
            jPanel5 = new javax.swing.JPanel();
            BloquerBoutton = new javax.swing.JButton();
            RapportBoutton = new javax.swing.JButton();
            deleteButton = new javax.swing.JButton();
            ImprimerBoutton = new javax.swing.JButton();
            updateButton = new javax.swing.JButton();

            setMaximumSize(new java.awt.Dimension(927, 682));
            setMinimumSize(new java.awt.Dimension(927, 682));

            adherentTable.setModel(new gestionAdherent());
            adherentTable.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    adherentTableMouseClicked(evt);
                }
            });
            jScrollPane6.setViewportView(adherentTable);

            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Envoyer Un Mail A L'adherent :",
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 14))); // NOI18N

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

            EmailText.setColumns(20);
            EmailText.setRows(5);
            jScrollPane1.setViewportView(EmailText);

            fromLabel.setText("From");

            toLabel.setText("To");

            SubjectLabel.setText("Subject");

            MailBoutton.setText("Envoyer");
            MailBoutton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    MailBouttonActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1Layout.setHorizontalGroup(jPanel1Layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(fromLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(toLabel)).addGap(18, 18, 18)
                                            .addGroup(jPanel1Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(ToText).addComponent(FromText)))
                                    .addGroup(jPanel1Layout.createSequentialGroup().addComponent(SubjectLabel)
                                            .addGap(18, 18, 18)
                                            .addGroup(jPanel1Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(jScrollPane1,
                                                            javax.swing.GroupLayout.Alignment.TRAILING)
                                                    .addComponent(SubjectText)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                            jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                                    .addComponent(MailBoutton)))
                            .addContainerGap()));
            jPanel1Layout
                    .setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap()
                                    .addGroup(jPanel1Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                    .addComponent(fromLabel)
                                                    .addComponent(FromText, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                                    .addGap(20, 20, 20)
                                                    .addGroup(jPanel1Layout
                                                            .createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.BASELINE)
                                                            .addComponent(ToText,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(toLabel))
                                                    .addGap(18, 18, 18).addComponent(SubjectText,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(SubjectLabel))
                                    .addGap(28, 28, 28)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(MailBoutton)));

            jPanel3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
            jPanel3.setMaximumSize(new java.awt.Dimension(392, 336));
            jPanel3.setMinimumSize(new java.awt.Dimension(392, 336));

            jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Information De L'Adherent :",
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 14))); // NOI18N

            idadherent_lbl.setText("IdAdhrent :");

            idadherenttxt.setEditable(false);
            idadherenttxt.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    idadherenttxtActionPerformed(evt);
                }
            });

            nom_lbl.setText("Nom :");

            nomadherentTxt.setEditable(false);

            prenomadherent_lbl.setText("Prenom :");

            prenomAdhrentTxt.setEditable(false);

            adresseaderent_lbl.setText("Adresse E-mail : ");

            adresseAdherentTxt.setEditable(false);

            telAdherentTXT.setEditable(false);

            tel_lbl.setText("Telephone :");

            nbr_recl_lbl.setText("Nombres de rclamations:");

            nbrReclamationsTxt.setEditable(false);

            mdpAdherentTXT.setEditable(false);
            mdpAdherentTXT.setText("jPasswordField1");

            jLabel1.setText("Mot De passe Adhrent :");

            javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
            jPanel2.setLayout(jPanel2Layout);
            jPanel2Layout.setHorizontalGroup(
                    jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel2Layout
                            .createSequentialGroup().addContainerGap().addGroup(jPanel2Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                                            jPanel2Layout.createSequentialGroup().addGroup(jPanel2Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(adresseaderent_lbl).addComponent(tel_lbl)).addGap(48,
                                                            48, 48)
                                                    .addGroup(jPanel2Layout
                                                            .createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addComponent(telAdherentTXT)
                                                            .addComponent(adresseAdherentTxt)))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addGroup(jPanel2Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(idadherent_lbl).addComponent(nom_lbl)
                                                    .addComponent(prenomadherent_lbl))
                                            .addGap(66, 66, 66)
                                            .addGroup(jPanel2Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                            false)
                                                    .addComponent(idadherenttxt, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            146, Short.MAX_VALUE)
                                                    .addComponent(nomadherentTxt).addComponent(prenomAdhrentTxt,
                                                            javax.swing.GroupLayout.Alignment.TRAILING))
                                            .addGap(0, 0, Short.MAX_VALUE))
                                    .addGroup(jPanel2Layout
                                            .createSequentialGroup()
                                            .addGroup(jPanel2Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(nbr_recl_lbl).addComponent(jLabel1))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addGroup(jPanel2Layout
                                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addComponent(mdpAdherentTXT).addComponent(nbrReclamationsTxt))))
                            .addContainerGap()));
            jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(idadherent_lbl).addComponent(idadherenttxt,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(nom_lbl).addComponent(nomadherentTxt,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(prenomadherent_lbl).addComponent(prenomAdhrentTxt,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(adresseaderent_lbl).addComponent(adresseAdherentTxt,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(telAdherentTXT, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tel_lbl))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(nbr_recl_lbl).addComponent(nbrReclamationsTxt,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(21, 21, 21)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel1).addComponent(mdpAdherentTXT,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap(34, Short.MAX_VALUE)));

            javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
            jPanel3.setLayout(jPanel3Layout);
            jPanel3Layout.setHorizontalGroup(jPanel3Layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
            jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(13, Short.MAX_VALUE)));

            jPanel4.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

            jLabel4.setText("Chercher Un Adherent :");

            txtSearchAdherent.addKeyListener(new java.awt.event.KeyAdapter() {
                public void keyReleased(java.awt.event.KeyEvent evt) {
                    txtSearchAdherentKeyReleased(evt);
                }
            });

            jLabel5.setText("Selectionnez le Nom et prnom de l'adherent");

            name_comboBox.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
                public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
                }

                public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
                    name_comboBoxPopupMenuWillBecomeInvisible(evt);
                }

                public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
                }
            });
            name_comboBox.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    name_comboBoxActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
            jPanel4.setLayout(jPanel4Layout);
            jPanel4Layout.setHorizontalGroup(
                    jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel4Layout
                            .createSequentialGroup().addContainerGap().addGroup(jPanel4Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel4Layout.createSequentialGroup().addComponent(jLabel4)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(txtSearchAdherent, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    175, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 243,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18).addComponent(name_comboBox,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 98,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
            jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap(16, Short.MAX_VALUE)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 35,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(name_comboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 28,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtSearchAdherent, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap()));

            jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Vos Options d'Administrateur : ",
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 14))); // NOI18N

            BloquerBoutton.setText("Bloquer");
            BloquerBoutton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    BloquerBouttonActionPerformed(evt);
                }
            });

            RapportBoutton.setText("Gnrer Rapport");
            RapportBoutton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    RapportBouttonActionPerformed(evt);
                }
            });

            deleteButton.setText("Supprimer");
            deleteButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    deleteButtonActionPerformed(evt);
                }
            });

            ImprimerBoutton.setText("Imprimer");
            ImprimerBoutton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ImprimerBouttonActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
            jPanel5.setLayout(jPanel5Layout);
            jPanel5Layout.setHorizontalGroup(jPanel5Layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(RapportBoutton, javax.swing.GroupLayout.PREFERRED_SIZE, 189,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 189,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)
                            .addGroup(
                                    jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(BloquerBoutton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(ImprimerBoutton, javax.swing.GroupLayout.DEFAULT_SIZE, 169,
                                                    Short.MAX_VALUE))
                            .addGap(0, 0, Short.MAX_VALUE)));
            jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(BloquerBoutton).addComponent(deleteButton))
                            .addContainerGap(66, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(ImprimerBoutton).addComponent(RapportBoutton,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 22,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap()));

            updateButton.setText("Modifier");
            updateButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    updateButtonActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
            this.setLayout(layout);
            layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 335,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addGap(18, 18, 18).addGroup(
                                            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            539, Short.MAX_VALUE)
                                                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                            .addContainerGap(25, Short.MAX_VALUE))
                                    .addGroup(layout.createSequentialGroup().addGap(40, 40, 40)
                                            .addComponent(updateButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addContainerGap()))));
            layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addGap(27, 27, 27)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                            .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18).addComponent(jScrollPane6,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16,
                                                    Short.MAX_VALUE)
                                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(13, 13, 13))
                                    .addGroup(layout.createSequentialGroup().addGap(30, 30, 30)
                                            .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(updateButton)
                                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))));
        }// </editor-fold>//GEN-END:initComponents

        private void adherentTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_adherentTableMouseClicked

            try {

                int row = adherentTable.getSelectedRow();
                String Table_Click = (adherentTable.getModel().getValueAt(row, 0).toString());
                String requete = "select * from adherent where id_adherent='" + Table_Click + "'";

                Statement statement = MyConnection.getInstance().createStatement();
                PreparedStatement ps = MyConnection.getInstance().prepareStatement(requete);
                ResultSet resultat = ps.executeQuery();

                if (resultat.next()) {

                    String add1 = resultat.getString("id_adherent");
                    idadherenttxt.setText(add1);
                    String add2 = resultat.getString("nom");
                    nomadherentTxt.setText(add2);
                    String add3 = resultat.getString("prenom");
                    prenomAdhrentTxt.setText(add3);
                    String add4 = resultat.getString("adresse_mail");
                    adresseAdherentTxt.setText(add4);
                    String add5 = resultat.getString("mdp");
                    // mdpAdherentTXT.setText(add5);
                    String add6 = resultat.getString("telephone");
                    telAdherentTXT.setText(add6);
                    String add7 = resultat.getString("nombre_reclamation");
                    nbrReclamationsTxt.setText(add7);

                }

            }

            catch (Exception e) {

                JOptionPane.showMessageDialog(null, e);
            }

        }//GEN-LAST:event_adherentTableMouseClicked

        private void idadherenttxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idadherenttxtActionPerformed

            idadherenttxt.setEditable(false);
        }//GEN-LAST:event_idadherenttxtActionPerformed

        private void update_table() {

            try {
                String sql = "select * from adherent";
                Statement statement = MyConnection.getInstance().createStatement();
                PreparedStatement ps = MyConnection.getInstance().prepareStatement(sql);
                ResultSet resultat = ps.executeQuery();
                adherentTable.setModel(DbUtils.resultSetToTableModel(resultat));

            }

            catch (Exception e) {

                JOptionPane.showMessageDialog(null, e);

            }

        }

        private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
            int p = JOptionPane.showConfirmDialog(null, "etes-vous sur de vouloir supprimer", "delete",
                    JOptionPane.YES_NO_OPTION);
            AdherentDAO adherentDAO = new AdherentDAO();
            if (p == 0) {
                int id = Integer.parseInt(idadherenttxt.getText());
                adherentDAO.deleteAdherent(id);

                String requete = "delete from adherent where id_adherent= ?";

                update_table();
            }
        }//GEN-LAST:event_deleteButtonActionPerformed

        public void update(Graphics g) {
            super.update(g);
        }

        private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateButtonActionPerformed

            try {
                int id = Integer.parseInt(idadherenttxt.getText());
                String nom = nomadherentTxt.getText();
                String prenom = prenomAdhrentTxt.getText();
                String adresseMail = adresseAdherentTxt.getText();
                String mdp = mdpAdherentTXT.getText();
                int tel = Integer.parseInt(telAdherentTXT.getText());
                int breReclamation = Integer.parseInt(nbrReclamationsTxt.getText());

                AdherentDAO adherentDAO = new AdherentDAO();
                adherentDAO.updateAdherent(id, nom, prenom, adresseMail, mdp, tel, breReclamation);

            }

            catch (Exception e) {

                JOptionPane.showMessageDialog(null, e);

            }

            update_table();
        }//GEN-LAST:event_updateButtonActionPerformed

        private void name_comboBoxPopupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_name_comboBoxPopupMenuWillBecomeInvisible
            AdherentDAO adherentDAO = new AdherentDAO();
            Authentification authentification = new Authentification();
            List<Adherent> listeAdherents = new ArrayList<Adherent>();
            listeAdherents = adherentDAO.DisplayAllAdhrernt();
            for (int i = 0; i < listeAdherents.size(); i++) {
                name_comboBox.addItem(listeAdherents.get(i).getNom() + " " + listeAdherents.get(i).getPrenom());
            }

        }//GEN-LAST:event_name_comboBoxPopupMenuWillBecomeInvisible

        private void name_comboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_name_comboBoxActionPerformed

            //       
            //         try {
            //         
            //             String requete = "select * from adherent";
            //             Statement statement = MyConnection.getInstance().createStatement();
            //             PreparedStatement ps = MyConnection.getInstance().prepareStatement(requete);
            //             ResultSet resultat =ps.executeQuery();
            //             
            //             
            //             while (resultat.next())
            //             {
            //                 
            //                 String name= resultat.getString("nom");
            //                 name_comboBox.addItem(name);
            //              } }
            //         
            //         
            //         catch(Exception e)
            //         
            //         {  
            //             JOptionPane.showMessageDialog(null, e);   
            //         }
            //         
            //             

        }//GEN-LAST:event_name_comboBoxActionPerformed

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

        private void RapportBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RapportBouttonActionPerformed

            String value1 = idadherenttxt.getText();
            String value2 = nomadherentTxt.getText();
            String value3 = prenomAdhrentTxt.getText();
            String value4 = adresseAdherentTxt.getText();
            String value5 = mdpAdherentTXT.getText();
            String value6 = telAdherentTXT.getText();
            String value7 = nbrReclamationsTxt.getText();

            try {
                // pagesize.A4.rotate() pour voir le rapport dans IDE 
                com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.A4.rotate());
                PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("rapport.pdf"));

                if ((new File("rapport.pdf")).exists()) {

                    Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler rapport.pdf");
                    p.waitFor();

                } else {

                    System.out.println("File is not exists");

                }

                document.open();
                // Date
                document.add(new Paragraph(new Date().toString()));
                document.add(new Paragraph("Rapport Statistiques",
                        FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED)));
                document.add(new Paragraph(
                        "--------------------------------------------------------------------------------------------------------------------------------------------------------------------"));

                // ajoute un tableau dans le rapport 

                //                  PdfPTable table = new PdfPTable(4);
                //                  
                //                   PdfPCell cell = new PdfPCell(new Paragraph("Informations Adhrents"));
                //                     // le titre du tableau 
                //                  cell.setColspan(10);
                //                  cell.setBackgroundColor(BaseColor.GREEN);
                //                  table.addCell(cell);

                //                  table.addCell("Id Adhrent");
                //                  table.addCell("Nom de l'adhrent");
                //                  table.addCell("Prnom de l'adhrent");
                //                  table.addCell("Numro de l'adhrent");
                //                  document.add(table);
                // le titre du tableau 

                // ajouter l'image dans le fichier pdf 
                Image image = Image.getInstance("statistiques.png");
                document.add(new Paragraph("statistiques.png"));
                document.add(image);

                // document.add(new Paragraph("Salut sindoud", FontFactory.getFont(FontFactory.TIMES_BOLD,18,Font.BOLD, BaseColor.BLUE)));

                //document.add(new Paragraph (new Date().toString()));

                PdfPTable table = new PdfPTable(6);
                PdfPCell cell = new PdfPCell(new Paragraph("Titre"));
                cell.setColspan(4);
                //  cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setBackgroundColor(BaseColor.GREEN);
                table.addCell("id de l'adherent");
                table.addCell(value1);
                table.addCell("Nom de l'adhrent");
                table.addCell(value2);
                table.addCell("Prnom de l'adhrent");
                table.addCell(value3);
                table.addCell("adresse de l'adhrent");
                table.addCell(value4);
                table.addCell("mot de passe de l'adherent");
                table.addCell(value5);
                table.addCell("tel de l'adherent ");
                table.addCell(value6);
                table.addCell("nombre de reclamations");
                table.addCell(value7);

                document.add(table);

                document.close();
                //com.itextpdf.text.Image image1= com.itextpdf.text.Image.getInstance("statistiques.png");
                // image1.scaleAbsolute(400,300);
                //document.add(image1);
                //PdfContentByte cb= writer.getDirectContent();
                JOptionPane.showMessageDialog(null, "rapport enregistr");
            }

            catch (DocumentException | IOException | InterruptedException | HeadlessException e) {

                JOptionPane.showMessageDialog(null, e);

            }
            //
        }//GEN-LAST:event_RapportBouttonActionPerformed

        private void MailBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MailBouttonActionPerformed
            String From = FromText.getText();
            String To = ToText.getText();
            String Subject = SubjectText.getText();
            String text = EmailText.getText();

            Properties pros = new Properties();
            pros.put("mail.smtp.host", "smtp.gmail.com");
            pros.put("mail.smtp.socketFactory.port", "465");
            pros.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
            pros.put("mail.smtp.auth", "true");
            pros.put("mail.smtp.port", "465");

            Session session = Session.getDefaultInstance(pros,

                    new javax.mail.Authenticator() {

                        protected PasswordAuthentication getPasswordAuthentication() {

                            return new PasswordAuthentication("covoiturage3a18@gmail.com", "sindasalma");

                        }
                    }

            );

            try {
                Message message = new MimeMessage(session);
                message.setFrom(new InternetAddress(From));
                message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(To));
                message.setSubject(Subject);
                message.setText(text);
                Transport.send(message);

                JOptionPane.showMessageDialog(null, "mail recu ");

            } catch (Exception e) {

                JOptionPane.showMessageDialog(null, "Vrifier les emails saisis");

            }
        }//GEN-LAST:event_MailBouttonActionPerformed

        private void BloquerBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BloquerBouttonActionPerformed

            AdherentDAO adherentDAO = new AdherentDAO();
            int row = adherentTable.getSelectedRow();
            int id = (int) adherentTable.getValueAt(row, 0);
            Adherent adherent = new Adherent();

            adherentDAO.setEetatAdherent(id);
        }//GEN-LAST:event_BloquerBouttonActionPerformed

        private void txtSearchAdherentKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchAdherentKeyReleased

            try {

                String requete = " select * from adherent where nom=?";
                Statement statement = MyConnection.getInstance().createStatement();
                PreparedStatement ps = MyConnection.getInstance().prepareStatement(requete);
                ps.setString(1, txtSearchAdherent.getText());

                ResultSet resultat = ps.executeQuery();

                if (resultat.next()) {

                    String add1 = resultat.getString("id_adherent");
                    idadherenttxt.setText(add1);
                    String add2 = resultat.getString("nom");
                    nomadherentTxt.setText(add2);
                    String add3 = resultat.getString("prenom");
                    prenomAdhrentTxt.setText(add3);
                    String add4 = resultat.getString("adresse_mail");
                    adresseAdherentTxt.setText(add4);
                    String add5 = resultat.getString("mdp");
                    mdpAdherentTXT.setText(add5);
                    String add6 = resultat.getString("telephone");
                    telAdherentTXT.setText(add6);
                    String add7 = resultat.getString("nombre_reclamation");
                    nbrReclamationsTxt.setText(add7);

                }

            } catch (Exception e) {

                JOptionPane.showMessageDialog(null, e);

            }

        }//GEN-LAST:event_txtSearchAdherentKeyReleased

        private void ImprimerBouttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImprimerBouttonActionPerformed

            MessageFormat header = new MessageFormat("rapport imprim");
            MessageFormat footer = new MessageFormat("Page{0,number,integer}");

            try {

                adherentTable.print(JTable.PrintMode.NORMAL, header, footer);

            } catch (java.awt.print.PrinterException e)

            {

                System.err.format("vous ne pouvez pas faire l'impression", e.getMessage());

            }

        }//GEN-LAST:event_ImprimerBouttonActionPerformed

        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton BloquerBoutton;
        private javax.swing.JTextArea EmailText;
        private javax.swing.JTextField FromText;
        private javax.swing.JButton ImprimerBoutton;
        private javax.swing.JButton MailBoutton;
        private javax.swing.JButton RapportBoutton;
        private javax.swing.JLabel SubjectLabel;
        private javax.swing.JTextField SubjectText;
        private javax.swing.JTextField ToText;
        private javax.swing.JTable adherentTable;
        private javax.swing.JTextField adresseAdherentTxt;
        private javax.swing.JLabel adresseaderent_lbl;
        private javax.swing.JButton deleteButton;
        private javax.swing.JLabel fromLabel;
        private javax.swing.JLabel idadherent_lbl;
        private static javax.swing.JTextField idadherenttxt;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JLabel jLabel5;
        private javax.swing.JPanel jPanel1;
        private javax.swing.JPanel jPanel2;
        private javax.swing.JPanel jPanel3;
        private javax.swing.JPanel jPanel4;
        private javax.swing.JPanel jPanel5;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JScrollPane jScrollPane6;
        private javax.swing.JPasswordField mdpAdherentTXT;
        private javax.swing.JComboBox name_comboBox;
        private javax.swing.JTextField nbrReclamationsTxt;
        private javax.swing.JLabel nbr_recl_lbl;
        private javax.swing.JLabel nom_lbl;
        private javax.swing.JTextField nomadherentTxt;
        private javax.swing.JTextField prenomAdhrentTxt;
        private javax.swing.JLabel prenomadherent_lbl;
        private javax.swing.JTextField telAdherentTXT;
        private javax.swing.JLabel tel_lbl;
        private javax.swing.JLabel toLabel;
        private javax.swing.JTextField txtSearchAdherent;
        private javax.swing.JButton updateButton;
        // End of variables declaration//GEN-END:variables
    }