-
-
Save anonymous/014a7c3fdce1013800ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void ver_empleado() | |
{ | |
LinkedHashMap<String, Integer> columnsProps = new LinkedHashMap<>(); | |
columnsProps.put("DNI", 80); | |
columnsProps.put("Nombre y Apellidos", 300); | |
columnsProps.put("Categoria", 90); | |
columnsProps.put("Cargo", 200); | |
columnsProps.put("Fec. Ingreso", 70); | |
columnsProps.put("Contrato", 70); | |
columnsProps.put("Fec. Ven. Co.", 70); | |
columnsProps.put("Poliza SCTR", 70); | |
columnsProps.put("EMO", 70); | |
columnsProps.put("Ant. Polic.", 70); | |
columnsProps.put("Ant. Penales", 70); | |
columnsProps.put("Ant. Judic.", 70); | |
columnsProps.put("Estado", 50); | |
for (Map.Entry<String, Integer> column : columnsProps.entrySet()) | |
{ | |
tableModel.addColumn(column.getKey()); | |
} | |
try | |
{ | |
URL url = new URL("http://tupagina.com/get_empleados.php"); | |
try (InputStream is = url.openStream(); | |
JsonReader reader = Json.createReader(is)) | |
{ | |
JsonObject empleadosObject = reader.readObject(); | |
JsonArray empleados = empleadosObject.getJsonArray("data"); | |
empleados.getValuesAs(JsonObject.class).stream().forEach((empleado) -> | |
{ | |
Object fila[] = new Object[14]; | |
fila[0] = empleado.getString("dni_col"); | |
fila[1] = empleado.getString("nom_col"); | |
fila[2] = empleado.getString("descripcion"); | |
fila[3] = empleado.getString("desc_car"); | |
fila[4] = "-"; | |
fila[5] = "NO"; | |
fila[6] = "-"; | |
if( empleado.getOrDefault("fec_ini", null) != null ) | |
{ | |
fila[5] = "SI"; | |
fila[6] = empleado.getString("fec_ini"); | |
} | |
fila[7] = fila[8] = fila[9] | |
= fila[10] = fila[11] = "-"; | |
fila[12] = empleado.getString("est_col").equals("1") ? "ACTIVO" : "-"; | |
tableModel.addRow(fila); | |
}); | |
} | |
} | |
catch(Exception e){ System.out.println(e.getMessage()); } | |
int columnIndex = 0; | |
for (Map.Entry<String, Integer> column : columnsProps.entrySet()) | |
{ | |
table.getColumnModel().getColumn(columnIndex++).setMinWidth(column.getValue()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment