Java tutorial
/* * 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 IHM; import Metier.AfficheFilm; import Metier.Article; import Metier.Film; import Metier.Mariage; import Metier.Photo; import Metier.Vip; import accesAuxDonnees.DAODivers; import accesAuxDonnees.DAOFilm; import accesAuxDonnees.DAOVIP; import accesAuxDonnees.SourceMySQL; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; import java.net.PasswordAuthentication; import java.sql.Connection; import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import static javax.swing.JOptionPane.INFORMATION_MESSAGE; import static javax.swing.JOptionPane.YES_NO_OPTION; import javax.swing.JTable; import modeleComboBox.ComboBoxModele; import modeleTable.ModeleJTable; import modeleTable.ModeleJTableFilm; import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPSClient; import sun.util.calendar.LocalGregorianCalendar.Date; /** * * @author poncho */ public class FenetrePrincipale extends javax.swing.JFrame { DAOVIP leDao; DAOFilm leDaoFilm; SourceMySQL source; DAODivers leDaoDivers; Vip vip; List<Mariage> listeMariage; // liste des mariages de la jcombobox des divorces List<Vip> listeVip; // liste des Vip pour la fonctions mariage ModeleJTable lemodele;//modele de table pour les vip ModeleJTableFilm lemodeleFilm; // modele de table pour les films private File f; // fichier pour l'upload de photos pour les articles private String nomPhoto; // nom de la photot de l'article upload private String nomF; // nom du fichier de l'article uploader public FenetrePrincipale(DAOVIP Dao, DAOFilm leDaoFilm, ModeleJTable modele, ModeleJTableFilm modeleFilm, DAODivers leDaoDivers) throws SQLException, Exception { vip = new Vip(); this.lemodele = modele; this.lemodeleFilm = modeleFilm; this.leDao = Dao; this.leDaoFilm = leDaoFilm; this.leDaoDivers = leDaoDivers; this.listeMariage = new ArrayList<>(); this.listeVip = new ArrayList<>(); initComponents(); } public Vip getVip() { return this.vip; } /** * 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() { jTabbedPane1 = new javax.swing.JTabbedPane(); jTabbedPane2 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); tableVip = new javax.swing.JTable(); btnAjouterVip = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); btnPhoto = new javax.swing.JButton(); jLabel27 = new javax.swing.JLabel(); jPanel4 = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); tableFilm = new javax.swing.JTable(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jLabel28 = new javax.swing.JLabel(); jPanel5 = new javax.swing.JPanel(); jComboBoxFilm = new javax.swing.JComboBox(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jComboBoxActeur = new javax.swing.JComboBox(); jLabel16 = new javax.swing.JLabel(); jLabel20 = new javax.swing.JLabel(); jComboBoxRealisateur = new javax.swing.JComboBox(); jButton6 = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); jSeparator2 = new javax.swing.JSeparator(); jLabel26 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jComboVip1 = new javax.swing.JComboBox(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jComboBoxVip2 = new javax.swing.JComboBox(); jLabel8 = new javax.swing.JLabel(); btnAjouterVip2 = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); txtAnnee = new javax.swing.JTextField(); txtLieux = new javax.swing.JTextField(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); txtMois = new javax.swing.JTextField(); txtJour = new javax.swing.JTextField(); jLabel15 = new javax.swing.JLabel(); jSeparator3 = new javax.swing.JSeparator(); jSeparator4 = new javax.swing.JSeparator(); jPanel2 = new javax.swing.JPanel(); comboBoxMariage = new javax.swing.JComboBox(); btnDivorcer = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); txtAnneeD = new javax.swing.JTextField(); jLabel18 = new javax.swing.JLabel(); txtMoisD = new javax.swing.JTextField(); jLabel19 = new javax.swing.JLabel(); txtJourD = new javax.swing.JTextField(); jLabel29 = new javax.swing.JLabel(); jSeparator5 = new javax.swing.JSeparator(); jPanel6 = new javax.swing.JPanel(); jLabel21 = new javax.swing.JLabel(); txtAuteur = new javax.swing.JTextField(); jLabel22 = new javax.swing.JLabel(); jLabel23 = new javax.swing.JLabel(); txtTitre = new javax.swing.JTextField(); jLabel24 = new javax.swing.JLabel(); txtDateArticle = new javax.swing.JTextField(); jLabel25 = new javax.swing.JLabel(); txtHeure = new javax.swing.JTextField(); jButton7 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jLabel30 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); txtContenu = new javax.swing.JTextArea(); jSeparator6 = new javax.swing.JSeparator(); jSeparator7 = new javax.swing.JSeparator(); btnPhotoArticle = new javax.swing.JButton(); txtNomPhotoA = new javax.swing.JTextField(); jLabel31 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); tableVip.setModel(lemodele); jScrollPane1.setViewportView(tableVip); btnAjouterVip.setText("ajouterVip"); btnAjouterVip.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAjouterVipActionPerformed(evt); } }); jButton2.setText("Modifier"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); btnPhoto.setText("Ajouter une photo"); btnPhoto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPhotoActionPerformed(evt); } }); jLabel27.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel27.setText("Liste des VIP"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(btnAjouterVip, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(115, 115, 115) .addComponent(btnPhoto)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE)) .addContainerGap()) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(215, 215, 215) .addComponent(jLabel27) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(34, 34, 34) .addComponent(jLabel27) .addGap(27, 27, 27) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnAjouterVip) .addComponent(jButton2) .addComponent(btnPhoto)) .addGap(21, 21, 21)) ); jTabbedPane2.addTab("VIP", jPanel1); tableFilm.setModel(lemodeleFilm); jScrollPane2.setViewportView(tableFilm); jButton3.setText("Ajouter un film "); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setText("modifier un film"); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton5.setText("Ajouter une affiche"); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jLabel28.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel28.setText("Liste des Films"); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() .addGap(43, 43, 43) .addComponent(jButton3) .addGap(81, 81, 81) .addComponent(jButton4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton5) .addGap(32, 32, 32)) .addGroup(jPanel4Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE) .addContainerGap()) .addGroup(jPanel4Layout.createSequentialGroup() .addGap(214, 214, 214) .addComponent(jLabel28) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel4Layout.setVerticalGroup( jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel4Layout.createSequentialGroup() .addComponent(jLabel28) .addGap(18, 18, 18) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE) .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton3) .addComponent(jButton4) .addComponent(jButton5)) .addGap(21, 21, 21)) ); jTabbedPane2.addTab("Film", jPanel4); try{ jComboBoxFilm.setModel(new ComboBoxModele(this.leDaoFilm.listeFilm())); } catch(Exception E) { } jLabel11.setText("Film :"); jLabel12.setText("Acteur:"); try{ jComboBoxActeur.setModel(new ComboBoxModele(this.leDao.getActeur())); } catch(Exception e) { } jLabel16.setText("Realisateur :"); jLabel20.setText("ou"); try{ jComboBoxRealisateur.setModel(new ComboBoxModele(this.leDao.getRealisateur())); } catch(Exception e) { } jButton6.setText("creer le casting"); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jLabel26.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel26.setText("Casting"); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel5Layout.createSequentialGroup() .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(60, 60, 60) .addComponent(jComboBoxFilm, javax.swing.GroupLayout.PREFERRED_SIZE, 358, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addComponent(jSeparator2)) .addContainerGap()) .addGroup(jPanel5Layout.createSequentialGroup() .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addGap(255, 255, 255) .addComponent(jLabel26)) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel12) .addGap(86, 86, 86) .addComponent(jComboBoxActeur, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(50, 50, 50) .addComponent(jLabel20) .addGap(18, 18, 18) .addComponent(jLabel16) .addGap(18, 18, 18) .addComponent(jComboBoxRealisateur, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(102, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(235, 235, 235)) ); jPanel5Layout.setVerticalGroup( jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel5Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel26) .addGap(33, 33, 33) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(jComboBoxFilm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(13, 13, 13) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(50, 50, 50) .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jComboBoxActeur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel20) .addComponent(jLabel16) .addComponent(jComboBoxRealisateur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel12)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 125, Short.MAX_VALUE) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(87, 87, 87) .addComponent(jButton6) .addGap(103, 103, 103)) ); jTabbedPane2.addTab("Casting", jPanel5); jLabel2.setText("Liste des clibataires :"); jComboVip1.setModel(new ComboBoxModele(this.leDao.getCelibataire(this.listeVip)) ); jLabel4.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel4.setText("Mariage"); jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N jLabel5.setText("VIP 1 :"); jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N jLabel6.setText("VIP 2 :"); jLabel7.setText("Liste des clibataires :"); jComboBoxVip2.setModel(new ComboBoxModele(this.leDao.getCelibataire(this.listeVip)) ); jLabel8.setText("ou :"); btnAjouterVip2.setText("AjouterVip"); btnAjouterVip2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAjouterVip2ActionPerformed(evt); } }); jButton1.setText("Marier les Vip"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jLabel9.setText("Date du mariage :"); jLabel10.setText("lieux du mariage :"); jLabel13.setText("aaaa"); jLabel14.setText("mm "); txtMois.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtMoisActionPerformed(evt); } }); jLabel15.setText("jj"); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(jLabel5)) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(29, 29, 29) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jComboVip1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel6) .addGroup(jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9) .addComponent(jLabel10) .addComponent(jLabel7)) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(4, 4, 4) .addComponent(jComboBoxVip2, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39) .addComponent(jLabel8)) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(25, 25, 25) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup() .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jLabel13) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(txtAnnee, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel14) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtMois, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addComponent(jLabel15)) .addComponent(txtLieux, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(1, 1, 1) .addComponent(txtJour, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(38, 38, 38) .addComponent(btnAjouterVip2)))))) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(227, 227, 227) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(122, Short.MAX_VALUE)) .addComponent(jSeparator3) .addComponent(jSeparator4) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel4) .addGap(27, 27, 27) .addComponent(jLabel5) .addGap(18, 18, 18) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jComboVip1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) .addComponent(jLabel6) .addGap(26, 26, 26) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel8) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(jComboBoxVip2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel3Layout.createSequentialGroup() .addGap(1, 1, 1) .addComponent(btnAjouterVip2))) .addGap(52, 52, 52) .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(txtAnnee, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13) .addComponent(jLabel14) .addComponent(txtMois, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtJour, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15)) .addGap(41, 41, 41) .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel10) .addComponent(txtLieux, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 100, Short.MAX_VALUE) .addComponent(jButton1) .addGap(35, 35, 35)) ); jTabbedPane2.addTab("Mariage", jPanel3); comboBoxMariage.setModel(new ComboBoxModele(this.leDao.vipMari(this.listeMariage))); btnDivorcer.setText("Divorcer les deux Vip"); btnDivorcer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDivorcerActionPerformed(evt); } }); jLabel3.setText("Liste des mariages"); jLabel1.setText("Date du divorce :"); jLabel17.setText("aaaa"); jLabel18.setText("mm "); txtMoisD.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtMoisDActionPerformed(evt); } }); jLabel19.setText("jj"); jLabel29.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel29.setText("Divorce"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(252, 252, 252) .addComponent(jLabel29)) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(comboBoxMariage, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnDivorcer, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel1) .addGap(30, 30, 30) .addComponent(jLabel17) .addGap(18, 18, 18) .addComponent(txtAnneeD, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel18) .addGap(18, 18, 18) .addComponent(txtMoisD, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(1, 1, 1) .addComponent(txtJourD, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGap(0, 73, Short.MAX_VALUE)) .addComponent(jSeparator5) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel29) .addGap(79, 79, 79) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(comboBoxMariage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 116, Short.MAX_VALUE) .addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jLabel17) .addComponent(txtAnneeD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel18) .addComponent(txtMoisD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtJourD, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel19)) .addGap(63, 63, 63) .addComponent(btnDivorcer) .addGap(135, 135, 135)) ); //jComboBox1.setModel(new ComboBoxModele(this.leDao.vipMari())); jTabbedPane2.addTab("Divorce", jPanel2); jLabel21.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N jLabel21.setText("Contenu :"); jLabel22.setText("Auteur :"); jLabel23.setText("titre :"); jLabel24.setText("Date :"); jLabel25.setText("Heure :"); jButton7.setText("Gnrer l'article"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jButton8.setText("Gnerer date et heure du jour"); jButton8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton8ActionPerformed(evt); } }); jLabel30.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N jLabel30.setText("Article"); txtContenu.setColumns(20); txtContenu.setRows(5); jScrollPane3.setViewportView(txtContenu); btnPhotoArticle.setText("Choisir un photo"); btnPhotoArticle.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPhotoArticleActionPerformed(evt); } }); txtNomPhotoA.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtNomPhotoAActionPerformed(evt); } }); jLabel31.setText("Nom de la photo :"); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jSeparator6) .addComponent(jSeparator7) .addGroup(jPanel6Layout.createSequentialGroup() .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane3) .addGroup(jPanel6Layout.createSequentialGroup() .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addGap(224, 224, 224) .addComponent(jButton7)) .addGroup(jPanel6Layout.createSequentialGroup() .addGap(242, 242, 242) .addComponent(jLabel30)) .addGroup(jPanel6Layout.createSequentialGroup() .addGap(252, 252, 252) .addComponent(jLabel21)) .addGroup(jPanel6Layout.createSequentialGroup() .addGap(46, 46, 46) .addComponent(btnPhotoArticle) .addGap(59, 59, 59) .addComponent(jLabel31) .addGap(18, 18, 18) .addComponent(txtNomPhotoA, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(0, 94, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addGap(16, 16, 16) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(jLabel23) .addGap(18, 18, 18) .addComponent(txtTitre, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel6Layout.createSequentialGroup() .addComponent(jLabel22) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(txtAuteur, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel6Layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jButton8)) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addComponent(jLabel24) .addGap(18, 18, 18) .addComponent(txtDateArticle, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addComponent(jLabel25) .addGap(18, 18, 18) .addComponent(txtHeure, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(54, 54, 54))) .addContainerGap()) ); jPanel6Layout.setVerticalGroup( jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel30) .addGap(5, 5, 5) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtTitre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel23) .addComponent(txtDateArticle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel24)) .addGap(18, 18, 18) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtAuteur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel22) .addComponent(txtHeure, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel25)) .addGap(11, 11, 11) .addComponent(jButton8) .addGap(18, 18, 18) .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(32, 32, 32) .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnPhotoArticle) .addComponent(jLabel31) .addComponent(txtNomPhotoA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(11, 11, 11) .addComponent(jLabel21) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jButton7) .addContainerGap()) ); jTabbedPane2.addTab("Article", jPanel6); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 593, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 22, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jTabbedPane2) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void txtMoisDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMoisDActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtMoisDActionPerformed private void btnDivorcerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDivorcerActionPerformed if (!(txtAnneeD.getText().equals("")) && !(comboBoxMariage.getSelectedIndex() == -1) &&!(txtMoisD.getText().equals("")) &&!(txtJourD.getText().equals("")) ) { try { int index = comboBoxMariage.getSelectedIndex(); String dateD = txtAnneeD.getText() +"-"+txtMoisD.getText()+"-"+txtJourD.getText() ; // rcupration de la date et mise au format mySQL this.leDao.divorcerVip(this.listeMariage.get(comboBoxMariage.getSelectedIndex()),dateD); // on divorce les vips du mariage slection dans la comboBox this.listeMariage.remove(index); // on retire le mariage "divorc" this.comboBoxMariage.setModel(new ComboBoxModele(this.leDao.vipMari(this.listeMariage))); // on rinitialise les combobox des vip clibataire et mariage pour les mettres a jour this.jComboBoxVip2.setModel(new ComboBoxModele(leDao.getCelibataire(listeVip))); this.jComboVip1.setModel((new ComboBoxModele(leDao.getCelibataire(listeVip)))); txtMoisD.setText(""); txtAnneeD.setText(""); // on rinitialise les diffrents champs txtJourD.setText(""); } catch (SQLException ex) { JOptionPane.showMessageDialog(this,"le format de la date est mauvais, il boit etre come suivant" , "attention", INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(this,"attention vous n'avez pas renseign la date ou le mariage" , "attention", INFORMATION_MESSAGE); } }//GEN-LAST:event_btnDivorcerActionPerformed private void txtMoisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMoisActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtMoisActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed Vip vip1 = listeVip.get(this.jComboVip1.getSelectedIndex()); Vip vip2 = listeVip.get(this.jComboBoxVip2.getSelectedIndex()); // on rcupre les vips slectionns if ( vip1.equals(vip2)) { JOptionPane.showMessageDialog(this,"vous ne pouvez pas marier un Vip avec lui mme" , "attention", INFORMATION_MESSAGE); } else { try { String date = txtAnnee.getText() +"-"+txtMois.getText()+"-"+txtJour.getText() ; // mise au format de la date leDao.marierVip(vip1, vip2, date, txtLieux.getText()); txtAnnee.setText(""); txtLieux.setText(""); // on rinitialise les diffrents champs this.jComboBoxVip2.setModel(new ComboBoxModele(leDao.getCelibataire(listeVip))); //on rinitialise les combobox des vip clibataire et mariage pour les mettres a jour this.jComboVip1.setModel((new ComboBoxModele(leDao.getCelibataire(listeVip)))); this.comboBoxMariage.setModel(new ComboBoxModele(this.leDao.vipMari(this.listeMariage))); } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jButton1ActionPerformed private void btnAjouterVip2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAjouterVip2ActionPerformed FenetreAjoutVip fen = null; try { fen = new FenetreAjoutVip(this, vip, this.leDaoDivers, this.leDao.getDernierNumero()); } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } if (fen.doModal() == true) { try { lemodele.insererVIP(vip); this.listeVip.add(vip); this.jComboBoxVip2.setModel(new ComboBoxModele(leDao.getCelibataire(listeVip))); this.jComboBoxVip2.setSelectedItem((vip.getNom()) + "-" + vip.getNumVip()); // on slectionne le vip cr dans la comboBox } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_btnAjouterVip2ActionPerformed private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed if (jComboBoxFilm.getSelectedIndex() == -1) { JOptionPane.showMessageDialog(this, "vous devez slectionner un film", "attention", INFORMATION_MESSAGE); } else { String nomFilm = (String) this.jComboBoxFilm.getSelectedItem(); int numVisa = Integer.parseInt(nomFilm.split("_")[0]); // on teste que l'utilisateur est bien slctionn un realisateur ou un acteur mais pas les deux if ((jComboBoxActeur.getSelectedIndex() == -1 && jComboBoxRealisateur.getSelectedIndex() == -1) || (jComboBoxActeur.getSelectedIndex() != -1 && jComboBoxRealisateur.getSelectedIndex() != -1)) { JOptionPane.showMessageDialog(this, "vous devez slectionner un acteur ou un realisateur", "attention", INFORMATION_MESSAGE); jComboBoxActeur.setSelectedIndex(-1); // on fait en sorte que les jcombobox n'aient aucun item slctionn jComboBoxRealisateur.setSelectedIndex(-1); } else if (jComboBoxActeur.getSelectedIndex() != -1) { String nomActeur = (String) this.jComboBoxActeur.getSelectedItem(); int numActeur = Integer.parseInt(nomActeur.split("_")[1]); // on rcupre le numeroVip try { this.leDaoDivers.insererCasting(numActeur, numVisa, "A"); jComboBoxActeur.setSelectedIndex(-1); // on fait en sorte que les jcombobox n'aient aucun item slctionn jComboBoxFilm.setSelectedIndex(-1); } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "erreur lors de l'insertion, verifier que le casting ne soit pas dj insr", "attention", INFORMATION_MESSAGE); Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } else { String nomRealisateur = (String) this.jComboBoxRealisateur.getSelectedItem(); int numRealisateur = Integer.parseInt(nomRealisateur.split("_")[1]);// on rcupre le numeroVip try { this.leDaoDivers.insererCasting(numRealisateur, numVisa, "R"); jComboBoxFilm.setSelectedIndex(-1); // on fait en sorte que les jcombobox n'aient aucun item slctionn jComboBoxRealisateur.setSelectedIndex(-1); } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "erreur lors de l'insertion, verifier que le casting ne soit pas dj insr", "attention", INFORMATION_MESSAGE); Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } } }//GEN-LAST:event_jButton6ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed int leNumero = -1; int ligne = this.tableFilm.getSelectedRow(); if (ligne != -1) // on teste que l'utilisateur ait bien slctionn un film { leNumero = (int) lemodeleFilm.getValueAt(ligne, 0); // rcupre le numro de Visa du film slctionn AfficheFilm afficheAjoutee = new AfficheFilm(); FenetreAjoutAffiche fen6 = new FenetreAjoutAffiche(this, afficheAjoutee, leNumero); if (fen6.doModal() == true) { try { this.leDaoFilm.ajoutAffiche(afficheAjoutee); } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); JOptionPane.showMessageDialog(this, "probleme lors de l'insertion dans la base, vrifier que la photo n'existe pas dj", "attention", INFORMATION_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "vous devez slectionner un film", "attention", INFORMATION_MESSAGE); } }//GEN-LAST:event_jButton5ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed int leNumero = -1; int ligne = this.tableFilm.getSelectedRow(); if (ligne != -1) { try { leNumero = (int) lemodeleFilm.getValueAt(ligne, 0); // on rcupre le numro de Visa du film slctionn Film leFilmM = leDaoFilm.getFilm(leNumero); FenetreModificationFilm fen4 = new FenetreModificationFilm(this, leFilmM, this.leDaoDivers); fen4.remplirChamps(); if (fen4.doModal()) { this.lemodeleFilm.modifierFilm(leFilmM, ligne); } } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_jButton4ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed Film unFilm = new Film(); FenetreAjoutFilm fen3 = new FenetreAjoutFilm(this, unFilm, this.leDaoDivers); if (fen3.doModal() == true) { try { lemodeleFilm.insererFilm(unFilm); } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "erreur sur les informations, verifier que le numero de Visa ne soit pas dupliqu ou que le type des champs soit correct", "attention", INFORMATION_MESSAGE); } } }//GEN-LAST:event_jButton3ActionPerformed private void btnPhotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPhotoActionPerformed int leNumero = -1 ; int ligne = this.tableVip.getSelectedRow(); if(ligne!= -1) { leNumero =(int) lemodele.getValueAt(ligne,0); // on rcupre le numro du vip slctionn Photo photoAjoute = new Photo(leNumero); FenetreAjoutPhoto fen5 = new FenetreAjoutPhoto(this,photoAjoute); if ( fen5.doModal() ==true) { if( photoAjoute.getTypePhoto() == 1) // si le type photo = 1, alors c'est une photo classique { try { this.leDao.ajouterPhoto(photoAjoute); } catch (SQLException ex) { JOptionPane.showMessageDialog(this,"probleme lors de l'insertion dans la base, vrifier que la photo n'existe pas dj" , "attention", INFORMATION_MESSAGE); } } else // sinon c'est une photo de profil { try { this.leDao.ajouterPhotoProfil(photoAjoute); } catch (SQLException ex) { JOptionPane.showMessageDialog(this,"probleme lors de l'insertion dans la base, vrifier que la photo n'existe pas dj" , "attention", INFORMATION_MESSAGE); } } } } else { JOptionPane.showMessageDialog(this,"vous n'avez pas slction de Vip" , "attention", INFORMATION_MESSAGE); } }//GEN-LAST:event_btnPhotoActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed int leNumero = -1; int ligne = this.tableVip.getSelectedRow(); if (ligne != -1) // on vrifie que l'utilisateur est bien slectionn un numro { try { leNumero = (int) lemodele.getValueAt(ligne, 0);// on rcupre le numro du vip slctionn Vip vipModifier = leDao.getVip(leNumero); FenetreModifierVip fen2 = new FenetreModifierVip(this, vipModifier, this.leDaoDivers); fen2.remplirChamps(); if (fen2.doModal()) { this.lemodele.modifierVip(vipModifier, ligne); } } catch (SQLException ex) { JOptionPane.showMessageDialog(this, "erreur sur les informations, verifier que le numero de Vip ne soit pas dupliqu ou que la date soit au bon format", "attention", INFORMATION_MESSAGE); } } }//GEN-LAST:event_jButton2ActionPerformed private void btnAjouterVipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAjouterVipActionPerformed Vip vipAjouter = new Vip(); FenetreAjoutVip fen = null; try { fen = new FenetreAjoutVip(this, vipAjouter, this.leDaoDivers, this.leDao.getDernierNumero()); // on instancie une fenetre d'ajout de Vip , en lui donnant en parametre le dernier numeroVip utilis } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } if (fen.doModal() == true) { try { lemodele.insererVIP(vipAjouter); } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } } }//GEN-LAST:event_btnAjouterVipActionPerformed private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed if ( !txtTitre.getText().equals("") && !txtAuteur.getText().equals("") && !txtContenu.getText().equals("") && !txtDateArticle.getText().equals("") && !txtHeure.getText().equals("")) // on vrifie que tous les champs soit remplie { Article article = new Article(); article.setTitre(txtTitre.getText()); article.setAuteur(txtAuteur.getText()); article.setContenu(txtContenu.getText()); //on rcupere tous les champs article.setDate(txtDateArticle.getText()); article.setHeure(txtHeure.getText()); try { FileInputStream input = null; try { input = new FileInputStream(nomF); } catch (FileNotFoundException ex) { Logger.getLogger(FenetreAjoutPhoto.class.getName()).log(Level.SEVERE, null, ex); } FTPSClient ftpClient = new FTPSClient(); if(!txtNomPhotoA.getText().equals("")) { ftpClient.connect("iutdoua-samba.univ-lyon1.fr",990); // on cr la connexion ftp Properties props = new Properties(); FileInputStream fichier = new FileInputStream("src/info.properties"); props.load(fichier); ftpClient.login(props.getProperty("login"), props.getProperty("password")); // on rentre le password et le login System.out.println(ftpClient.getReplyString()); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.setFileTransferMode(FTP.BINARY_FILE_TYPE); // on met le mode de transfert en fichier binaire ftpClient.enterLocalPassiveMode(); String remote ; remote = "public_html/CPOA/Site/assets/imagesArticles/" + txtNomPhotoA.getText() ; // on spcifie le lieu de dpot du fichier ainsi qu son nom boolean done = ftpClient.storeFile(remote, input); // on upload le fichier input.close(); if( done) //si le fichier a russi { article.setNomPhoto(txtNomPhotoA.getText()); System.out.println("reussi"); System.out.println(ftpClient.getReplyString()); } else { article.setNomPhoto("NULL"); System.out.println(ftpClient.getReplyString()); throw new Exception(); // si l'upload n'a pas russi, on interromp la cration de l'article et on en informe l'utilisateur } } } catch(Exception E) { JOptionPane.showMessageDialog(this,"erreur lors de l'upload de la photo" , "attention", INFORMATION_MESSAGE); // si il y a eu un probleme d'upload } try { this.leDaoDivers.insrerArticle(article); } catch (SQLException ex) { Logger.getLogger(FenetrePrincipale.class.getName()).log(Level.SEVERE, null, ex); } this.txtContenu.setText(""); txtHeure.setText(""); txtDateArticle.setText(""); // on remet tous les champs a vide txtTitre.setText(""); txtAuteur.setText(""); txtNomPhotoA.setText(""); this.nomF = ""; this.nomPhoto = ""; } else { JOptionPane.showMessageDialog(this,"vous devez remplir tous les champs( except photo qui est optionel)" , "attention", INFORMATION_MESSAGE); } }//GEN-LAST:event_jButton7ActionPerformed private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed String format = "dd/MM/yy H:mm:ss"; java.text.SimpleDateFormat formater = new java.text.SimpleDateFormat(format); java.util.Date date = new java.util.Date(); // on rcupre la date et l'heure du jour au format "dd/MM/yy H:mm:ss" String hd[] = formater.format(date).split(" "); // on coupe en deux au caractre espace, cela permet de rcuprer la date et l'heure sparement txtDateArticle.setText(hd[0].replaceAll("[/]", "-")); // on remplace les / par des - pour mettre la date au format mySQL txtHeure.setText(hd[1]); }//GEN-LAST:event_jButton8ActionPerformed private void btnPhotoArticleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPhotoArticleActionPerformed JFileChooser chooser = new JFileChooser(new File(".")); // on fait selectionner a l'utilsateur le fichier voulie chooser.setDialogTitle("ouvrir une image"); int reponse = chooser.showOpenDialog(this); if (reponse == JFileChooser.APPROVE_OPTION) { InputStream input = null; f = chooser.getSelectedFile(); // on rcupre le fichir nomPhoto = f.getName(); // on rcupre le nom de fichier nomF = f.getAbsolutePath(); // on rcupere le chemin absolue du ficheir txtNomPhotoA.setText(nomPhoto); } }//GEN-LAST:event_btnPhotoArticleActionPerformed private void txtNomPhotoAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNomPhotoAActionPerformed // TODO add your handling code here: }//GEN-LAST:event_txtNomPhotoAActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnAjouterVip; private javax.swing.JButton btnAjouterVip2; private javax.swing.JButton btnDivorcer; private javax.swing.JButton btnPhoto; private javax.swing.JButton btnPhotoArticle; private javax.swing.JComboBox comboBoxMariage; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JComboBox jComboBoxActeur; private javax.swing.JComboBox jComboBoxFilm; private javax.swing.JComboBox jComboBoxRealisateur; private javax.swing.JComboBox jComboBoxVip2; private javax.swing.JComboBox jComboVip1; 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 jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel28; private javax.swing.JLabel jLabel29; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel30; private javax.swing.JLabel jLabel31; 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.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator2; private javax.swing.JSeparator jSeparator3; private javax.swing.JSeparator jSeparator4; private javax.swing.JSeparator jSeparator5; private javax.swing.JSeparator jSeparator6; private javax.swing.JSeparator jSeparator7; private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTabbedPane jTabbedPane2; private javax.swing.JTable tableFilm; private javax.swing.JTable tableVip; private javax.swing.JTextField txtAnnee; private javax.swing.JTextField txtAnneeD; private javax.swing.JTextField txtAuteur; private javax.swing.JTextArea txtContenu; private javax.swing.JTextField txtDateArticle; private javax.swing.JTextField txtHeure; private javax.swing.JTextField txtJour; private javax.swing.JTextField txtJourD; private javax.swing.JTextField txtLieux; private javax.swing.JTextField txtMois; private javax.swing.JTextField txtMoisD; private javax.swing.JTextField txtNomPhotoA; private javax.swing.JTextField txtTitre; // End of variables declaration//GEN-END:variables }