Menu

Facturier.java

FactOOor

/
* licence GPL V2
* Copyleft : Pinel Stéphane - Paris - France
* mail : stpinel@infonie.fr
* To change this template, choose Tools | Templates
* and open the template in the editor.
/
/
* Facturier.java

* Created on 16 mai 2011, 18:16:07
*/
package efs.ui;

import efs.SourceDonnees;
import efs.SourceDonnees.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.util.Locale;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/

* @author stefan
/
public class Facturier extends javax.swing.JFrame {

private int leChoix;
private Object con;
String requete = "";

/** Creates new form Facturier */
public Facturier() {
    initComponents();
    this.setBounds(150, 60, 795, 830);
    //this.setSize(835, 850);
    this.setTitle("FactOOor pour vous servir");
    this.setVisible(true);
}

public void inserdate() {
/ 2. Construction du DateFormat en choisiant un format :
* SHORT = 01/01/2002
* FULL = lundi 1 janvier 2002
*/
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault());
// 3. Affichage
//System.out.println(dateFormat.format(null));
String format = dateFormat.format(jLDate);
}
/
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.
*/
/// commance ici
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    jPaChoixDevis = new javax.swing.JPanel();
    choixSelection = new javax.swing.JComboBox();
    jPageBlanche = new javax.swing.JPanel();
    resultatSelection = new javax.swing.JLabel();
    resultatLabel = new javax.swing.JLabel();
    jLDate = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    choixCombox = new javax.swing.JPanel();
    jSeparator2 = new javax.swing.JSeparator();
    groupeArticle = new javax.swing.JComboBox();
    sousArticle = new javax.swing.JComboBox();
    list1 = new javax.swing.JList();
    jPaValPdf = new javax.swing.JPanel();
    valiserFacture = new javax.swing.JButton();
    apercuPDF = new javax.swing.JButton();
    jButFermer = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Facturier");
    setResizable(false);

    choixSelection.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Avoir", "Devis", "Facture,", "Bon de commande" }));
    choixSelection.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseEntered(java.awt.event.MouseEvent evt) {
            choixSelectionMouseEntered(evt);
        }
    });
    choixSelection.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            choixSelectionActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPaChoixDevisLayout = new javax.swing.GroupLayout(jPaChoixDevis);
    jPaChoixDevis.setLayout(jPaChoixDevisLayout);
    jPaChoixDevisLayout.setHorizontalGroup(
        jPaChoixDevisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPaChoixDevisLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(choixSelection, 0, 176, Short.MAX_VALUE)
            .addContainerGap())
    );
    jPaChoixDevisLayout.setVerticalGroup(
        jPaChoixDevisLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPaChoixDevisLayout.createSequentialGroup()
            .addContainerGap()
            .addComponent(choixSelection, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(30, Short.MAX_VALUE))
    );

    jPageBlanche.setBackground(new java.awt.Color(255, 255, 255));
    jPageBlanche.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
    jPageBlanche.setPreferredSize(new java.awt.Dimension(500, 700));

    resultatSelection.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    resultatSelection.setText("Facture");

    resultatLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    resultatLabel.setText("...");

    jLDate.setText("..");

    jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/efs/ui/logoEFSfacture.png"))); // NOI18N
    jLabel3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    jLabel3.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/efs/ui/logoEFSfacture.png"))); // NOI18N

    jLabel2.setText("N° :");

    jLabel4.setText("0542130");

    jPanel1.setBackground(new java.awt.Color(255, 255, 255));
    jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 206, Short.MAX_VALUE)
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 100, Short.MAX_VALUE)
    );

    javax.swing.GroupLayout jPageBlancheLayout = new javax.swing.GroupLayout(jPageBlanche);
    jPageBlanche.setLayout(jPageBlancheLayout);
    jPageBlancheLayout.setHorizontalGroup(
        jPageBlancheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPageBlancheLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPageBlancheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPageBlancheLayout.createSequentialGroup()
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 301, Short.MAX_VALUE)
                    .addComponent(jLDate, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPageBlancheLayout.createSequentialGroup()
                    .addComponent(resultatLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(38, 38, 38)
                    .addComponent(resultatSelection, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );
    jPageBlancheLayout.setVerticalGroup(
        jPageBlancheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPageBlancheLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPageBlancheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLDate))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE)
            .addGroup(jPageBlancheLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(resultatLabel)
                .addComponent(resultatSelection)
                .addComponent(jLabel4)
                .addComponent(jLabel2))
            .addGap(252, 252, 252)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(130, 130, 130))
    );

    jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel1.setText("FactOOoR, le facturier");

    org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, groupeArticle, org.jdesktop.beansbinding.ELProperty.create("${selectedItem}"), groupeArticle, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
    bindingGroup.addBinding(binding);

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

    sousArticle.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sous Articles 1", "Sous Articles 2", "Sous Articles 3" }));

    list1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list1, org.jdesktop.beansbinding.ELProperty.create("${selectedElement}"), list1, org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
    bindingGroup.addBinding(binding);

    list1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            list1ValueChanged(evt);
        }
    });

    javax.swing.GroupLayout choixComboxLayout = new javax.swing.GroupLayout(choixCombox);
    choixCombox.setLayout(choixComboxLayout);
    choixComboxLayout.setHorizontalGroup(
        choixComboxLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(choixComboxLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(choixComboxLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(sousArticle, 0, 176, Short.MAX_VALUE)
                .addComponent(groupeArticle, javax.swing.GroupLayout.Alignment.TRAILING, 0, 176, Short.MAX_VALUE)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(list1, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );
    choixComboxLayout.setVerticalGroup(
        choixComboxLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(choixComboxLayout.createSequentialGroup()
            .addGap(12, 12, 12)
            .addComponent(list1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(groupeArticle, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(18, 18, 18)
            .addComponent(sousArticle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );

    valiserFacture.setText("Valider");
    valiserFacture.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            valiserFactureActionPerformed(evt);
        }
    });

    apercuPDF.setBackground(new java.awt.Color(255, 0, 51));
    apercuPDF.setForeground(new java.awt.Color(255, 255, 255));
    apercuPDF.setText("Aperçu PDF");
    apercuPDF.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            apercuPDFActionPerformed(evt);
        }
    });

    jButFermer.setText("Fermer le facturier");
    jButFermer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButFermerActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPaValPdfLayout = new javax.swing.GroupLayout(jPaValPdf);
    jPaValPdf.setLayout(jPaValPdfLayout);
    jPaValPdfLayout.setHorizontalGroup(
        jPaValPdfLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPaValPdfLayout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPaValPdfLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(apercuPDF, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
                .addComponent(valiserFacture, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE)
                .addComponent(jButFermer, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap())
    );
    jPaValPdfLayout.setVerticalGroup(
        jPaValPdfLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPaValPdfLayout.createSequentialGroup()
            .addGap(35, 35, 35)
            .addComponent(valiserFacture)
            .addGap(18, 18, 18)
            .addComponent(apercuPDF)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
            .addComponent(jButFermer, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(32, 32, 32)
                    .addComponent(jPageBlanche, javax.swing.GroupLayout.PREFERRED_SIZE, 517, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPaValPdf, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(choixCombox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPaChoixDevis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(layout.createSequentialGroup()
                    .addGap(179, 179, 179)
                    .addComponent(jLabel1)))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(18, 18, 18)
                    .addComponent(jPaChoixDevis, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(choixCombox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(60, 60, 60)
                    .addComponent(jPaValPdf, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createSequentialGroup()
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jPageBlanche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap())
    );

    bindingGroup.bind();

    pack();
}// </editor-fold>

public static void affiche(String message) {
System.out.println(message);
}

public static void arret(String message) {
System.err.println(message);
System.exit(99);
}
private void groupeArticleActionPerformed(java.awt.event.ActionEvent evt) {
Connection conn = SourceDonnees.getConnection();
String requetega = "SELECT Nom FROM TFClient";
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(requetega) ;
groupeArticle.removeAllItems();
while(rs.next()) {
groupeArticle.addItem(rs.getString("Nom"));
}
rs.close();
} catch (Exception e) {
System.out.println("Erreur:Anomalie lors de l'execution de la requête : "+e);
}
}

private void valiserFactureActionPerformed(java.awt.event.ActionEvent evt) {

}

private void apercuPDFActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
}

private void choixSelectionActionPerformed(java.awt.event.ActionEvent evt) {                                               
    leChoix = choixSelection.getSelectedIndex();
    // System.out.println(leChoix);
    switch (leChoix) {
        case 0:
            resultatSelection.setText("Avoir");
            break;
        case 1:
            resultatSelection.setText("Devis");
            break;
        case 2:
            resultatSelection.setText("Facture");
            break;
        case 3:
            resultatSelection.setText("Bon de commande");
            break;
        default:
            System.exit(0);
    }
}                                              
private void choixSelectionMouseEntered(java.awt.event.MouseEvent evt) {                                            
    // TODO add your handling code here:
}

private void jButFermerActionPerformed(java.awt.event.ActionEvent evt) {                                           
    this.dispose();
}

private void list1ValueChanged(javax.swing.event.ListSelectionEvent evt) {                                   
//Connection conn = SourceDonnees.getConnection();
  //  String requete = "SELECT * FROM TFClient";

    list1.addListSelectionListener(new ListSelectionListener() {
                            public void valueChanged(ListSelectionEvent e) {
                                    if (!e.getValueIsAdjusting()) {

                                           // model.clear();

                                            String st = (String) list1.getSelectedValue();
                                            System.out.println(st);
                                            try {
                                                    Connection conn = SourceDonnees.getConnection();
                                                    String requete = "SELECT Nom FROM TFClient";
                                                    String tableNames = "";
                                                    Statement stmt = conn.createStatement();
                                                    ResultSet rs = stmt.executeQuery(requete) ;
                                                    list1.removeAll();
                                                    while (rs.next()) {
                                                            //tableNames = rs.getString("Nom");
                                                           // rs.addElement(rs.getString("Nom"));
                                                    }

                                            } catch (Exception ex) {
                                                System.out.println("Erreur:Anomalie lors de l'execution de la requête : "+e);
                                            }
                                    }
                            }
                    });

/ try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(requete) ;
list1.removeAll();
while(rs.next()) {
list1.addListSelectionListener(rs.getString("Nom"));
}
rs.close();
} catch (Exception ex) {
System.out.println("Ca marche pas !");
}
/
}

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            new Facturier().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton apercuPDF;
private javax.swing.JPanel choixCombox;
private javax.swing.JComboBox choixSelection;
private javax.swing.JComboBox groupeArticle;
private javax.swing.JButton jButFermer;
private javax.swing.JLabel jLDate;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPaChoixDevis;
private javax.swing.JPanel jPaValPdf;
private javax.swing.JPanel jPageBlanche;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JList list1;
private javax.swing.JLabel resultatLabel;
private javax.swing.JLabel resultatSelection;
private javax.swing.JComboBox sousArticle;
private javax.swing.JButton valiserFacture;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration

// dernier }

}


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.