private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:

    // ssup.setDate_soiree(new java.sql.Date(datesoiree.getTime()));
    // ssup.setNom_soiree(nomsoiree);
    // ssup.setDescription_soiree(discrip);

    if (jTfnomsoiree.getText().equals("")
        || jTAdescrip.getText().equals("")
        || jTFadresse.getText().equals("")
        || (jXDatePickerdatesoiree.getDate() == null)) {
      JOptionPane.showMessageDialog(
          this,
          "suppression erroné!! tout les champs doivent étrede remplie !!! cliquer deux fois sur la ligne que vous souhaitez supprimer merci",
          "Ajout soiree",
          JOptionPane.ERROR_MESSAGE);
    } else {
      String nomtheatre = jTfnomsoiree.getText();
      String discrip = jTAdescrip.getText();
      String adresse = jTFadresse.getText();
      java.util.Date datetheatre = jXDatePickerdatesoiree.getDate();
      int ligne_selectionee = jTable1.getSelectedRow();
      int id = (int) jTable1.getValueAt(ligne_selectionee, 0);

      Theatre tsup = new Theatre();

      // ssup.setAdresse_soiree(adresse);
      tsup.setCode_theatre(id);
      SoireeDAO soireedao = new SoireeDAO();
      soireedao.deleteSoiree(id);
      JOptionPane.showMessageDialog(this, "Suppression effectuée avec succès :");
    }
  } // GEN-LAST:event_jButton3ActionPerformed
  private void jBrechercheActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBrechercheActionPerformed
    // TODO add your handling code here:
    TheatreDAO tdao = new TheatreDAO();
    Theatre tresultat = new Theatre();

    tresultat = tdao.findtheatreBynom(jTFrecherche.getText());

    System.out.println("" + tresultat.toString());

    if ((tresultat.getNom_theatre() != null)
        && (tresultat.getAdresse_théatre() != null)
        && (tresultat.getDescription_theatre() != null)) {
      jTfnomsoiree.setText(tresultat.getNom_theatre());
      jTFadresse.setText(tresultat.getAdresse_théatre());
      jTAdescrip.setText(tresultat.getDescription_theatre());
      jXDatePickerdatesoiree.setDate(tresultat.getDate_theatre());

      JOptionPane.showMessageDialog(this, "recherche effectuée avec succès :");
    } else {

      JOptionPane.showMessageDialog(
          this, "Nom théatre inexistant", "Recherche nom soirée", JOptionPane.WARNING_MESSAGE);
    }
  } // GEN-LAST:event_jBrechercheActionPerformed
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:

    String nomtheatre;
    String discriptiontheatre;
    String datetheatre;
    String adressetheatre;
    nomtheatre = jTfnomsoiree.getText();
    discriptiontheatre = jTAdescrip.getText();
    adressetheatre = jTFadresse.getText();

    // java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
    //        datesoiree=jTFdat.getText();
    //
    //        String annee=datesoiree.substring(0, 4);
    //        int an=Integer.parseInt(annee);
    //        String month;
    //        month = datesoiree.substring(5, 7);
    //        int mon;
    //        mon = Integer.parseInt(month);
    //        String dd=datesoiree.substring(8, 10);
    //        int day;
    //        day = Integer.parseInt(dd);
    //        Date date=new Date(an-1900, mon-1, day);
    //

    if (nomtheatre.equals("") || discriptiontheatre.equals("") || adressetheatre.equals("")) {
      JOptionPane.showMessageDialog(
          this,
          "Ajout erroné!! remplissez les champs de saisie !!!",
          "Ajout soiree",
          JOptionPane.ERROR_MESSAGE);
    } else {

      Theatre t1 = new Theatre();
      t1.setNom_theatre(nomtheatre);
      t1.setDescription_theatre(discriptiontheatre);
      Date Datet;
      Datet = jXDatePickerdatesoiree.getDate();

      java.sql.Date sqlDate = new java.sql.Date(Datet.getTime());
      t1.setDate_theatre(sqlDate);
      t1.setAdresse_théatre(adressetheatre);
      TheatreDAO t1dao = new TheatreDAO();
      t1dao.inserttheatre(t1);
      JOptionPane.showMessageDialog(this, "Ajout effectuée avec succée :");
    }
  } // GEN-LAST:event_jButton1ActionPerformed
  private void jTable1MouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jTable1MouseClicked
    // TODO add your handling code here:
    int ligne_selectionee = jTable1.getSelectedRow();
    int id = (int) jTable1.getValueAt(ligne_selectionee, 0);

    TheatreDAO tdao = new TheatreDAO();

    Theatre t = new Theatre();
    t = tdao.findtheatreByID(id);

    jTfnomsoiree.setText(t.getNom_theatre());
    jTAdescrip.setText(t.getDescription_theatre());
    jTFadresse.setText(t.getAdresse_théatre());

    java.sql.Date date = t.getDate_theatre();

    java.util.Date d = (java.util.Date) date;
    jXDatePickerdatesoiree.setDate(d);
  } // GEN-LAST:event_jTable1MouseClicked
 private void jButton2ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
   // TODO add your handling code here:
   if (jTfnomsoiree.getText().equals("")) {
     JOptionPane.showMessageDialog(
         this,
         "Ajout erroné!! remplissez les champs de saisie !!!",
         "Ajout soiree",
         JOptionPane.ERROR_MESSAGE);
   } else {
     TheatreDAO tdao = new TheatreDAO();
     Theatre t = new Theatre();
     t = tdao.findtheatreBynom(jTfnomsoiree.getText());
     t.setCode_theatre(t.getCode_theatre());
     t.setAdresse_théatre(jTFadresse.getText());
     Date Datet;
     Datet = jXDatePickerdatesoiree.getDate();
     java.sql.Date sqlDate = new java.sql.Date(Datet.getTime());
     t.setDate_theatre(sqlDate);
     t.setDescription_theatre(jTAdescrip.getText());
     t.setNom_theatre(jTfnomsoiree.getText());
     tdao.updateSoiree(t);
   }
 } // GEN-LAST:event_jButton2ActionPerformed