GUI.Fixings.java Source code

Java tutorial

Introduction

Here is the source code for GUI.Fixings.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;

import DAO.ArticleDAO;
import DAO.CarDAO;
import DAO.FixingDAO;
import Entities.Article;
import Entities.Car;
import Entities.Fixing;
import Utils.ConnectedUser;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Font;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.FileOutputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Marwen
 */
public class Fixings extends javax.swing.JFrame {

    private static Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD);
    private static Font redFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.RED);
    private static Font subFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD);
    private static Font smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);

    /**
     * Creates new form InterfaceReparation
     */
    public Fixings() {
        initComponents();
    }

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

        jLabel4 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        numSoucheET = new javax.swing.JTextField();
        DesginationArticleET = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        designationReparationET = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        utilisationSP = new javax.swing.JComboBox();
        montantET = new javax.swing.JTextField();
        immatriculationET = new javax.swing.JTextField();
        indexET = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        immatriculationCB = new javax.swing.JCheckBox();
        seachImmatET = new javax.swing.JTextField();
        departementCB = new javax.swing.JCheckBox();
        searchDepartementET = new javax.swing.JTextField();
        dateCB = new javax.swing.JCheckBox();
        seachBT = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableJT = new javax.swing.JTable();
        printBT = new javax.swing.JButton();
        addBT = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        dateReparationET = new javax.swing.JTextField();
        seachDateET = new javax.swing.JTextField();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenu6 = new javax.swing.JMenu();

        jLabel4.setText("jLabel4");

        jTextField8.setText("jTextField8");

        jTable1.setModel(
                new javax.swing.table.DefaultTableModel(
                        new Object[][] { { null, null, null, null }, { null, null, null, null },
                                { null, null, null, null }, { null, null, null, null } },
                        new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
        jScrollPane1.setViewportView(jTable1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setText("Deconnecter");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Bienvenue Mr");

        jLabel2.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 51, 153));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Rechercher");

        jLabel3.setText("Numero de Souche");

        jLabel5.setText("Designation Article");

        jLabel7.setText("Date de Rparation");

        jLabel8.setText("Utilisation");

        jLabel9.setText("Dsignation de rparation");

        jLabel10.setText("Immatriculation");

        jLabel11.setText("Montant");

        jLabel12.setText("Index");

        utilisationSP.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Fonction", "Service" }));

        jLabel13.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(0, 51, 153));
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText("Ajouter Rparation");

        immatriculationCB.setText("Immatriculation");

        departementCB.setText("Dpartement");
        departementCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                departementCBActionPerformed(evt);
            }
        });

        dateCB.setText("Date");

        seachBT.setText("Rechercher");
        seachBT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                seachBTActionPerformed(evt);
            }
        });

        tableJT.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][] { { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null },
                        { null, null, null, null, null, null, null, null, null } },
                new String[] { "Numero de Souche", "Fournisseur", "Dpartement", "Immatriculation", "Utilisation",
                        "Date de Rparation", "Designation de rparation", "Index", "Montant" }));
        jScrollPane2.setViewportView(tableJT);

        printBT.setText("Imprimmer");
        printBT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printBTActionPerformed(evt);
            }
        });

        addBT.setText("Ajouter");
        addBT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addBTActionPerformed(evt);
            }
        });

        jButton5.setText("Annuler");

        jMenu1.setText("Vehicule");

        jMenuItem2.setText("Ajouter vehicule");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem3.setText("Etat des vehicules dans une anne");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuItem4.setText("Alertes");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem4);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Rparation");

        jMenuItem5.setText("Ajouter une rparation");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuItem6.setText("Etat des rparations dans une anne");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuItem7.setText("Alertes");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem7);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Carburant");

        jMenuItem8.setText("Ajouter une consommation");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem8);

        jMenuItem9.setText("Etat des consommations dans une anne");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem9);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Magasin");

        jMenuItem10.setText("Ajouter un article");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem10);

        jMenuItem11.setText("Etat des consommations dans une anne");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem11);

        jMenuItem12.setText("Alertes");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem12);

        jMenuBar1.add(jMenu4);

        jMenu5.setText("Atelier");

        jMenuItem13.setText("Ajouter un bon de lavage");
        jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem13ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem13);

        jMenuItem14.setText("Demander un article");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem14ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem14);

        jMenuItem15.setText("Etat des consommations dans une anne");
        jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem15ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem15);

        jMenuBar1.add(jMenu5);

        jMenu6.setText("Parametrage");
        jMenuBar1.add(jMenu6);

        setJMenuBar(jMenuBar1);

        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(15, 15, 15).addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel3).addComponent(jLabel5))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(numSoucheET, javax.swing.GroupLayout.PREFERRED_SIZE, 63,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(DesginationArticleET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                63, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup().addComponent(immatriculationCB).addGap(18, 18, 18)
                                .addComponent(seachImmatET)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addGap(43, 43, 43)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel9).addComponent(jLabel8).addComponent(jLabel7))
                                        .addGap(18, 18, 18)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup()
                                                        .addGap(0, 0, Short.MAX_VALUE).addComponent(jLabel1)
                                                        .addGap(74, 74, 74).addComponent(jButton1))
                                                .addGroup(layout.createSequentialGroup().addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(layout.createSequentialGroup().addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.TRAILING,
                                                                        false)
                                                                .addComponent(dateReparationET,
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(utilisationSP,
                                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                                        0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(designationReparationET))
                                                                .addGap(50, 50, 50)
                                                                .addGroup(layout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(jLabel10)
                                                                        .addComponent(jLabel11)
                                                                        .addComponent(jLabel12)))
                                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                                layout.createSequentialGroup().addComponent(addBT)
                                                                        .addGap(23, 23, 23)))
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(jButton5)
                                                                .addGroup(layout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                                        false)
                                                                        .addComponent(indexET,
                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                70, Short.MAX_VALUE)
                                                                        .addComponent(montantET)
                                                                        .addComponent(immatriculationET)))
                                                        .addContainerGap())))
                                .addGroup(layout.createSequentialGroup().addGap(33, 33, 33)
                                        .addComponent(departementCB).addGap(18, 18, 18)
                                        .addComponent(searchDepartementET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                77, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dateCB).addGap(18, 18, 18)
                                        .addComponent(seachDateET, javax.swing.GroupLayout.PREFERRED_SIZE, 65,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(50, 50, 50).addComponent(seachBT).addGap(0, 0, Short.MAX_VALUE))))
                .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 899,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(printBT))
                                .addGroup(
                                        layout.createSequentialGroup().addGap(258, 258, 258).addComponent(jLabel2)))
                        .addGap(0, 40, Short.MAX_VALUE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGap(225, 225, 225).addComponent(jLabel13)
                                .addContainerGap(638, Short.MAX_VALUE))));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jButton1).addComponent(jLabel1))
                        .addGap(34, 34, 34)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3)
                                .addComponent(numSoucheET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel7).addComponent(jLabel10)
                                .addComponent(immatriculationET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(dateReparationET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5)
                                .addComponent(DesginationArticleET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel8).addComponent(jLabel11)
                                .addComponent(utilisationSP, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(montantET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel9)
                                .addComponent(designationReparationET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel12).addComponent(indexET,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(addBT).addComponent(jButton5))
                        .addGap(5, 5, 5).addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(seachBT, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(immatriculationCB)
                                        .addComponent(seachImmatET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(departementCB)
                                        .addComponent(searchDepartementET, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(dateCB).addComponent(seachDateET,
                                                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)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(printBT)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGap(27, 27, 27).addComponent(jLabel13)
                                .addContainerGap(620, Short.MAX_VALUE))));

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

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

        new CarsAlerts().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem4ActionPerformed

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

        new Carburant().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem8ActionPerformed

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

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

        new ArticleAlerts().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem12ActionPerformed

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

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

        FixingDAO fixingDao = new FixingDAO();
        List<Fixing> fixings = new ArrayList<>();
        if (immatriculationCB.isSelected() && !departementCB.isSelected() && !dateCB.isSelected()) {
            fixings.addAll(fixingDao.findFixingsByImmatriculation(seachImmatET.getText()));
        } else if (!immatriculationCB.isSelected() && departementCB.isSelected() && !dateCB.isSelected()) {
            fixings.addAll(fixingDao.findFixingsByDepartement(searchDepartementET.getText()));
        } else if (!immatriculationCB.isSelected() && !departementCB.isSelected() && dateCB.isSelected()) {

            Date date = new Date();
            try {
                DateFormat format = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);

                date = format.parse(seachDateET.getText());

            } catch (ParseException ex) {
                Logger.getLogger(Cars.class.getName()).log(Level.SEVERE, null, ex);
            }

            fixings.addAll(fixingDao.findFixingsByDate(date));
        }

        /// add to the table
        Object[] tableColumnNames = new Object[8];
        tableColumnNames[0] = "Num de souche";
        tableColumnNames[1] = "Article";
        tableColumnNames[2] = "Date reparation";
        tableColumnNames[3] = "Utilisation";
        tableColumnNames[4] = "Designation de reparation";
        tableColumnNames[5] = "Immatriculation";
        tableColumnNames[6] = "Montant";
        tableColumnNames[7] = "Index";

        DefaultTableModel tbd = new DefaultTableModel();
        tbd.setColumnIdentifiers(tableColumnNames);
        Object[] RowService = new Object[8];
        this.tableJT.setModel(tbd);
        for (int i = 0; i < fixings.size(); i++) {
            RowService[0] = fixings.get(i).getSoucheNumber();
            RowService[1] = fixings.get(i).getArticle().getDesignation();
            RowService[2] = fixings.get(i).getFixingDate().toString();
            RowService[3] = fixings.get(i).getUtilisation();
            RowService[4] = fixings.get(i).getDesignationD();
            RowService[5] = fixings.get(i).getCar().getImmatriculation();
            RowService[6] = fixings.get(i).getPrice();
            RowService[7] = fixings.get(i).getIndexKM();

            tbd.addRow(RowService);

        }

    }//GEN-LAST:event_seachBTActionPerformed

    private void printBTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printBTActionPerformed
        try {
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream("/home/marwen/Desktop/carburantList.pdf"));
            document.open();
            addMetaData(document);
            addTitlePage(document);
            //addContent(document);
            document.close();
        } catch (Exception e) {
            e.printStackTrace();
        } // TODO add your handling code here:

    }

    // iText allows to add metadata to the PDF which can be viewed in your Adobe
    // Reader
    // under File -> Properties
    private static void addMetaData(Document document) {
        document.addTitle("Fixing PDF");
        document.addSubject("subject");
        document.addKeywords("Car Fleet Management, PDF, JAVA");
        document.addAuthor("Marwen");
        document.addCreator("Marwen");
    }

    private void addTitlePage(Document document) throws DocumentException {
        Paragraph preface = new Paragraph();
        // We add one empty line
        addEmptyLine(preface, 1);
        // Lets write a big header
        preface.add(new Paragraph("Fixing", catFont));

        addEmptyLine(preface, 1);

        preface.add(new Paragraph(
                "Report generated by: " + System.getProperty("Car Fleet Management App") + ", " + new Date(),
                smallBold));
        addEmptyLine(preface, 3);

        preface.add(new Paragraph("Fixing details ", smallBold));

        int rowNumber = this.tableJT.getSelectedRow();

        // immatriculation
        preface.add(new Paragraph("Numero de souche : ", redFont));
        preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 0).toString(), smallBold));

        //marque
        preface.add(new Paragraph("Fournisseur : ", redFont));
        preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 1).toString(), smallBold));

        //etat
        preface.add(new Paragraph("Immatriculation : ", redFont));
        preface.add(new Paragraph(this.tableJT.getValueAt(rowNumber, 3).toString(), smallBold));

        addEmptyLine(preface, 3);
        preface.add(new Paragraph("Thank you for using Car Fleet Management App", smallBold));

        document.add(preface);
        // Start a new page
        document.newPage();
    }

    private static void addEmptyLine(Paragraph paragraph, int number) {
        for (int i = 0; i < number; i++) {
            paragraph.add(new Paragraph(" "));
        }
    }//GEN-LAST:event_printBTActionPerformed

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

        Fixing fixing = new Fixing();

        fixing.setSoucheNumber(numSoucheET.getText());

        // get Article
        Article article = new Article();

        try {
            // open new session
            ArticleDAO articleDAO = new ArticleDAO();
            article = articleDAO.findArticleByDesignation(DesginationArticleET.getText()).get(0);

        } catch (IndexOutOfBoundsException e) {
            // open new session
            ArticleDAO articleDAO = new ArticleDAO();
            article.setDesignation(DesginationArticleET.getText());
            articleDAO.addOrMergeArticle(article);
            // open new session
            articleDAO = new ArticleDAO();
            article = articleDAO.findArticleByDesignation(DesginationArticleET.getText()).get(0);

        }

        fixing.setArticle(article);

        try {
            DateFormat format = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
            Date date;
            date = format.parse(dateReparationET.getText());
            fixing.setDateDemande(date);
            fixing.setFixingDate(date);

        } catch (ParseException ex) {
            Logger.getLogger(Cars.class.getName()).log(Level.SEVERE, null, ex);
        }

        fixing.setUtilisation(utilisationSP.getSelectedItem().toString());
        fixing.setDesignationD(designationReparationET.getText());

        // get Car
        Car car = new Car();

        CarDAO carDAO = new CarDAO();
        if (carDAO.getCarByImmatriculation(immatriculationET.getText()) != null) {
            // open new session
            carDAO = new CarDAO();
            car = carDAO.getCarByImmatriculation(immatriculationET.getText());
        } else {
            // open new session
            carDAO = new CarDAO();
            car.setImmatriculation(immatriculationET.getText());
            carDAO.addCar(car);
            // open new session
            carDAO = new CarDAO();
            car = carDAO.getCarByImmatriculation(immatriculationET.getText());

        }

        fixing.setCar(car);

        fixing.setPrice(Float.parseFloat(montantET.getText()));
        fixing.setIndexKM(Integer.parseInt(indexET.getText()));

        FixingDAO fixingDao = new FixingDAO();
        fixingDao.addOrUpdateFixing(fixing);

    }//GEN-LAST:event_addBTActionPerformed

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

        new Fixings().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem2ActionPerformed

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

        new CarsStats().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem3ActionPerformed

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

        new Fixings().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem5ActionPerformed

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

        new FixingStats().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem6ActionPerformed

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

        new FixingsAlerts().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem7ActionPerformed

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

        new CarburantStats().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem9ActionPerformed

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

        new Articles().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem10ActionPerformed

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

        new BonLavage().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem13ActionPerformed

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

        new DemandesArticles().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jMenuItem14ActionPerformed

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

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

        ConnectedUser.setCurrentConnectedUser(null);
        new Login().setVisible(true);
        this.setVisible(false);

    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @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(Fixings.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Fixings.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Fixings.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Fixings.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        //</editor-fold>
        //</editor-fold>

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField DesginationArticleET;
    private javax.swing.JButton addBT;
    private javax.swing.JCheckBox dateCB;
    private javax.swing.JTextField dateReparationET;
    private javax.swing.JCheckBox departementCB;
    private javax.swing.JTextField designationReparationET;
    private javax.swing.JCheckBox immatriculationCB;
    private javax.swing.JTextField immatriculationET;
    private javax.swing.JTextField indexET;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField montantET;
    private javax.swing.JTextField numSoucheET;
    private javax.swing.JButton printBT;
    private javax.swing.JButton seachBT;
    private javax.swing.JTextField seachDateET;
    private javax.swing.JTextField seachImmatET;
    private javax.swing.JTextField searchDepartementET;
    private javax.swing.JTable tableJT;
    private javax.swing.JComboBox utilisationSP;
    // End of variables declaration//GEN-END:variables
}