示例#1
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
示例#2
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