/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ package presentation; import Metier.Medicament; import acces_aux_donnes.MedicamentSQL; import acces_aux_donnes.familleMedocSQL; import java.util.ArrayList; import java.util.Vector; import javax.swing.DefaultComboBoxModel; import javax.swing.JOptionPane; /** * * @author emile.lalorcey */ public class jffFamilleMedoc extends javax.swing.JFrame { int metier; /** * Creates new form jffFamilleMedoc */ public jffFamilleMedoc(int metier) { this.metier = metier; initComponents(); familleMedocSQL famille = new familleMedocSQL(); jCBFamille.setModel(new DefaultComboBoxModel(famille.rechercheFamille())); } /** * 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() { jLabel1 = new javax.swing.JLabel(); jLRecherche = new javax.swing.JLabel(); jTFRecherche = new javax.swing.JTextField(); jBRechercheValide = new javax.swing.JButton(); jCBFamille = new javax.swing.JComboBox<>(); jCBMedocListe = new javax.swing.JComboBox<>(); jMenuBar1 = new javax.swing.JMenuBar(); jMPage = new javax.swing.JMenu(); jMIProfession = new javax.swing.JMenuItem(); jMIFamille = new javax.swing.JMenuItem(); jMInfo = new javax.swing.JMenu(); jMIguide = new javax.swing.JMenuItem(); jMcredit = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/logodetoure.gif"))); // NOI18N jLRecherche.setText("Recherche m�dicament : "); jTFRecherche.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTFRechercheActionPerformed(evt); } }); jBRechercheValide.setText("Rechercher"); jBRechercheValide.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBRechercheValideActionPerformed(evt); } }); jCBFamille.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jCBFamille.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCBFamilleActionPerformed(evt); } }); jCBMedocListe.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jCBMedocListe.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCBMedocListeActionPerformed(evt); } }); jMPage.setText("Page"); jMIProfession.setText("Choix M�tier"); jMIProfession.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMIProfessionActionPerformed(evt); } }); jMPage.add(jMIProfession); jMIFamille.setText("Famille Medicament"); jMIFamille.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMIFamilleActionPerformed(evt); } }); jMPage.add(jMIFamille); jMenuBar1.add(jMPage); jMInfo.setText("Info"); jMIguide.setText("Guide"); jMIguide.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMIguideActionPerformed(evt); } }); jMInfo.add(jMIguide); jMcredit.setText("Cr�dit"); jMInfo.add(jMcredit); jMenuBar1.add(jMInfo); 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() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLRecherche) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jTFRecherche, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(58, 58, 58)) .addGroup(layout.createSequentialGroup() .addComponent(jCBFamille, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(42, 42, 42))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jBRechercheValide) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(jCBMedocListe, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(31, 31, 31)))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLRecherche) .addComponent(jTFRecherche, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jBRechercheValide)) .addGap(29, 29, 29) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jCBFamille, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jCBMedocListe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(264, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jTFRechercheActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFRechercheActionPerformed }//GEN-LAST:event_jTFRechercheActionPerformed private void jBRechercheValideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBRechercheValideActionPerformed String medocRechercher = jTFRecherche.getText(); System.out.println(medocRechercher); MedicamentSQL medocTest = new MedicamentSQL(); ArrayList<String> rechercheMedoc = new ArrayList<String>(); rechercheMedoc = medocTest.rechercherMedicament(medocRechercher); if (rechercheMedoc.get(0) != null) { String idTrouve = rechercheMedoc.get(0); String nomTrouve = rechercheMedoc.get(1); String compositionTrouve = rechercheMedoc.get(2); String effetTrouve = rechercheMedoc.get(3); String contreIndicationTrouve = rechercheMedoc.get(4); String imgTrouve = idTrouve; Medicament medocTrouve = new Medicament(idTrouve, nomTrouve , compositionTrouve, effetTrouve, contreIndicationTrouve,imgTrouve); new jffInfoMedoc(medocTrouve, this.metier).setVisible(true); }else { JOptionPane.showMessageDialog(null,"Veuillez choisir un m�dicament valide"); } }//GEN-LAST:event_jBRechercheValideActionPerformed private void jCBFamilleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBFamilleActionPerformed familleMedocSQL famille = new familleMedocSQL(); Vector<String> medocFamille = new Vector<String>(); String libelleFamille = jCBFamille.getSelectedItem().toString(); String codeFamille = famille.rechercheCodeFamille(libelleFamille); medocFamille = famille.rechercherMedocFamille(codeFamille); jCBMedocListe.setModel(new DefaultComboBoxModel(medocFamille)); }//GEN-LAST:event_jCBFamilleActionPerformed private void jCBMedocListeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBMedocListeActionPerformed String nomMedoc = jCBMedocListe.getSelectedItem().toString(); System.out.println(nomMedoc); MedicamentSQL medocTest = new MedicamentSQL(); ArrayList<String> rechercheMedoc = new ArrayList<String>(); rechercheMedoc = medocTest.rechercherMedicament(nomMedoc); System.out.print("TEst"); if (rechercheMedoc.get(0) != null) { String idTrouve = rechercheMedoc.get(0); String nomTrouve = rechercheMedoc.get(1); String compositionTrouve = rechercheMedoc.get(2); String effetTrouve = rechercheMedoc.get(3); String contreIndicationTrouve = rechercheMedoc.get(4); String imgTrouve = idTrouve; Medicament medocTrouve = new Medicament(idTrouve, nomTrouve , compositionTrouve, effetTrouve, contreIndicationTrouve,imgTrouve); new jffInfoMedoc(medocTrouve, this.metier).setVisible(true); } }//GEN-LAST:event_jCBMedocListeActionPerformed private void jMIProfessionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIProfessionActionPerformed new jffProfession().setVisible(true); this.setVisible(false); }//GEN-LAST:event_jMIProfessionActionPerformed private void jMIguideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIguideActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMIguideActionPerformed private void jMIFamilleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIFamilleActionPerformed new jffFamilleMedoc(this.metier).setVisible(true); this.setVisible(false); }//GEN-LAST:event_jMIFamilleActionPerformed /** * @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(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(jffFamilleMedoc.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBRechercheValide; private javax.swing.JComboBox<String> jCBFamille; private javax.swing.JComboBox<String> jCBMedocListe; private javax.swing.JLabel jLRecherche; private javax.swing.JLabel jLabel1; private javax.swing.JMenuItem jMIFamille; private javax.swing.JMenuItem jMIProfession; private javax.swing.JMenuItem jMIguide; private javax.swing.JMenu jMInfo; private javax.swing.JMenu jMPage; private javax.swing.JMenuItem jMcredit; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JTextField jTFRecherche; // End of variables declaration//GEN-END:variables }