Пример #1
0
  public IntervenantPage() throws SQLException {
    initComponents();

    ConnectBDD();

    jTextField1.setText("-");
    jLabel4.setVisible(false);
    jComboBox3.setVisible(false);
    jLabel5.setVisible(false);
    jTextField1.setVisible(false);

    identifiantConnect = ConnectPage.getIdentifiant();

    IntervenantsDAO i1 = new IntervenantsDAO();
    i1.getConnection();
    ArrayList<Intervenants> mesLogin = i1.selectAll();

    for (Intervenants ii : mesLogin) {
      jComboBox1.addItem(ii.getLogin());
    }

    OrdinateurDAO o1 = new OrdinateurDAO();
    o1.getConnection();
    ArrayList<Ordinateur> mesordi = o1.selectAll();

    for (Ordinateur oo : mesordi) {
      jComboBox2.addItem(oo.getRefOrdinateur());
    }

    PanneDAO p1 = new PanneDAO();
    p1.getConnection();
    ArrayList<Panne> mesPanne = p1.selectAll();

    DefaultTableModel model = new DefaultTableModel();
    model.addColumn("Id Panne");
    model.addColumn("Date Panne");
    model.addColumn("Type Materiel");
    model.addColumn("Urgence Panne");
    model.addColumn("Peripherique Panne");
    model.addColumn("Ordinateur");
    model.addColumn("Descriptif");

    for (Panne pp : mesPanne) {
      model.addRow(
          new Object[] {
            pp.getIdPanne(),
            pp.getDatePanne(),
            pp.getTypeMaterielPanne(),
            pp.getUrgencePanne(),
            pp.getPeripheriquePanne(),
            pp.getIdOrdinateurPanne(),
            pp.getDescriptifPanne()
          });
    }

    jTable2.setModel(model);

    this.setIconImage(new ImageIcon(getClass().getResource("gsb-icon.png")).getImage());
  }
Пример #2
0
  private void jComboBox5ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jComboBox5ActionPerformed

    int a = jComboBox3.getSelectedIndex();
    int b = jComboBox5.getSelectedIndex();

    if (b == 1) { // SI TYPE SELECTIONNEE EST HARDWARE

      jLabel4.setVisible(true);
      jComboBox3.setVisible(true);
      jLabel5.setVisible(true);
      jTextField1.setVisible(true);

      if (a == 1) {
        variable = "CarteMere";
      } else if (a == 2) {
        variable = "Processeur";
      } else if (a == 3) {
        variable = "MemoireVive";
      } else if (a == 4) {
        variable = "DisqueDur";
      } else if (a == 5) {
        variable = "CarteReseau";
      } else if (a == 6) {
        variable = "Lecteur";
      } else if (a == 7) {
        variable = "CarteGraphique";
      } else if (a == 8) {
        variable = "CarteSon";
      } else if (a == 9) {
        variable = "Alimentation";
      }

    } else {
      jLabel4.setVisible(false);
      jComboBox3.setVisible(false);
      jLabel5.setVisible(false);
      jTextField1.setVisible(false);
    }

    String panne;
    boolean compare;
    int idPanne;

    jComboBox4.removeAllItems();
    PanneDAO p2 = new PanneDAO();
    p2.getConnection();
    ArrayList<Panne> mesPanne2 = p2.selectAll();

    machine = jComboBox2.getSelectedItem().toString();

    for (Panne pp : mesPanne2) {
      panne = pp.getIdOrdinateurPanne();
      idPanne = pp.getIdPanne();

      selected = jComboBox5.getSelectedItem().toString();

      String typeMaterielPanne = pp.getTypeMaterielPanne();
      compare = panne.equals(machine);
      if (compare == true) {
        if (typeMaterielPanne.equals(selected)) {
          jComboBox4.addItem(idPanne);
        }
      }
    }
  } // GEN-LAST:event_jComboBox5ActionPerformed
Пример #3
0
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed

    modification = jTextField1.getText();
    machine = jComboBox2.getSelectedItem().toString();
    intervenant = jComboBox1.getSelectedItem().toString();
    composant = jComboBox3.getSelectedItem().toString();
    info = jTextArea1.getText();

    try {
      formatDate = df.format(jDateChooser1.getDate());

      try {
        int a = jComboBox3.getSelectedIndex();
        int b = jComboBox5.getSelectedIndex();

        if (b == 1) { // SI TYPE SELECTIONNEE EST HARDWARE

          Ordinateur update = new Ordinateur(variable, modification, machine);
          OrdinateurDAO ordi = new OrdinateurDAO();
          ordi.getConnection();
          ordi.update(update);
        }
        int idPanneSelect;
        idPanneSelect = jComboBox4.getSelectedItem().hashCode();
        InterventionDAO iDAO = new InterventionDAO(); // DEBUT INSERT INTERVENTION
        Intervention insertInter =
            new Intervention(
                formatDate,
                machine,
                composant,
                idPanneSelect,
                modification,
                info,
                identifiantConnect);
        iDAO.getConnection();
        iDAO.insert(insertInter);

        int idPanne = jComboBox4.getSelectedItem().hashCode();

        Panne delete = new Panne(idPanne);
        PanneDAO ordinateurPanne = new PanneDAO();
        ordinateurPanne.getConnection();
        ordinateurPanne.delete(delete);

        jComboBox4.removeAllItems();

        PanneDAO p2 = new PanneDAO(); // ACTUALISE ID PANNE
        p2.getConnection();
        ArrayList<Panne> mesPanne2 = p2.selectAll();

        String panne;
        boolean compare;

        for (Panne pp : mesPanne2) {
          panne = pp.getIdOrdinateurPanne();
          idPanne = pp.getIdPanne();
          compare = panne.equals(machine);
          if (compare == true) {
            jComboBox4.addItem(idPanne);
          }
        }

      } catch (Exception e) {
        jTextArea1.setText("-");
        jTextField1.setText("-");
        JOptionPane.showMessageDialog(null, "Veuillez spécifier tous les champs ");
        e.printStackTrace();
      }

      jTextField1.setText("-");
      jTextArea1.setText("-");

      JOptionPane.showMessageDialog(null, "Votre panne a bien etais résolu");

    } catch (Exception e) {
      jTextArea1.setText("-");
      jTextField1.setText("-");
      JOptionPane.showMessageDialog(null, "Veuillez selectionner une date ");
      e.printStackTrace();
    }

    PanneDAO p1 = new PanneDAO(); // ACTUALISE HISTORIQUE PANNE
    p1.getConnection();
    ArrayList<Panne> mesPanne = p1.selectAll();

    DefaultTableModel model = new DefaultTableModel();
    model.addColumn("Id Panne");
    model.addColumn("Date Panne");
    model.addColumn("Type Materiel");
    model.addColumn("Urgence Panne");
    model.addColumn("Peripherique Panne");
    model.addColumn("Ordinateur");
    model.addColumn("Descriptif");

    for (Panne pp : mesPanne) {
      model.addRow(
          new Object[] {
            pp.getIdPanne(),
            pp.getDatePanne(),
            pp.getTypeMaterielPanne(),
            pp.getUrgencePanne(),
            pp.getPeripheriquePanne(),
            pp.getIdOrdinateurPanne(),
            pp.getDescriptifPanne()
          });
    }

    jTable2.setModel(model);
    jComboBox5.setSelectedIndex(0);

    machine = jComboBox2.getSelectedItem().toString();
    intervenant = jComboBox1.getSelectedItem().toString();
    composant = jComboBox3.getSelectedItem().toString();
    info = jTextArea1.getText();

    try {
      FileWriter fw = new FileWriter("log_intervenant.txt", true);
      BufferedWriter bw = new BufferedWriter(fw);
      bw.newLine();
      PrintWriter pw = new PrintWriter(bw);
      pw.print(
          "Modification: "
              + modification
              + "\n Machine: "
              + machine
              + "\n Intervenant: "
              + intervenant
              + "\n Composant: "
              + composant
              + "\n Info: "
              + info
              + "\n ----------------------- \n");
      pw.close();
    } catch (IOException e) {
      System.out.println(" Problème à l’écriture du fichier ");
      System.exit(0);
    }
  } // GEN-LAST:event_jButton3ActionPerformed