Example #1
0
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed

    try {
      interfaces op;
      op = (interfaces) Naming.lookup("rmi://localhost/persistencia");

      pre = op.buscaPregunta(Integer.parseInt(jTextField1.getText()));
      if (pre != null) {
        this.jLabel5.setText(Integer.toString(pre.getIdpregunta()));
        this.jTextField2.setText(pre.getPregunta());
        this.jTextField3.setText(pre.getRespuestacorrecta());
        this.jTextField1.setText("");
        Examen c;
        c = op.buscaExamen(pre.getExamen().getIdexamen());
        Materia t;
        t = op.buscaMateria(c.getMateria().getIdmateria());
        this.jComboBox1.setSelectedItem(
            exa.getIdexamen() + "-" + t.getNombre() + "-" + exa.getParcial());
        this.jTextField1.setText("");

      } else {
        JOptionPane.showMessageDialog(null, "No existe");
      }

    } catch (NotBoundException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MalformedURLException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jButton1ActionPerformed
Example #2
0
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    try {

      if (this.jTextField2.getText().length() > 0) {
        pre.setPregunta(jTextField2.getText());
        pre.setRespuestacorrecta(jTextField3.getText());
        pre.setIdpregunta(Integer.parseInt(jLabel5.getText()));
        String texto = (String) jComboBox1.getSelectedItem();
        String[] parts = texto.split("-");
        String part = parts[0];
        exa.setIdexamen(Integer.parseInt(part));
        pre.setExamen(exa);
        interfaces op;
        op = (interfaces) Naming.lookup("rmi://localhost/persistencia");
        if (op.actualizarPregunta(pre)) {
          JOptionPane.showMessageDialog(null, "Se actualizo correctamente");
          this.jLabel5.setText("");
          this.jTextField2.setText("");
          this.jTextField3.setText("");
        } else {
          JOptionPane.showMessageDialog(null, "Ocurrio un error");
        }
      } else {
        JOptionPane.showMessageDialog(
            null, "Debe buscar primero el centro de trabajo para poder eliminar o actualizar ");
      }
    } catch (NotBoundException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MalformedURLException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
      Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jButton3ActionPerformed
Example #3
0
  private void jButton2ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton2ActionPerformed
    if (jTextField2.getText().isEmpty()) {
      JOptionPane.showMessageDialog(null, "Debe Ingresar una Pregunta");
    } else {
      pre.setPregunta(jTextField2.getText());
      pre.setRespuestacorrecta(jTextField3.getText());
      String texto = (String) jComboBox1.getSelectedItem();
      String[] parts = texto.split("-");
      String part = parts[0];
      exa.setIdexamen(Integer.parseInt(part));
      pre.setExamen(exa);
      try {
        interfaces op;
        op = (interfaces) Naming.lookup("rmi://localhost/persistencia");
        if (op.insertarPregunta(pre)) {
          this.jLabel5.setText("");
          this.jTextField2.setText("");
          JOptionPane.showMessageDialog(null, "Se inserto correctamente");
          this.jLabel5.setText("");
          this.jTextField2.setText("");
          this.jTextField3.setText("");
        } else {
          JOptionPane.showMessageDialog(null, "Ocurrio un error");
        }

      } catch (NotBoundException ex) {
        Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
      } catch (MalformedURLException ex) {
        Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
      } catch (RemoteException ex) {
        Logger.getLogger(PreguntasForm.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
  } // GEN-LAST:event_jButton2ActionPerformed
Example #4
0
 private void jButton4ActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton4ActionPerformed
   try {
     if (this.jTextField2.getText().length() > 0) {
       interfaces op;
       op = (interfaces) Naming.lookup("rmi://localhost/persistencia");
       pre.setIdpregunta(Integer.parseInt(jLabel5.getText()));
       if (op.eliminarPregunta(pre)) {
         JOptionPane.showMessageDialog(null, "Se Elimino correctamente");
         this.jLabel5.setText("");
         this.jTextField2.setText("");
         this.jTextField3.setText("");
       } else {
         JOptionPane.showMessageDialog(null, "Ocurrio un error");
       }
     } else {
       JOptionPane.showMessageDialog(
           null, "Debe buscar primero escuela para poder eliminar o actualizar ");
     }
   } catch (NotBoundException | MalformedURLException | RemoteException ex) {
     Logger.getLogger(Centros.class.getName()).log(Level.SEVERE, null, ex);
   }
 } // GEN-LAST:event_jButton4ActionPerformed