Accueil > > > Gestion Stock/Gestion_Stock/src/gerer_application/recherche_categorie.java
GESTION STOCK
Gestion Stock/Gestion_Stock/src/gerer_application/recherche_categorie.java
Informations sur ce code source
Application swing de gestion de stock avec JDBC composée dinterface swing, la source de données est incluse dans le dossier. la fonction d'envoi de mail avec java mail ne marche pas. Améliorez et postez si ca vous tente !
Fichier : Gestion Stock/Gestion_Stock/src/gerer_application/recherche_categorie.java
Nombre de lignes : 135 lignes
Afficher ce fichier en plein écran
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /*
- * recherche_client.java
- *
- * Created on 19 juin 2011, 13:34:57
- */
- package gerer_application;
- import Operations.Operation;
- import java.sql.*;
- import javax.swing.JOptionPane;
- /**
- *
- * @author Ibrahima
- */
- public class recherche_categorie extends javax.swing.JFrame {
- /** Creates new form recherche_client */
- public recherche_categorie(String i) {
- super("Resultat de la recherche de : " + i);
- initComponents();
- Object[][] donnes = recherche_article(i);
- jTable1.setModel(new javax.swing.table.DefaultTableModel(
- donnes,
- new String[]{
- "ID Article", "Nom Article", "Categorie", "Quantite"
- }));
- }
- /** 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() {
- jScrollPane1 = new javax.swing.JScrollPane();
- jTable1 = new javax.swing.JTable();
- jButton1 = new javax.swing.JButton();
- setBounds(new java.awt.Rectangle(400, 100, 200, 200));
- setName("Form"); // NOI18N
- jScrollPane1.setName("jScrollPane1"); // NOI18N
- jTable1.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
- },
- new String [] {
- }
- ));
- jTable1.setName("jTable1"); // NOI18N
- jScrollPane1.setViewportView(jTable1);
- org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(gerer_application.Gerer_Application.class).getContext().getResourceMap(recherche_categorie.class);
- jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
- jButton1.setName("jButton1"); // NOI18N
- jButton1.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton1ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addContainerGap(413, Short.MAX_VALUE)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
- // TODO add your handling code here:
- this.setVisible(false);
- }//GEN-LAST:event_jButton1ActionPerformed
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTable jTable1;
- // End of variables declaration//GEN-END:variables
- public Object[][] recherche_article(String str) {
- Statement s;
- ResultSet rs;
- Operation op = new Operation();
- Connection con = op.conect();
- Object[][] donnes = new Object[100][4];
- try {
- s = con.createStatement();
- rs = s.executeQuery("select * from Article_Stock where Categorie LIKE '" + str + "%'");
- int i = 0;
- if (rs.next()) {
- while (rs.next()) {
- for (i = 0; i < donnes.length + 1; i++) {
- donnes[i][0] = rs.getInt(1);
- donnes[i][1] = rs.getString(2);
- donnes[i][2] = rs.getString(3);
- donnes[i][3] = rs.getString(4);
- rs.next();
- }
- }
- } else {
- donnes = null;
- }
- } catch (Exception e) {
- }
- return donnes;
- }
- }
|