Java tutorial
package Info_perso; import Gestion.*; import com.itextpdf.text.Element; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import static java.lang.System.exit; import java.sql.Blob; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; /* * 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. */ /** * * @author ouissam */ public class Modif_Enseignant extends javax.swing.JFrame { BD db; ResultSet Res; String DOTI, CIN, NOM, PRENOM, NOMAR, PRENOMAR, DATE, LIEU, SITU, NBR, ADR, EMAIL, ENTREE, RECRU, TEL; String filename; String num; String N_some; String format = "yyyy-MM-dd"; java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat(format); public Modif_Enseignant(String num) throws SQLException { initComponents(); this.num = num; db = new BD(Parametre.Host, Parametre.username, Parametre.password, Parametre.IPHOST, Parametre.Port); Res = db.querySelectAll("Enseignant", "N_somme='" + num + "'"); while (Res.next()) { N_some = Res.getString("N_somme"); n.setText(Res.getString("N_somme")); cin.setText("" + Res.getString("CIN")); nom.setText("" + Res.getString("nom")); prenom.setText("" + Res.getString("prenom")); lieu.setText("" + Res.getString("Lieu_Naissance")); date.setDate(Res.getDate("Date_naissance")); situ.setText("" + Res.getString("situation_familiale")); nbr.setText("" + Res.getString("nb_enfants")); nomar.setText("" + Res.getString("nom_Ar")); prenomar.setText("" + Res.getString("prenom_Ar")); adr.setText("" + Res.getString("adresse")); tel.setText("" + Res.getString("N_telephone")); entree.setDate(Res.getDate("date_d_entree")); recru.setDate(Res.getDate("date_recrutement")); email.setText("" + Res.getString("ad_electronique")); Blob b = Res.getBlob("image"); if (b != null) { byte barr[] = b.getBytes(1, (int) b.length()); java.awt.Image image = getToolkit().createImage(barr); ImageIcon i = new ImageIcon(image); ImageIcon icon = new ImageIcon(i.getImage().getScaledInstance(112, 118, 0)); img.setIcon(icon); } parcourir.enable(false); cin.setEnabled(false); nom.setEnabled(false); prenom.setEnabled(false); n.setEnabled(false); nomar.setEnabled(false); prenomar.setEnabled(false); situ.setEnabled(false); lieu.setEnabled(false); adr.setEnabled(false); email.setEnabled(false); tel.setEnabled(false); nbr.setEnabled(false); date.setEnabled(false); date.getDateEditor().setEnabled(false); entree.setEnabled(false); entree.getDateEditor().setEnabled(false); recru.setEnabled(false); recru.getDateEditor().setEnabled(false); valider.setEnabled(false); nomar.setHorizontalAlignment(Element.ALIGN_LEFT); prenomar.setHorizontalAlignment(Element.ALIGN_LEFT); } } /** * 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() { cin = new javax.swing.JTextField(); jLabel15 = new javax.swing.JLabel(); img = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); prenomar = new javax.swing.JTextField(); nomar = new javax.swing.JTextField(); jLabel16 = new javax.swing.JLabel(); parcourir = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); nbr = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); tel = new javax.swing.JTextField(); jLabel7 = new javax.swing.JLabel(); nom = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); prenom = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); email = new javax.swing.JTextField(); jLabel12 = new javax.swing.JLabel(); lieu = new javax.swing.JTextField(); adr = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); n = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); situ = new javax.swing.JTextField(); modifier = new org.edisoncor.gui.button.ButtonAction(); valider = new org.edisoncor.gui.button.ButtonAction(); annuler = new org.edisoncor.gui.button.ButtonAction(); date = new com.toedter.calendar.JDateChooser(); entree = new com.toedter.calendar.JDateChooser(); recru = new com.toedter.calendar.JDateChooser(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); cin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cinActionPerformed(evt); } }); jLabel15.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel15.setText("CIN :"); img.setText(" Photo"); img.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); img.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jLabel17.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel17.setText(" :"); prenomar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { prenomarActionPerformed(evt); } }); jLabel16.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel16.setText(" :"); parcourir.setBackground(new java.awt.Color(1, 168, 158)); parcourir.setText("Parcourir "); parcourir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { parcourirActionPerformed(evt); } }); jLabel6.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel6.setText("Situation familiale :"); nbr.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { nbrActionPerformed(evt); } }); jLabel1.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel1.setText("GSM :"); jLabel7.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel7.setText("Nombre d'enfants :"); jLabel4.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel4.setText("Nom :"); jLabel5.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel5.setText("Prenom :"); prenom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { prenomActionPerformed(evt); } }); jLabel8.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel8.setText("Date :"); jLabel9.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel9.setText("Lieu de naissance :"); jLabel10.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel10.setText("Adresse :"); jLabel11.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel11.setText("E-mail :"); jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Ressource/back.png"))); // NOI18N jLabel14.setText("jLabel14"); jLabel14.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); jLabel14.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel14MouseClicked(evt); } }); jLabel12.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel12.setText("Date de recrutement :"); lieu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lieuActionPerformed(evt); } }); jLabel3.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel3.setText("DOTI:"); jLabel2.setFont(new java.awt.Font("Ubuntu", 3, 28)); // NOI18N jLabel2.setForeground(new java.awt.Color(213, 99, 99)); jLabel2.setText("Modification d'Informations Personnelles"); n.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { nActionPerformed(evt); } }); jLabel13.setFont(new java.awt.Font("Serif", 3, 15)); // NOI18N jLabel13.setText("Date d'entre :"); situ.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { situActionPerformed(evt); } }); modifier.setText("Modifier"); modifier.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { modifierActionPerformed(evt); } }); valider.setText("Valider"); valider.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { validerActionPerformed(evt); } }); annuler.setText("Annuler"); annuler.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { annulerActionPerformed(evt); } }); 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(85, 85, 85) .addComponent(modifier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(159, 159, 159) .addComponent(valider, 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(annuler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel15)) .addComponent(jLabel1)) .addGap(41, 41, 41)) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(81, 81, 81) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(n, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cin, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout .createSequentialGroup() .addGap(2, 2, 2) .addComponent(tel, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))))))) .addGap(95, 95, 95) .addComponent(img, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(112, 112, 112) .addComponent(parcourir, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(82, 82, 82)) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(124, 124, 124).addComponent( jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 559, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel8).addComponent(jLabel6).addComponent(jLabel5) .addComponent(jLabel4).addComponent(jLabel10).addComponent(jLabel11) .addComponent(jLabel13)).addGap(23, 23, 23) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(adr, javax.swing.GroupLayout.PREFERRED_SIZE, 477, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(entree, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(41, 41, 41).addComponent(jLabel12) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(recru, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(situ, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(119, 119, 119)) .addGroup(layout.createSequentialGroup() .addComponent(date, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(69, 69, 69))) .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel9) .addComponent(jLabel7)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(nbr, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lieu, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(prenom, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(prenomar, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(nom, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(nomar, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(38, 38, 38))))) .addGap(0, 4, Short.MAX_VALUE))))) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(n, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup().addComponent(jLabel3) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel15) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel1)))) .addComponent(img, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(parcourir, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(51, 51, 51))) .addComponent(jLabel2) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(37, 37, 37).addComponent(jLabel4) .addGap(18, 18, 18).addComponent(jLabel5).addGap(28, 28, 28)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(nom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(nomar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(prenom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(prenomar, 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.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lieu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9)) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(date, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(nbr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(situ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(adr, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(19, 19, 19) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(entree, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(recru, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(email, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(43, 43, 43) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(modifier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(annuler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(31, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(valider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())))); pack(); }// </editor-fold>//GEN-END:initComponents private void cinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cinActionPerformed // TODO add your handling code here: }//GEN-LAST:event_cinActionPerformed private void prenomarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prenomarActionPerformed // TODO add your handling code here: }//GEN-LAST:event_prenomarActionPerformed private void parcourirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parcourirActionPerformed JFileChooser chooser = new JFileChooser();//cration dun nouveau filechosser chooser.setApproveButtonText("Choix du fichier..."); //intitul du bouton if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { filename = chooser.getSelectedFile().getAbsolutePath().toString(); ImageIcon icon = new ImageIcon(filename); ImageIcon i = new ImageIcon(icon.getImage().getScaledInstance(112, 118, 0)); img.setIcon(i); //img.setIcon(new javax.swing.ImageIcon(getClass().getResource("/home/ouissam/Bureau/logoFso.jpg"))); //chooser.getSelectedFile().getAbsolutePath().toString()) } }//GEN-LAST:event_parcourirActionPerformed private void nbrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nbrActionPerformed // TODO add your handling code here: }//GEN-LAST:event_nbrActionPerformed private void prenomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prenomActionPerformed // TODO add your handling code here: }//GEN-LAST:event_prenomActionPerformed private void jLabel14MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel14MouseClicked Principale x = new Principale(); x.setLocationRelativeTo(x.getGlassPane()); x.setResizable(false); x.show(); this.dispose(); }//GEN-LAST:event_jLabel14MouseClicked private void lieuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lieuActionPerformed // TODO add your handling code here: }//GEN-LAST:event_lieuActionPerformed private void nActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nActionPerformed // TODO add your handling code here: }//GEN-LAST:event_nActionPerformed private void situActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_situActionPerformed // TODO add your handling code here: }//GEN-LAST:event_situActionPerformed private void modifierActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modifierActionPerformed n.setEnabled(true); parcourir.setEnabled(true); cin.setEnabled(true); nom.setEnabled(true); prenom.setEnabled(true); nomar.setEnabled(true); prenomar.setEnabled(true); situ.setEnabled(true); lieu.setEnabled(true); adr.setEnabled(true); email.setEnabled(true); tel.setEnabled(true); nbr.setEnabled(true); valider.setEnabled(true); date.setEnabled(true); date.getDateEditor().setEnabled(false); entree.setEnabled(true); entree.getDateEditor().setEnabled(false); recru.setEnabled(true); recru.getDateEditor().setEnabled(false); }//GEN-LAST:event_modifierActionPerformed private void validerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_validerActionPerformed FileInputStream fin = null; boolean b = false; boolean t = false; if (JOptionPane.showConfirmDialog(null, "tes vous sr de vouloir modifier les informations ") == 0) { DOTI = n.getText(); CIN = cin.getText(); NOM = nom.getText(); PRENOM = prenom.getText(); NOMAR = nomar.getText(); PRENOMAR = prenomar.getText(); DATE = formater.format(date.getDate()); LIEU = lieu.getText(); SITU = situ.getText(); NBR = nbr.getText(); ADR = adr.getText(); EMAIL = email.getText(); ENTREE = formater.format(entree.getDate()); RECRU = formater.format(recru.getDate()); TEL = tel.getText(); if (CIN.equals("") || NOM.equals("") || PRENOM.equals("") || NOMAR.equals("") || PRENOMAR.equals("") || DATE.equals("") || LIEU.equals("") || SITU.equals("") || NBR.equals("") || ADR.equals("") || EMAIL.equals("") || ENTREE.equals("")) { JOptionPane.showMessageDialog(this, "vrifiez l'insertion de votre image ou des champs!!"); } else { if (!DOTI.equals(N_some)) { Res = db.querySelectAll("Enseignant", "N_somme='" + DOTI + "'"); try { while (Res.next()) { t = true; } } catch (SQLException ex) { Logger.getLogger(Modif_Enseignant.class.getName()).log(Level.SEVERE, null, ex); } if (t == false) { if (JOptionPane.showConfirmDialog(null, "tes vous sr de vouloir modifier le Numero de some ??") == 0) { b = true; } } } if (t == false) { Res = db.executionQuery("select count(*) from Enseignant"); try { while (Res.next()) { int s = Integer.parseInt(Res.getString("count(*)")); s++; Connection con = db.connexionDatabase(); if (filename == null) { if (img.getIcon() != null) { PreparedStatement pre = con.prepareStatement( "Update Enseignant set N_somme= ?,cin= ?,nom=?,prenom=?," + "prenom_Ar=?,nom_Ar=?," + "adresse=?,Date_naissance=?," + "Lieu_Naissance=?,ad_electronique=?,N_telephone=?," + "situation_familiale=?,nb_enfants=?," + "date_d_entree=?,date_recrutement=? " + "where N_somme = '" + num + "'"); if (b) { pre.setString(1, DOTI); } else { pre.setString(1, N_some); } pre.setString(2, CIN); pre.setString(3, NOM); pre.setString(4, PRENOM); pre.setString(5, PRENOMAR); pre.setString(6, NOMAR); pre.setString(7, ADR); pre.setString(8, DATE); pre.setString(9, LIEU); pre.setString(10, EMAIL); pre.setString(11, TEL); pre.setString(12, SITU); pre.setString(13, NBR); pre.setString(14, ENTREE); pre.setString(15, RECRU); pre.executeUpdate(); JOptionPane.showMessageDialog(this, "la Modification est effectue avec succs!!"); Principale x = new Principale(); x.setLocationRelativeTo(x.getGlassPane()); x.setResizable(false); x.show(); this.dispose(); } else { PreparedStatement pre = con.prepareStatement( "Update Enseignant set N_somme= ?,cin= ?,nom=?,prenom=?," + "prenom_Ar=?,nom_Ar=?," + "adresse=?,Date_naissance=?," + "Lieu_Naissance=?,ad_electronique=?,N_telephone=?," + "situation_familiale=?,nb_enfants=?," + "date_d_entree=?,date_recrutement=? " + "where N_somme = '" + num + "'"); if (b) { pre.setString(1, DOTI); } else { pre.setString(1, N_some); } pre.setString(2, CIN); pre.setString(3, NOM); pre.setString(4, PRENOM); pre.setString(5, PRENOMAR); pre.setString(6, NOMAR); pre.setString(7, ADR); pre.setString(8, DATE); pre.setString(9, LIEU); pre.setString(10, EMAIL); pre.setString(11, TEL); pre.setString(12, SITU); pre.setString(13, NBR); pre.setString(14, ENTREE); pre.setString(15, RECRU); pre.executeUpdate(); JOptionPane.showMessageDialog(this, "la Modification est effectue avec succs!!"); Principale x = new Principale(); x.setLocationRelativeTo(x.getGlassPane()); x.setResizable(false); x.show(); this.dispose(); } } else { //String unicode= "?useUnicode=yes&characterEncoding=UTF-8"; Connection con1 = db.connexionDatabase(); File imgfile = new File(filename); fin = new FileInputStream(imgfile); PreparedStatement pre = con1 .prepareStatement("Update Enseignant set N_somme=?,cin= ?,nom=?,prenom=?," + "prenom_Ar=?,nom_Ar=?," + "adresse=?,Date_naissance=?," + "Lieu_Naissance=?,ad_electronique=?,N_telephone=?," + "situation_familiale=?,nb_enfants=?," + "date_d_entree=?,date_recrutement=?,image=? " + "where N_somme = '" + num + "'"); if (b) { pre.setString(1, DOTI); } else { pre.setString(1, N_some); } pre.setString(2, CIN); pre.setString(3, NOM); pre.setString(4, PRENOM); pre.setString(5, PRENOMAR); pre.setString(6, NOMAR); pre.setString(7, ADR); pre.setString(8, DATE); pre.setString(9, LIEU); pre.setString(10, EMAIL); pre.setString(11, TEL); pre.setString(12, SITU); pre.setString(13, NBR); pre.setString(14, ENTREE); pre.setString(15, RECRU); pre.setBinaryStream(16, (InputStream) fin, (int) imgfile.length()); pre.executeUpdate(); JOptionPane.showMessageDialog(this, "la Modification est effectue avec succs!!"); Principale x = new Principale(); x.setLocationRelativeTo(x.getGlassPane()); x.setResizable(false); x.show(); this.dispose(); } } } catch (SQLException ex) { Logger.getLogger(Nv_Enseignant.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Modif_Enseignant.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(this, "Ce numro de some existe !!"); } } } }//GEN-LAST:event_validerActionPerformed private void annulerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_annulerActionPerformed EnseignantNum x = new EnseignantNum(); x.setLocationRelativeTo(x.getGlassPane()); x.setResizable(false); x.show(); this.dispose(); }//GEN-LAST:event_annulerActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField adr; private org.edisoncor.gui.button.ButtonAction annuler; private javax.swing.JTextField cin; private com.toedter.calendar.JDateChooser date; private javax.swing.JTextField email; private com.toedter.calendar.JDateChooser entree; private javax.swing.JLabel img; 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 jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JTextField lieu; private org.edisoncor.gui.button.ButtonAction modifier; private javax.swing.JTextField n; private javax.swing.JTextField nbr; private javax.swing.JTextField nom; private javax.swing.JTextField nomar; private javax.swing.JButton parcourir; private javax.swing.JTextField prenom; private javax.swing.JTextField prenomar; private com.toedter.calendar.JDateChooser recru; private javax.swing.JTextField situ; private javax.swing.JTextField tel; private org.edisoncor.gui.button.ButtonAction valider; // End of variables declaration//GEN-END:variables }