예제 #1
0
  private void mitemupdateMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_mitemupdateMousePressed
    try {
      val = new Validators("roles");
      Object[] datos = {txtName.getText(), lblId.getText()};
      Object[] tipos = {2};
      if (val.validar(datos, tipos)) {
        if (!"".equals(lblId.getText())) {
          int id = Integer.valueOf(lblId.getText());
          String name = txtName.getText();
          objroles = new RolesDAO();
          int i = objroles.update(id, name);
          if (i == 0) {

            JOptionPane.showMessageDialog(null, "No se pudo actualizar datos");
          } else {
            objroles.getTableAll(tblroles, lblcant);
            cleanBox();
            JOptionPane.showMessageDialog(null, "roles actualizados");
          }
        } else {
          JOptionPane.showMessageDialog(null, "Seleccione un rol para ejecutar esta accion");
        }
      } else {
        JOptionPane.showMessageDialog(null, "Campos requeridos incompletos");
      }
    } catch (Exception e) {
      System.out.println(_error + "_Update:" + e);
    }
  } // GEN-LAST:event_mitemupdateMousePressed
예제 #2
0
 public void cargaForm() {
   try {
     objroles = new RolesDAO();
     qs = new Query();
     objroles.getTableAll(tblroles, lblcant);
   } catch (Exception e) {
     System.out.println(_error + "CargaForm:" + e);
   }
 }
예제 #3
0
  private void mitemdeleteMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_mitemdeleteMousePressed
    try {
      val = new Validators("roles");
      Object[] datos = {lblId.getText()};
      Object[] tipos = {};
      if (val.validar(datos, tipos)) {
        int i;
        i =
            JOptionPane.showConfirmDialog(
                null,
                "¿Esta seguro de eliminar este registro?",
                "Aviso",
                JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.WARNING_MESSAGE);

        if (i == 0) {
          if (!"".equals(lblId.getText())) {
            int id = Integer.valueOf(lblId.getText());
            objroles = new RolesDAO();
            i = objroles.delete(id);
            if (i == 0) {
              JOptionPane.showMessageDialog(null, "No se pudo eliminar el rol");
            } else {
              objroles.getTableAll(tblroles, lblcant);
              cleanBox();
              JOptionPane.showMessageDialog(null, "Rol eliminado");
            }
          } else {
            JOptionPane.showMessageDialog(null, "Seleccione un rol para ejecutar esta accion");
          }
        }
      } else {
        JOptionPane.showMessageDialog(null, "Campos requeridos incompletos");
      }
    } catch (Exception e) {
      System.out.println(_error + "_Delete:" + e);
    }
  } // GEN-LAST:event_mitemdeleteMousePressed
예제 #4
0
 private void mitemregisterMousePressed(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_mitemregisterMousePressed
   try {
     val = new Validators("roles");
     Object[] datos = {txtName.getText()};
     Object[] tipos = {2};
     if (val.validar(datos, tipos)) {
       String name = txtName.getText();
       objroles = new RolesDAO();
       int i = objroles.save(name);
       if (i == 0) {
         JOptionPane.showMessageDialog(null, "No se pudo grabar datos");
       } else {
         objroles.getTableAll(tblroles, lblcant);
         cleanBox();
         JOptionPane.showMessageDialog(null, "Nueva rol registrado");
       }
     } else {
       JOptionPane.showMessageDialog(null, "Campos requeridos incompletos");
     }
   } catch (Exception e) {
     System.out.println(_error + "_Register:" + e);
   }
 } // GEN-LAST:event_mitemregisterMousePressed
예제 #5
0
  private void tblrolesMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_tblrolesMouseClicked
    int fsel;
    fsel = this.tblroles.getSelectedRow();
    if (fsel == -1) {

    } else {
      try {
        roles = new Roles();
        DefaultTableModel m = new DefaultTableModel();
        m = (DefaultTableModel) this.tblroles.getModel();
        String idrol = String.valueOf(m.getValueAt(fsel, 0));
        lblId.setText(idrol);
        roles = objroles.getValues(Integer.parseInt(idrol));
        txtName.setText(roles.getName());

      } catch (Exception e) {
        System.out.println(_error + "_tblroles:" + e);
      }
    }
  } // GEN-LAST:event_tblrolesMouseClicked
예제 #6
0
 private void btnFindActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnFindActionPerformed
   String name = txtFilter.getText();
   objroles = new RolesDAO();
   objroles.find(name, tblroles, lblcant);
 } // GEN-LAST:event_btnFindActionPerformed