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

    // boton para modificar
    if (!txtcodigo.getText().isEmpty()) {
      if (!txtnombre.getText().isEmpty()) {

        // Se selecciona el dato del comobobox que tiene el id segun el indice del combobox que se
        // puede ver

        mthunidadmedidas obj = new mthunidadmedidas();
        obj.setNumero(Integer.parseInt(txtcodigo.getText()));
        obj.setNombre(txtnombre.getText());

        if (obj.modify_unidad()) {
          try {
            DefaultTableModel modelo = (DefaultTableModel) tablaunidadmedidas.getModel();
            int filas = tablaunidadmedidas.getRowCount();
            for (int i = 0; filas > i; i++) {
              modelo.removeRow(0);
            }
            mthunidadmedidas para_actualizar = new mthunidadmedidas();
            para_actualizar.tabla_unidad();
            limpiar();
          } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error al limpiar la tabla.");
          }
          JOptionPane.showMessageDialog(this, "Datos Modificados");

        } else {
          JOptionPane.showMessageDialog(this, "Error al modificar datos");
        }

      } else {
        JOptionPane.showMessageDialog(this, "Por favor asegurese de llenar todos los campos");
      }

    } else {
      JOptionPane.showMessageDialog(this, "Por favor seleccione un usuario a modificar");
    }
  } // GEN-LAST:event_jButton3ActionPerformed