diff --git a/bin/control/ControlLogin.class b/bin/control/ControlLogin.class new file mode 100644 index 0000000..9df1d14 Binary files /dev/null and b/bin/control/ControlLogin.class differ diff --git a/bin/control/ControlPrincipal.class b/bin/control/ControlPrincipal.class new file mode 100644 index 0000000..399cccf Binary files /dev/null and b/bin/control/ControlPrincipal.class differ diff --git a/bin/main/Main.class b/bin/main/Main.class index 97b6361..1f192a4 100644 Binary files a/bin/main/Main.class and b/bin/main/Main.class differ diff --git a/bin/utiles/Archivo.class b/bin/utiles/Archivo.class index 81281d5..c2caf3d 100644 Binary files a/bin/utiles/Archivo.class and b/bin/utiles/Archivo.class differ diff --git a/bin/utiles/Cifrador.class b/bin/utiles/Cifrador.class index 6eaa23a..c01c5c1 100644 Binary files a/bin/utiles/Cifrador.class and b/bin/utiles/Cifrador.class differ diff --git a/bin/utiles/Validador.class b/bin/utiles/Validador.class index bfd08eb..85405fe 100644 Binary files a/bin/utiles/Validador.class and b/bin/utiles/Validador.class differ diff --git a/bin/visualV2/FrameLogin$1.class b/bin/visualV2/FrameLogin$1.class new file mode 100644 index 0000000..bc4a4d5 Binary files /dev/null and b/bin/visualV2/FrameLogin$1.class differ diff --git a/bin/visualV2/FrameLogin$2.class b/bin/visualV2/FrameLogin$2.class new file mode 100644 index 0000000..a568299 Binary files /dev/null and b/bin/visualV2/FrameLogin$2.class differ diff --git a/bin/visualV2/FrameLogin$3.class b/bin/visualV2/FrameLogin$3.class new file mode 100644 index 0000000..3789fd7 Binary files /dev/null and b/bin/visualV2/FrameLogin$3.class differ diff --git a/bin/visualV2/FrameLogin.class b/bin/visualV2/FrameLogin.class new file mode 100644 index 0000000..c6197ac Binary files /dev/null and b/bin/visualV2/FrameLogin.class differ diff --git a/bin/visualV2/FramePrincipal.class b/bin/visualV2/FramePrincipal.class new file mode 100644 index 0000000..19dd311 Binary files /dev/null and b/bin/visualV2/FramePrincipal.class differ diff --git a/bin/visualV2/FrameRegistro$1.class b/bin/visualV2/FrameRegistro$1.class new file mode 100644 index 0000000..27ac858 Binary files /dev/null and b/bin/visualV2/FrameRegistro$1.class differ diff --git a/bin/visualV2/FrameRegistro$2.class b/bin/visualV2/FrameRegistro$2.class new file mode 100644 index 0000000..b2b0ce7 Binary files /dev/null and b/bin/visualV2/FrameRegistro$2.class differ diff --git a/bin/visualV2/FrameRegistro.class b/bin/visualV2/FrameRegistro.class new file mode 100644 index 0000000..8bfa452 Binary files /dev/null and b/bin/visualV2/FrameRegistro.class differ diff --git a/bin/visualV2/JTableTable$1.class b/bin/visualV2/JTableTable$1.class new file mode 100644 index 0000000..8f982ae Binary files /dev/null and b/bin/visualV2/JTableTable$1.class differ diff --git a/bin/visualV2/JTableTable.class b/bin/visualV2/JTableTable.class new file mode 100644 index 0000000..985132f Binary files /dev/null and b/bin/visualV2/JTableTable.class differ diff --git a/bin/visualV2/P.A.M.v2/catola.png b/bin/visualV2/P.A.M.v2/catola.png new file mode 100644 index 0000000..594b23d Binary files /dev/null and b/bin/visualV2/P.A.M.v2/catola.png differ diff --git a/bin/visualV2/P.A.M.v2/logo.png b/bin/visualV2/P.A.M.v2/logo.png new file mode 100644 index 0000000..d52b124 Binary files /dev/null and b/bin/visualV2/P.A.M.v2/logo.png differ diff --git a/bin/visualV2/P.A.M.v2/resumen.png b/bin/visualV2/P.A.M.v2/resumen.png new file mode 100644 index 0000000..520c843 Binary files /dev/null and b/bin/visualV2/P.A.M.v2/resumen.png differ diff --git a/bin/visualV2/PanelCartola$1.class b/bin/visualV2/PanelCartola$1.class new file mode 100644 index 0000000..c7617b5 Binary files /dev/null and b/bin/visualV2/PanelCartola$1.class differ diff --git a/bin/visualV2/PanelCartola$2.class b/bin/visualV2/PanelCartola$2.class new file mode 100644 index 0000000..8a15e1e Binary files /dev/null and b/bin/visualV2/PanelCartola$2.class differ diff --git a/bin/visualV2/PanelCartola$3.class b/bin/visualV2/PanelCartola$3.class new file mode 100644 index 0000000..bd2f2c0 Binary files /dev/null and b/bin/visualV2/PanelCartola$3.class differ diff --git a/bin/visualV2/PanelCartola.class b/bin/visualV2/PanelCartola.class new file mode 100644 index 0000000..dbbc4ef Binary files /dev/null and b/bin/visualV2/PanelCartola.class differ diff --git a/bin/visualV2/PanelResumen$1.class b/bin/visualV2/PanelResumen$1.class new file mode 100644 index 0000000..e9c4fb4 Binary files /dev/null and b/bin/visualV2/PanelResumen$1.class differ diff --git a/bin/visualV2/PanelResumen.class b/bin/visualV2/PanelResumen.class new file mode 100644 index 0000000..f9d6b27 Binary files /dev/null and b/bin/visualV2/PanelResumen.class differ diff --git a/bin/visualV2/PanelSuperior$1.class b/bin/visualV2/PanelSuperior$1.class new file mode 100644 index 0000000..41e005b Binary files /dev/null and b/bin/visualV2/PanelSuperior$1.class differ diff --git a/bin/visualV2/PanelSuperior$2.class b/bin/visualV2/PanelSuperior$2.class new file mode 100644 index 0000000..55076a1 Binary files /dev/null and b/bin/visualV2/PanelSuperior$2.class differ diff --git a/bin/visualV2/PanelSuperior.class b/bin/visualV2/PanelSuperior.class new file mode 100644 index 0000000..d85c186 Binary files /dev/null and b/bin/visualV2/PanelSuperior.class differ diff --git a/src/control/ControlLogin.java b/src/control/ControlLogin.java new file mode 100644 index 0000000..34a754f --- /dev/null +++ b/src/control/ControlLogin.java @@ -0,0 +1,70 @@ +package control; + +import utiles.Archivo; + +public class ControlLogin { + Archivo archivo; + + public ControlLogin() { + + archivo = new Archivo("dataUser"); + } + + public boolean añadirUsuario(String user, String pass, String pass2) { + + if (!isUser(user)) { + if (user.length() > 4) { + if (pass.equals(pass2)) { + if (pass.length() > 6) { + archivo.escribirArchivo(user + ";" + pass); + return true; + } else { + + javax.swing.JOptionPane.showMessageDialog(null, "La contraseña es muy corta", null, + javax.swing.JOptionPane.ERROR_MESSAGE); + return false; + } + } else { + + javax.swing.JOptionPane.showMessageDialog(null, "Las contraseñas no son iguales", null, + javax.swing.JOptionPane.ERROR_MESSAGE); + return false; + } + } else { + + javax.swing.JOptionPane.showMessageDialog(null, "El usuario es muy corto", null, + javax.swing.JOptionPane.ERROR_MESSAGE); + return false; + } + } else { + + javax.swing.JOptionPane.showMessageDialog(null, "El usuario ya existe ", null, + javax.swing.JOptionPane.ERROR_MESSAGE); + return false; + } + } + + public boolean isUser(String user) { + + String[] arch = archivo.entregarProcesado(); + for (int x = 0; x < arch.length; x++) { + if (arch[x].split(";")[0].equals(user)) { + return true; + } + } + + return false; + } + + public boolean isUserPass(String user, String pass) { + + String[] arch = archivo.entregarProcesado(); + for (int x = 0; x < arch.length; x++) { + if (arch[x].split(";")[0].equals(user) && arch[x].split(";")[1].equals(pass)) { + return true; + } + } + + return false; + } +} diff --git a/src/control/ControlPrincipal.java b/src/control/ControlPrincipal.java new file mode 100644 index 0000000..794db26 --- /dev/null +++ b/src/control/ControlPrincipal.java @@ -0,0 +1,342 @@ +package control; + +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; + +import utiles.Archivo; + +public class ControlPrincipal extends Archivo { + + public ControlPrincipal(String usuario) { + + super(usuario); + ordenar(); + actId(); + actSaldos(); + } + + public void añadir(String fecha, String documento, String fd, String desc, String ing, String egr) { + + int id = 1; + int saldo = 0; + + String[] arch = entregarProcesado(); + String[] lastRow = arch[arch.length - 1].split(";"); + if(isFiled()){ + + id = Integer.parseInt(lastRow[0]) + 1; + saldo = Integer.parseInt(lastRow[lastRow.length - 1]) + Integer.parseInt(ing) - Integer.parseInt(egr); + }else{ + + saldo = Integer.parseInt(ing) - Integer.parseInt(egr); + + } + + String fila = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";" + saldo; + + escribirArchivo(fila); + + } + + public void modificarFila(String id, String fecha, String documento, String fd, String desc, String ing, + String egr) { + + String[] arch = entregarProcesado(); + + for (int x = 0; x < arch.length; x++) { + + if (arch[x].split(";")[0].equals(id)) { + + arch[x] = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";" + + "0"; + + } + + } + + actSaldos(); + actArchivo(arch); + } + + public void eliminarFila(String id) { + + borrarLinea(id); + actSaldos(); + + } + + public void ordenar() { + + String[] arch = entregarProcesado(); + + boolean swapped = true; + int j = 0; + String tmp; + + while (swapped) { + + swapped = false; + j++; + + for (int i = 0; i < arch.length - j; i++) { + + Calendar f1 = new GregorianCalendar(Integer.parseInt(arch[i].split(";")[1].split("/")[2]), + Integer.parseInt(arch[i].split(";")[1].split("/")[1]), + Integer.parseInt(arch[i].split(";")[1].split("/")[0])); + Calendar f2 = new GregorianCalendar(Integer.parseInt(arch[i + 1].split(";")[1].split("/")[2]), + Integer.parseInt(arch[i + 1].split(";")[1].split("/")[1]), + Integer.parseInt(arch[i + 1].split(";")[1].split("/")[0])); + + if (f1.after(f2)) { + + tmp = arch[i]; + arch[i] = arch[i + 1]; + arch[i + 1] = tmp; + swapped = true; + + } + + } + + } + actArchivo(arch); + } + + public void actSaldos() { + + String[] arch = entregarProcesado(); + if(isFiled()){ + + for (int x = 0; x < arch.length; x++) { + + int saldoAnterior = 0; + int saldo = 0; + + if (x > 0) { + + String[] aux = arch[x - 1].split(";"); + saldoAnterior = Integer.parseInt(aux[aux.length - 1]); + + } + + String textAux = ""; + String[] aux = arch[x].split(";"); + + if (arch[x].length() > 1) { + + saldo = saldoAnterior + Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]); + + } + + for (int z = 0; z < aux.length - 1; z++) { + + textAux += aux[z] + ";"; + + } + + textAux += saldo; + arch[x] = textAux; + + } + + actArchivo(arch); + + } + + } + + public void actId() { + + String[] arch = entregarProcesado(); + int id = 1; + for (int x = 0; x < arch.length; x++) { + + String[] aux = arch[x].split(";"); + aux[0] = String.valueOf(id); + id++; + + String linea = ""; + for (int z = 0; z < aux.length; z++) { + + linea += aux[z] + ";"; + + } + + arch[x] = linea; + + } + actArchivo(arch); + } + + public String[] getLastRow() { + + String[] arch = entregarProcesado(); + return arch[arch.length - 1].split(";"); + + } + + public String[] getRow(int id) { + + String[] arch = entregarProcesado(); + return arch[id].split(";"); + + } + + public int getRowCount() { + + String[] arch = entregarProcesado(); + return arch.length; + + } + + public boolean isFiled() { + + return (leerArchivo().length() > 5); + + } + + public String[][] resumenMes() { + + String[][] fin = new String[4][1]; + + if (leerArchivo().length() > 5) { + + String[] arch = entregarProcesado(); + ArrayList fechas = new ArrayList(); + ArrayList ings = new ArrayList(); + ArrayList egrs = new ArrayList(); + + for (int x = 0; x < arch.length; x++) { + + String fecha = arch[x].split(";")[1].split("/")[2] + "-" + arch[x].split(";")[1].split("/")[1]; + + if (!fechas.contains(fecha)) { + + fechas.add(fecha); + ings.add("0"); + egrs.add("0"); + + } + + } + + for (int x = 0; x < arch.length; x++) { + + String fecha = arch[x].split(";")[1].split("/")[2] + "-" + arch[x].split(";")[1].split("/")[1]; + String ing = arch[x].split(";")[5]; + String egr = arch[x].split(";")[6]; + int index = fechas.indexOf(fecha); + + ings.set(index, String.valueOf(Integer.parseInt(ings.get(index)) + Integer.parseInt(ing))); + egrs.set(index, String.valueOf(Integer.parseInt(egrs.get(index)) + Integer.parseInt(egr))); + + } + + fin = new String[4][fechas.size()]; + + for (int x = 0; x < fechas.size(); x++) { + + fin[0][x] = fechas.get(x); + fin[1][x] = String.valueOf(Integer.parseInt(ings.get(x)) - Integer.parseInt(egrs.get(x))); + fin[2][x] = ings.get(x); + fin[3][x] = egrs.get(x); + + } + + fin = ordenarSaldos(fin); + + } + + return fin; + + } + + public String[][] ordenarSaldos(String[][] saldos) { + + boolean swapped = true; + int j = 0; + String tmp; + String tmp1; + String tmp2; + String tmp3; + + while (swapped) { + + swapped = false; + j++; + + for (int i = 0; i < saldos[0].length - j; i++) { + + YearMonth f1 = YearMonth.parse(saldos[0][i]); + YearMonth f2 = YearMonth.parse(saldos[0][i + 1]); + + if (f1.isAfter(f2)) { + + tmp = saldos[0][i]; + tmp1 = saldos[1][i]; + tmp2 = saldos[2][i]; + tmp3 = saldos[3][i]; + + saldos[0][i] = saldos[0][i + 1]; + saldos[1][i] = saldos[1][i + 1]; + saldos[2][i] = saldos[2][i + 1]; + saldos[3][i] = saldos[3][i + 1]; + + saldos[0][i + 1] = tmp; + saldos[1][i + 1] = tmp1; + saldos[2][i + 1] = tmp2; + saldos[3][i + 1] = tmp3; + + swapped = true; + + } + + } + + } + + return saldos; + + } + + public int[] resumenDoc() { + + String[] arch = entregarProcesado(); + int[] docs = { 0, 0, 0 }; + + if (leerArchivo().length() > 5) { + + for (int x = 0; x < arch.length; x++) { + + String[] aux = arch[x].split(";"); + + switch (aux[2]) { + + case "Efectivo": + + docs[0] += Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]); + break; + + case "Transferencia": + + docs[1] += Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]); + break; + + case "Credito": + + docs[2] += Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]); + break; + + } + + } + + } + + return docs; + + } + +} diff --git a/src/main/Main.java b/src/main/Main.java index 5021064..13a2cd1 100644 --- a/src/main/Main.java +++ b/src/main/Main.java @@ -2,6 +2,6 @@ package main; public class Main { public static void main(String[] args) { - visual.FrameLogin login = new visual.FrameLogin(); + visualV2.FrameLogin login = new visualV2.FrameLogin(); } } diff --git a/src/utiles/Archivo.java b/src/utiles/Archivo.java index cc7b3a0..b6d56f9 100644 --- a/src/utiles/Archivo.java +++ b/src/utiles/Archivo.java @@ -14,10 +14,14 @@ public class Archivo { protected FileWriter fw; public Archivo(String archivo) { + + String ruta = getRuta(archivo); + try { this.archivo = new File(ruta); if (!this.archivo.exists()) { + this.archivo.createNewFile(); } } catch (Exception e) { @@ -25,6 +29,7 @@ public class Archivo { } public String getRuta(String archivo) { + String ruta = ""; String os = System.getProperty("os.name"); if (os.contains("Windows")) { @@ -40,6 +45,7 @@ public class Archivo { } public String leerArchivo() { + abrirLeer(); String cadena = ""; String cadenaFinal = ""; @@ -48,23 +54,25 @@ public class Archivo { cadenaFinal += cadena; } } catch (IOException e) { - System.out.println("Error en br.readLine()"); + } cerrarLeer(); return cadenaFinal; } public void escribirArchivo(String texto) { + abrirEscribir(); try { fw.append(texto + "*!"); } catch (IOException e) { - System.out.println("Error en fw.write(texto)"); + } cerrarEscribir(); } public String[] entregarProcesado() { + String[] datos; datos = leerArchivo().split("\\*!"); return datos; @@ -73,40 +81,40 @@ public class Archivo { public void borrarLinea(String id) { String[] arch = entregarProcesado(); - - if(arch.length > 1){ - + + if (arch.length > 1) { + for (int x = 0; x < arch.length; x++) { - + if (arch[x].split(";")[0].equals(id)) { - + arch[x] = ""; break; - + } - + } - + String[] nArch = new String[arch.length - 1]; int z = 0; - + for (int x = 0; x < arch.length; x++) { - + if (arch[x].length() > 1) { - + nArch[z] = arch[x]; z++; - + } - + } - + actArchivo(nArch); - - }else{ - + + } else { + clearFile(); - + } } @@ -128,7 +136,7 @@ public class Archivo { fw.write(""); fw.close(); } catch (IOException e) { - System.out.println("Error al instanciar FileWriter"); + } } @@ -136,7 +144,7 @@ public class Archivo { try { fr = new FileReader(archivo); } catch (FileNotFoundException e) { - System.out.println("Error al instanciar FileReader"); + } br = new BufferedReader(fr); } @@ -145,12 +153,12 @@ public class Archivo { try { fr.close(); } catch (IOException e) { - System.out.println("Error en fr.close()"); + } try { br.close(); } catch (IOException e) { - System.out.println("Error en br.close()"); + } } @@ -158,7 +166,7 @@ public class Archivo { try { fw = new FileWriter(archivo, true); } catch (IOException e) { - System.out.println("Error al instanciar FileWriter"); + } } @@ -167,7 +175,7 @@ public class Archivo { try { fw.close(); } catch (IOException e) { - System.out.println("No deberia ocurrir, pero weno\nError en fw.close()"); + } } } diff --git a/src/utiles/Cifrador.java b/src/utiles/Cifrador.java index d782ef2..114be03 100755 --- a/src/utiles/Cifrador.java +++ b/src/utiles/Cifrador.java @@ -33,7 +33,7 @@ public class Cifrador { byte[] mensajeCifrado = cipher.doFinal(mensajeSinCifrar); return codificarBase64(mensajeCifrado); } catch (Exception e) { - System.out.println("Error en el cifrado"); + e.printStackTrace(); } return null; @@ -60,7 +60,7 @@ public class Cifrador { try { return new BASE64Decoder().decodeBuffer(cadena); } catch (IOException ex) { - System.out.println("Error con la decodificacion en base64"); + ex.printStackTrace(); } return null; diff --git a/src/utiles/Validador.java b/src/utiles/Validador.java index 83a0b0c..45d8701 100644 --- a/src/utiles/Validador.java +++ b/src/utiles/Validador.java @@ -1,10 +1,12 @@ package utiles; public class Validador { - + public static boolean isNumber(String num) { - - return (num.matches("\\d")); - + + boolean isNumber = num.matches("^[1-9]?[0-9]+"); + + return (isNumber); + } } diff --git a/src/visualV2/FrameLogin.java b/src/visualV2/FrameLogin.java new file mode 100644 index 0000000..113424d --- /dev/null +++ b/src/visualV2/FrameLogin.java @@ -0,0 +1,206 @@ +package visualV2; + +import java.awt.event.*; +import javax.swing.*; + +import control.ControlLogin; + +public class FrameLogin extends JFrame { + + private javax.swing.JButton bIngresar; + private javax.swing.JButton bRegistrar; + private javax.swing.JButton bSalir; + private javax.swing.JPanel bar; + private javax.swing.JLabel bienvenido; + private javax.swing.JPasswordField fContraseña1; + private javax.swing.JTextField fUsuario; + private javax.swing.JLabel lContraseña; + private javax.swing.JLabel lUsuario; + private javax.swing.JLabel pam; + private javax.swing.JPanel panel; + + public FrameLogin() { + initComponents(); + } + + private void initComponents() { + + panel = new javax.swing.JPanel(); + pam = new javax.swing.JLabel(); + bienvenido = new javax.swing.JLabel(); + bar = new javax.swing.JPanel(); + lUsuario = new javax.swing.JLabel(); + fUsuario = new javax.swing.JTextField(); + lContraseña = new javax.swing.JLabel(); + fContraseña1 = new javax.swing.JPasswordField(); + bIngresar = new javax.swing.JButton(); + bRegistrar = new javax.swing.JButton(); + bSalir = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setBackground(new java.awt.Color(21, 21, 21)); + setMaximumSize(null); + setMinimumSize(null); + + panel.setBackground(new java.awt.Color(0, 128, 128)); + + pam.setFont(new java.awt.Font("Candara", 1, 60)); // NOI18N + pam.setForeground(new java.awt.Color(255, 255, 255)); + pam.setText("P.A.M"); + + bienvenido.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + bienvenido.setForeground(new java.awt.Color(255, 255, 255)); + bienvenido.setText(" Bienvenido de nuevo "); + + bar.setBackground(new java.awt.Color(255, 255, 255)); + bar.setPreferredSize(new java.awt.Dimension(215, 2)); + + javax.swing.GroupLayout barLayout = new javax.swing.GroupLayout(bar); + bar.setLayout(barLayout); + barLayout.setHorizontalGroup( + barLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 251, Short.MAX_VALUE) + ); + barLayout.setVerticalGroup( + barLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 9, Short.MAX_VALUE) + ); + + lUsuario.setBackground(new java.awt.Color(0, 204, 204)); + lUsuario.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + lUsuario.setForeground(new java.awt.Color(255, 255, 255)); + lUsuario.setText("Usuario"); + lContraseña.setBackground(new java.awt.Color(0, 204, 204)); + lContraseña.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + lContraseña.setForeground(new java.awt.Color(255, 255, 255)); + lContraseña.setText("Contraseña"); + + bIngresar.setText("Ingresar"); + bIngresar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bIngresarActionPerformed(evt); + } + }); + + bRegistrar.setText("Registrarse"); + bRegistrar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bRegistrarActionPerformed(evt); + } + }); + + bSalir.setText("Salir"); + bSalir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bSalirActionPerformed(evt); + } + }); + + + javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel); + panel.setLayout(panelLayout); + panelLayout.setHorizontalGroup( + panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup() + .addGap(95, 95, 95) + .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(bar, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(pam) + .addComponent(bRegistrar) + .addComponent(bienvenido) + .addComponent(bIngresar, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(bSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(fUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lUsuario) + .addComponent(lContraseña) + .addComponent(fContraseña1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(94, Short.MAX_VALUE)) + ); + panelLayout.setVerticalGroup( + panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup() + .addGap(29, 29, 29) + .addComponent(pam, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(bienvenido, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bar, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(13, 13, 13) + .addComponent(lUsuario) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lContraseña) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fContraseña1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(bIngresar) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bRegistrar) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bSalir) + .addContainerGap(17, Short.MAX_VALUE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException + | UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } + + getRootPane().setDefaultButton(bIngresar); + setUndecorated(true); + pack(); + setVisible(true); + setLocationRelativeTo(null); + + } + + private void bIngresarActionPerformed(ActionEvent evt) { + + + ControlLogin control = new ControlLogin(); + + if (control.isUserPass(fUsuario.getText(), String.valueOf(fContraseña1.getPassword()))) { + + FramePrincipal principal = new FramePrincipal(fUsuario.getText()); + + dispose(); + + } else { + + JOptionPane.showMessageDialog(null, "Usuario o contraseña incorrectas", null, JOptionPane.ERROR_MESSAGE); + + } + + } + + private void bSalirActionPerformed(ActionEvent evt) { + + + System.exit(0); + + } + + private void bRegistrarActionPerformed(ActionEvent evt) { + + FrameRegistro registro = new FrameRegistro(); + + dispose(); + } + + + +} diff --git a/src/visualV2/FramePrincipal.java b/src/visualV2/FramePrincipal.java new file mode 100644 index 0000000..2e632e6 --- /dev/null +++ b/src/visualV2/FramePrincipal.java @@ -0,0 +1,91 @@ +package visualV2; + +import javax.swing.*; +import java.awt.*; + +public class FramePrincipal extends JFrame { + + private JPanel panelCard; + private PanelCartola panelCartola; + private PanelResumen panelResumen; + private PanelSuperior panelSuperior; + private JPanel separador; + private String usuario; + + public FramePrincipal(String usuario) { + this.usuario = usuario; + initComponents(); + + } + + private void initComponents() { + + panelSuperior = new PanelSuperior(usuario); + panelCard = new JPanel(); + panelCartola = new PanelCartola(usuario); + panelResumen = new PanelResumen(usuario); + separador = new JPanel(); + + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + getContentPane().setBackground(new Color(0, 128, 128)); + + separador.setBackground(new Color(255, 255, 255)); + + panelCard.setLayout(new CardLayout()); + panelCard.add(panelCartola, "cartola"); + panelCard.add(panelResumen, "resumen"); + + javax.swing.GroupLayout separadorLayout = new javax.swing.GroupLayout(separador); + separador.setLayout(separadorLayout); + separadorLayout.setHorizontalGroup(separadorLayout + .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1001, Short.MAX_VALUE)); + separadorLayout.setVerticalGroup(separadorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 11, Short.MAX_VALUE)); + + GroupLayout layout = new GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(panelSuperior, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent(panelCard, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(separador, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); + layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(panelSuperior, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(separador, javax.swing.GroupLayout.PREFERRED_SIZE, + javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0).addComponent(panelCard, javax.swing.GroupLayout.PREFERRED_SIZE, 524, + javax.swing.GroupLayout.PREFERRED_SIZE))); + + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException + | UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } + + pack(); + setVisible(true); + } + + public void toCartola() { + + panelCartola.getTabla().actTabla(); + CardLayout cardLayout = (CardLayout) panelCard.getLayout(); + cardLayout.show(panelCard, "cartola"); + } + + public void toResumen() { + panelResumen.llenarResumen(); + CardLayout cardLayout = (CardLayout) panelCard.getLayout(); + cardLayout.show(panelCard, "resumen"); + + } +} diff --git a/src/visualV2/FrameRegistro.java b/src/visualV2/FrameRegistro.java new file mode 100644 index 0000000..5f31cf4 --- /dev/null +++ b/src/visualV2/FrameRegistro.java @@ -0,0 +1,188 @@ +package visualV2; + +import java.awt.event.*; +import javax.swing.*; + +import control.ControlLogin; + +public class FrameRegistro extends JFrame { + + private javax.swing.JButton bRegistrarse; + private javax.swing.JButton bSalir; + private javax.swing.JPanel bar; + private javax.swing.JLabel bienvenido; + private javax.swing.JPasswordField fContraseña; + private javax.swing.JTextField fUsuario; + private javax.swing.JPasswordField fVerificar; + private javax.swing.JLabel lContraseña; + private javax.swing.JLabel lUsuario; + private javax.swing.JLabel lVerificiar; + private javax.swing.JLabel pam; + private javax.swing.JPanel panel; + + public FrameRegistro() { + initComponents(); + } + + private void initComponents() { + + panel = new javax.swing.JPanel(); + pam = new javax.swing.JLabel(); + bienvenido = new javax.swing.JLabel(); + bar = new javax.swing.JPanel(); + lUsuario = new javax.swing.JLabel(); + fUsuario = new javax.swing.JTextField(); + lContraseña = new javax.swing.JLabel(); + fContraseña = new javax.swing.JPasswordField(); + bRegistrarse = new javax.swing.JButton(); + bSalir = new javax.swing.JButton(); + fVerificar = new javax.swing.JPasswordField(); + lVerificiar = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setBackground(new java.awt.Color(21, 21, 21)); + setMinimumSize(null); + + panel.setBackground(new java.awt.Color(0, 128, 128)); + + pam.setFont(new java.awt.Font("Candara", 1, 60)); // NOI18N + pam.setForeground(new java.awt.Color(255, 255, 255)); + pam.setText("P.A.M"); + + bienvenido.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + bienvenido.setForeground(new java.awt.Color(255, 255, 255)); + bienvenido.setText(" Bienvenido de nuevo "); + + bar.setBackground(new java.awt.Color(255, 255, 255)); + bar.setPreferredSize(new java.awt.Dimension(215, 2)); + + javax.swing.GroupLayout barLayout = new javax.swing.GroupLayout(bar); + bar.setLayout(barLayout); + barLayout.setHorizontalGroup(barLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, + 251, Short.MAX_VALUE)); + barLayout.setVerticalGroup( + barLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 9, Short.MAX_VALUE)); + + lUsuario.setBackground(new java.awt.Color(0, 204, 204)); + lUsuario.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + lUsuario.setForeground(new java.awt.Color(255, 255, 255)); + lUsuario.setText("Usuario"); + + lContraseña.setBackground(new java.awt.Color(0, 204, 204)); + lContraseña.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + lContraseña.setForeground(new java.awt.Color(255, 255, 255)); + lContraseña.setText("Contraseña"); + + bRegistrarse.setText("Registrarse"); + bRegistrarse.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bRegistrarseActionPerformed(evt); + } + }); + + bSalir.setText("Salir"); + bSalir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + bSalirActionPerformed(evt); + } + }); + + lVerificiar.setBackground(new java.awt.Color(0, 204, 204)); + lVerificiar.setFont(new java.awt.Font("Candara", 1, 18)); // NOI18N + lVerificiar.setForeground(new java.awt.Color(255, 255, 255)); + lVerificiar.setText("Verificar Contraseña"); + + javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel); + panel.setLayout(panelLayout); + panelLayout.setHorizontalGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, + panelLayout.createSequentialGroup().addGap(140, 140, 140) + .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(bar, javax.swing.GroupLayout.PREFERRED_SIZE, 251, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lUsuario) + .addComponent(fUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 161, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lContraseña) + .addComponent(fContraseña, javax.swing.GroupLayout.PREFERRED_SIZE, 161, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(bRegistrarse, javax.swing.GroupLayout.PREFERRED_SIZE, 87, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(bSalir, javax.swing.GroupLayout.PREFERRED_SIZE, 65, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(fVerificar, javax.swing.GroupLayout.PREFERRED_SIZE, 161, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(pam).addComponent(lVerificiar).addComponent(bienvenido)) + .addGap(140, 140, 140))); + panelLayout.setVerticalGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup().addGap(27, 27, 27) + .addComponent(pam, javax.swing.GroupLayout.PREFERRED_SIZE, 52, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(1, 1, 1) + .addComponent(bienvenido, javax.swing.GroupLayout.PREFERRED_SIZE, 35, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bar, javax.swing.GroupLayout.PREFERRED_SIZE, 9, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(lUsuario) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 31, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(lContraseña) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fContraseña, javax.swing.GroupLayout.PREFERRED_SIZE, 30, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(lVerificiar) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, + javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(fVerificar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, + javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(28, 28, 28).addComponent(bRegistrarse) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(bSalir) + .addGap(31, 31, 31))); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( + panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( + panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException + | UnsupportedLookAndFeelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + setUndecorated(true); + pack(); + getRootPane().setDefaultButton(bRegistrarse); + setVisible(true); + setLocationRelativeTo(null); + + } + + protected void bRegistrarseActionPerformed(ActionEvent evt) { + + + + ControlLogin control = new ControlLogin(); + if (control.añadirUsuario(fUsuario.getText(), String.valueOf(fContraseña.getPassword()), + String.valueOf(fVerificar.getPassword()))) { + FrameLogin login = new FrameLogin(); + + dispose(); + }else{ + } + + } + + private void bSalirActionPerformed(ActionEvent evt) { + + FrameLogin login = new FrameLogin(); + + dispose(); + } +} diff --git a/src/visualV2/JTableTable.java b/src/visualV2/JTableTable.java new file mode 100644 index 0000000..72f0e14 --- /dev/null +++ b/src/visualV2/JTableTable.java @@ -0,0 +1,71 @@ +package visualV2; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; + +import control.ControlPrincipal; + +public class JTableTable extends JTable{ + + String usuario; + + public JTableTable(String usuario){ + + this.usuario = usuario; + iniciar(); + + } + private void iniciar(){ + + setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + setBackground(new Color(178, 223, 219)); + setFont(new Font("Candara", 0, 13)); // NOI18N + setForeground(new Color(21, 21, 21)); + setModel(new DefaultTableModel( + new Object [][] { + {null, null, null, null, null, null, null, null} + }, + new String [] { + "N°", "Fecha", "Documento", "Fuente/Destino", "Descripcion", "Ingreso", "Egreso", "Saldo" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false, false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + setGridColor(new Color(255, 255, 255)); + setOpaque(false); + setSelectionForeground(new Color(255, 255, 255)); + actTabla(); + } + + public void actTabla() { + + ControlPrincipal control = new ControlPrincipal(usuario); + DefaultTableModel modelo = (DefaultTableModel) getModel(); + + setModel(modelo); + modelo.setRowCount(0); + + if (control.isFiled()) { + + for (int x = 0; x < control.getRowCount(); x++) { + + Object[] fila = control.getRow(x); + modelo.addRow(fila); + + } + + } + + } + +} diff --git a/src/visualV2/P.A.M.v2/catola.png b/src/visualV2/P.A.M.v2/catola.png new file mode 100644 index 0000000..594b23d Binary files /dev/null and b/src/visualV2/P.A.M.v2/catola.png differ diff --git a/src/visualV2/P.A.M.v2/logo.png b/src/visualV2/P.A.M.v2/logo.png new file mode 100644 index 0000000..d52b124 Binary files /dev/null and b/src/visualV2/P.A.M.v2/logo.png differ diff --git a/src/visualV2/P.A.M.v2/resumen.png b/src/visualV2/P.A.M.v2/resumen.png new file mode 100644 index 0000000..520c843 Binary files /dev/null and b/src/visualV2/P.A.M.v2/resumen.png differ diff --git a/src/visualV2/PanelCartola.java b/src/visualV2/PanelCartola.java new file mode 100644 index 0000000..fc04a31 --- /dev/null +++ b/src/visualV2/PanelCartola.java @@ -0,0 +1,468 @@ +package visualV2; + +import javax.swing.*; +import org.jdesktop.swingx.*; + +import control.ControlPrincipal; +import utiles.Validador; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +public class PanelCartola extends JPanel { + + private JButton bAñadir; + private JButton bEliminar; + private JButton bModificar; + private JComboBox boxDocumento1; + private JComboBox boxDocumento2; + private JXDatePicker dateFecha1; + private JXDatePicker dateFecha2; + private JTextField fDesc1; + private JTextField fDesc2; + private JTextField fEgr1; + private JTextField fEgr2; + private JTextField fFD1; + private JTextField fFD2; + private JTextField fIng1; + private JTextField fIng2; + private JTextField fNumero; + private JScrollPane jScrollPane1; + private JLabel lDesc1; + private JLabel lDesc2; + private JLabel lDocumento1; + private JLabel lDocumento2; + private JLabel lEgr1; + private JLabel lEgr2; + private JLabel lFD1; + private JLabel lFD2; + private JLabel lFecha1; + private JLabel lFecha2; + private JLabel lIng1; + private JLabel lIng2; + private JLabel lNumero; + private JTableTable tabla; + private String usuario; + + public PanelCartola(String usuario) { + this.usuario = usuario; + initComponents(); + } + + private void initComponents() { + + lFecha1 = new JLabel(); + lDocumento1 = new JLabel(); + boxDocumento1 = new JComboBox<>(); + lFD1 = new JLabel(); + fFD1 = new JTextField(); + fDesc1 = new JTextField(); + lDesc1 = new JLabel(); + lIng1 = new JLabel(); + fIng1 = new JTextField(); + fEgr1 = new JTextField(); + lEgr1 = new JLabel(); + jScrollPane1 = new JScrollPane(); + tabla = new JTableTable(usuario); + bAñadir = new JButton(); + bEliminar = new JButton(); + lFD2 = new JLabel(); + fFD2 = new JTextField(); + bModificar = new JButton(); + fDesc2 = new JTextField(); + lDesc2 = new JLabel(); + lIng2 = new JLabel(); + fIng2 = new JTextField(); + fEgr2 = new JTextField(); + lFecha2 = new JLabel(); + lEgr2 = new JLabel(); + lDocumento2 = new JLabel(); + boxDocumento2 = new JComboBox<>(); + fNumero = new JTextField(); + lNumero = new JLabel(); + dateFecha1 = new JXDatePicker(); + dateFecha2 = new JXDatePicker(); + + setBackground(new Color(0, 128, 128)); + + lFecha1.setBackground(new Color(0, 204, 204)); + lFecha1.setFont(new Font("Candara", 1, 14)); // NOI18N + lFecha1.setForeground(new Color(255, 255, 255)); + lFecha1.setText("Fecha:"); + + lDocumento1.setBackground(new Color(0, 204, 204)); + lDocumento1.setFont(new Font("Candara", 1, 14)); // NOI18N + lDocumento1.setForeground(new Color(255, 255, 255)); + lDocumento1.setText("Documento:"); + + boxDocumento1.setForeground(new Color(21, 21, 21)); + boxDocumento1.setModel(new DefaultComboBoxModel<>(new String[] { "Credito", "Efectivo", "Transferencia" })); + + lFD1.setBackground(new Color(0, 204, 204)); + lFD1.setFont(new Font("Candara", 1, 14)); // NOI18N + lFD1.setForeground(new Color(255, 255, 255)); + lFD1.setText("Fuente/Destino:"); + + fFD1.setToolTipText(""); + + lDesc1.setBackground(new Color(0, 204, 204)); + lDesc1.setFont(new Font("Candara", 1, 14)); // NOI18N + lDesc1.setForeground(new Color(255, 255, 255)); + lDesc1.setText("Descripcion:"); + + lIng1.setBackground(new Color(0, 204, 204)); + lIng1.setFont(new Font("Candara", 1, 14)); // NOI18N + lIng1.setForeground(new Color(255, 255, 255)); + lIng1.setText("Ingreso:"); + + lEgr1.setBackground(new Color(0, 204, 204)); + lEgr1.setFont(new Font("Candara", 1, 14)); // NOI18N + lEgr1.setForeground(new Color(255, 255, 255)); + lEgr1.setText("Egreso:"); + + jScrollPane1.setBackground(new Color(128, 203, 196)); + + jScrollPane1.setViewportView(tabla); + if (tabla.getColumnModel().getColumnCount() > 0) { + tabla.getColumnModel().getColumn(4).setPreferredWidth(150); + } + + bAñadir.setBackground(new Color(0, 188, 212)); + bAñadir.setText("Añadir"); + bAñadir.setContentAreaFilled(false); + bAñadir.setOpaque(true); + bAñadir.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + + añadirActionPerformed(evt); + + } + + }); + + bEliminar.setBackground(new Color(0, 188, 212)); + bEliminar.setText("Eliminar Fila Seleccionada"); + bEliminar.setContentAreaFilled(false); + bEliminar.setOpaque(true); + bEliminar.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + + eliminarActionPerformed(evt); + + } + + }); + + lFD2.setBackground(new Color(0, 204, 204)); + lFD2.setFont(new Font("Candara", 1, 14)); // NOI18N + lFD2.setForeground(new Color(255, 255, 255)); + lFD2.setText("Fuente/Destino:"); + + fFD2.setToolTipText(""); + + bModificar.setBackground(new Color(0, 188, 212)); + bModificar.setText("Modificar Fila"); + bModificar.setContentAreaFilled(false); + bModificar.setOpaque(true); + bModificar.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + + modificarActionPerformed(evt); + + } + + }); + + Calendar today = Calendar.getInstance(); + + dateFecha1.setDate(today.getTime()); + dateFecha2.setDate(today.getTime()); + + lDesc2.setBackground(new Color(0, 204, 204)); + lDesc2.setFont(new Font("Candara", 1, 14)); // NOI18N + lDesc2.setForeground(new Color(255, 255, 255)); + lDesc2.setText("Descripcion:"); + + lIng2.setBackground(new Color(0, 204, 204)); + lIng2.setFont(new Font("Candara", 1, 14)); // NOI18N + lIng2.setForeground(new Color(255, 255, 255)); + lIng2.setText("Ingreso:"); + + lFecha2.setBackground(new Color(0, 204, 204)); + lFecha2.setFont(new Font("Candara", 1, 14)); // NOI18N + lFecha2.setForeground(new Color(255, 255, 255)); + lFecha2.setText("Fecha:"); + + lEgr2.setBackground(new Color(0, 204, 204)); + lEgr2.setFont(new Font("Candara", 1, 14)); // NOI18N + lEgr2.setForeground(new Color(255, 255, 255)); + lEgr2.setText("Egreso:"); + + lDocumento2.setBackground(new Color(0, 204, 204)); + lDocumento2.setFont(new Font("Candara", 1, 14)); // NOI18N + lDocumento2.setForeground(new Color(255, 255, 255)); + lDocumento2.setText("Documento:"); + + boxDocumento2.setForeground(new Color(21, 21, 21)); + boxDocumento2.setModel(new DefaultComboBoxModel<>(new String[] { "Credito", "Efectivo", "Transferencia" })); + + fNumero.setToolTipText(""); + + lNumero.setBackground(new Color(0, 204, 204)); + lNumero.setFont(new Font("Candara", 1, 14)); // NOI18N + lNumero.setForeground(new Color(255, 255, 255)); + lNumero.setText("Nº"); + + GroupLayout layout = new GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, + layout.createSequentialGroup().addContainerGap() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 888, Short.MAX_VALUE) + .addGroup( + layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) + .addComponent(bEliminar))) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout + .createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lFD2, GroupLayout.Alignment.TRAILING) + .addComponent(lEgr2, GroupLayout.Alignment.TRAILING) + .addComponent(lIng2, GroupLayout.Alignment.TRAILING) + .addComponent(lDesc2, GroupLayout.Alignment.TRAILING) + .addComponent(lDocumento2, + GroupLayout.Alignment.TRAILING) + .addComponent(lFecha2, + GroupLayout.Alignment.TRAILING)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout + .createParallelGroup(GroupLayout.Alignment.LEADING, false) + .addComponent(boxDocumento2, 0, GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent(fFD2).addComponent(fDesc2).addComponent(fIng2) + .addComponent(fEgr2, GroupLayout.PREFERRED_SIZE, 170, + GroupLayout.PREFERRED_SIZE) + .addComponent(bModificar)) + .addComponent(dateFecha2, GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(GroupLayout.Alignment.TRAILING, + layout.createSequentialGroup().addComponent(lNumero) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fNumero, GroupLayout.PREFERRED_SIZE, 170, + GroupLayout.PREFERRED_SIZE)) + .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lFD1, GroupLayout.Alignment.TRAILING) + .addComponent(lEgr1, GroupLayout.Alignment.TRAILING) + .addComponent(lIng1, GroupLayout.Alignment.TRAILING) + .addComponent(lDesc1, GroupLayout.Alignment.TRAILING) + .addComponent(lDocumento1, GroupLayout.Alignment.TRAILING) + .addComponent(lFecha1, GroupLayout.Alignment.TRAILING)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout + .createParallelGroup(GroupLayout.Alignment.LEADING, false) + .addComponent(boxDocumento1, 0, GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE) + .addComponent(fFD1).addComponent(fDesc1).addComponent(fIng1) + .addComponent(fEgr1, GroupLayout.DEFAULT_SIZE, 170, + Short.MAX_VALUE) + .addComponent(bAñadir, GroupLayout.PREFERRED_SIZE, 96, + GroupLayout.PREFERRED_SIZE) + .addComponent(dateFecha1, GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addContainerGap())); + layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout + .createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addGroup( + layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane1, + GroupLayout.PREFERRED_SIZE, 470, GroupLayout.PREFERRED_SIZE)) + .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup().addGap(38, 38, 38) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lFecha1).addComponent(dateFecha1, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lDocumento1).addComponent(boxDocumento1, + GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(lFD1) + .addComponent(fFD1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lDesc1).addComponent(fDesc1, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(lIng1) + .addComponent(fIng1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(fEgr1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(lEgr1)) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(bAñadir) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lNumero).addComponent(fNumero, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lFecha2).addComponent(dateFecha2, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lDocumento2).addComponent(boxDocumento2, + GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(lFD2) + .addComponent(fFD2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lDesc2).addComponent(fDesc2, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(lIng2) + .addComponent(fIng2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(fEgr2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(lEgr2)) + .addGap(11, 11, 11).addComponent(bModificar))) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(bEliminar) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); + + } + + public JTableTable getTabla() { + + return tabla; + + } + + private void añadirActionPerformed(ActionEvent evt) { + + ControlPrincipal control = new ControlPrincipal(usuario); + SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); + String fecha = formateador.format(dateFecha1.getDate()); + String documento = this.boxDocumento1.getSelectedItem().toString(); + + String fD = fFD1.getText(); + fFD1.setText(""); + + String desc = fDesc1.getText(); + fDesc1.setText(""); + + String ing = fIng1.getText(); + if (ing.equals("")) { + ing = "0"; + } else if (ing.matches("^0")) { + + ing.replaceFirst("0", ""); + + } else if (!Validador.isNumber(ing)) { + JOptionPane.showMessageDialog(null, "Ingreso ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); + } + fIng1.setText("0"); + + String egr = fEgr1.getText(); + if (egr.equals("")) { + egr = "0"; + } else if (ing.startsWith("0")) { + + ing.replaceFirst("0", ""); + + } else if (!Validador.isNumber(egr)) { + JOptionPane.showMessageDialog(null, "Egreso ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); + } + fEgr1.setText("0"); + + control.añadir(fecha, documento, fD, desc, ing, egr); + + tabla.actTabla(); + + } + + private void eliminarActionPerformed(ActionEvent evt) { + + ControlPrincipal control = new ControlPrincipal(usuario); + + if (tabla.getSelectedRow() != -1) { + + control.eliminarFila((String) tabla.getValueAt(tabla.getSelectedRow(), 0)); + + tabla.actTabla(); + + } + + } + + private void modificarActionPerformed(ActionEvent evt) { + + if (!fNumero.getText().equals("")) { + + String number = fNumero.getText(); + + SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); + String fecha = formateador.format(dateFecha2.getDate()); + + String documento = boxDocumento2.getSelectedItem().toString(); + String fD = fFD2.getText(); + String desc = fDesc2.getText(); + String ing = fIng2.getText(); + if (ing.equals("")) { + + ing = "0"; + + } else if (ing.startsWith("0")) { + + ing.replaceFirst("0", ""); + + } else if (!Validador.isNumber(ing)) { + + JOptionPane.showMessageDialog(null, "Dato ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); + + } + String egr = fEgr2.getText(); + if (egr.equals("")) { + + egr = "0"; + + } else if (ing.startsWith("0")) { + + ing.replaceFirst("0", ""); + + } else if (!Validador.isNumber(egr)) { + + JOptionPane.showMessageDialog(null, "Dato ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); + + } + + ControlPrincipal control = new ControlPrincipal(usuario); + + control.modificarFila(number, fecha, documento, fD, desc, ing, egr); + + tabla.actTabla(); + + } else { + + JOptionPane.showMessageDialog(null, "No se ingreso el Nº"); + + } + + } +} diff --git a/src/visualV2/PanelResumen.java b/src/visualV2/PanelResumen.java new file mode 100644 index 0000000..00a2a20 --- /dev/null +++ b/src/visualV2/PanelResumen.java @@ -0,0 +1,542 @@ +package visualV2; + +import javax.swing.*; +import javax.swing.border.Border; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.StandardBarPainter; +import org.jfree.data.category.DefaultCategoryDataset; + +import control.ControlPrincipal; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +public class PanelResumen extends JPanel { + + private JLabel balance; + private JComboBox boxGraph; + private ArrayList egresos; + private ArrayList ingresos; + private ArrayList saldos; + private ArrayList meses; + private ChartPanel graphDocumento; + private ChartPanel graphMes; + private JLabel lEgr; + private JLabel lIng; + private JLabel lSaldo; + private JPanel panelGraphs; + private JLabel selectGraph; + private Border borde; + private String usuario; + + private DefaultCategoryDataset dataSetMes; + private DefaultCategoryDataset dataSetDoc; + + public PanelResumen(String usuario) { + this.usuario = usuario; + initComponents(); + } + + private void initComponents() { + + iniciarTextFieldYLabel(); + lSaldo = new JLabel(); + balance = new JLabel(); + lIng = new JLabel(); + lEgr = new JLabel(); + selectGraph = new JLabel(); + boxGraph = new JComboBox<>(); + panelGraphs = new JPanel(); + graphMes = crearGraphMes(); + graphDocumento = crearGraphDoc(); + + setBackground(new Color(0, 128, 128)); + + lSaldo.setFont(new Font("Candara", 1, 14)); // NOI18N + lSaldo.setForeground(new Color(255, 255, 255)); + lSaldo.setText("Saldo"); + + balance.setFont(new Font("Candara", 1, 36)); // NOI18N + balance.setForeground(new Color(255, 255, 255)); + balance.setText("Balance Mensual"); + + lIng.setFont(new Font("Candara", 1, 14)); // NOI18N + lIng.setForeground(new Color(255, 255, 255)); + lIng.setText("Ingresos"); + + lEgr.setFont(new Font("Candara", 1, 14)); // NOI18N + lEgr.setForeground(new Color(255, 255, 255)); + lEgr.setText("Egresos"); + + selectGraph.setFont(new Font("Candara", 1, 14)); // NOI18N + selectGraph.setForeground(new Color(255, 255, 255)); + selectGraph.setText("Seleccionar Grafico:"); + + boxGraph.setBackground(new Color(178, 223, 219)); + boxGraph.setModel(new DefaultComboBoxModel<>(new String[] { "Mes", "Documento" })); + boxGraph.setOpaque(false); + boxGraph.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + + comboActionPerformed(evt); + + } + + }); + + panelGraphs.setBackground(new Color(51, 51, 51)); + panelGraphs.setLayout(new CardLayout()); + + graphMes.setBackground(new Color(255, 255, 51)); + + GroupLayout graphMesLayout = new GroupLayout(graphMes); + graphMes.setLayout(graphMesLayout); + graphMesLayout.setHorizontalGroup( + graphMesLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); + graphMesLayout.setVerticalGroup( + graphMesLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); + + panelGraphs.add(graphMes, "Mes"); + + graphDocumento.setBackground(new Color(255, 51, 51)); + + GroupLayout graphDocumentoLayout = new GroupLayout(graphDocumento); + graphDocumento.setLayout(graphDocumentoLayout); + graphDocumentoLayout.setHorizontalGroup(graphDocumentoLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGap(0, 700, Short.MAX_VALUE)); + graphDocumentoLayout.setVerticalGroup(graphDocumentoLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGap(0, 465, Short.MAX_VALUE)); + + panelGraphs.add(graphDocumento, "Documento"); + + GroupLayout layout = new GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup().addContainerGap() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lEgr, GroupLayout.Alignment.TRAILING) + .addComponent(lSaldo, GroupLayout.Alignment.TRAILING) + .addComponent(lIng, GroupLayout.Alignment.TRAILING)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(balance, GroupLayout.PREFERRED_SIZE, 310, + GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(saldos.get(0), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(egresos.get(0), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(ingresos.get(0), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(meses.get(0))) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(saldos.get(1), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(egresos.get(1), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(ingresos.get(1), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(meses.get(1))) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(saldos.get(2), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(egresos.get(2), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(ingresos.get(2), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(meses.get(2))) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(saldos.get(3), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(egresos.get(3), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(ingresos.get(3), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(meses.get(3))) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(saldos.get(4), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(meses.get(4)) + .addComponent(egresos.get(4), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE) + .addComponent(ingresos.get(4), GroupLayout.PREFERRED_SIZE, 63, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) + .addComponent(meses.get(5)) + .addComponent(saldos.get(5), GroupLayout.DEFAULT_SIZE, 63, + Short.MAX_VALUE) + .addComponent(egresos.get(5)).addComponent(ingresos.get(5))))) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup().addComponent(selectGraph) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(boxGraph, GroupLayout.PREFERRED_SIZE, 119, + GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(panelGraphs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, + Short.MAX_VALUE)) + .addContainerGap())); + layout.setVerticalGroup(layout.createParallelGroup( + GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout + .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup() + .addComponent(balance, GroupLayout.PREFERRED_SIZE, 52, GroupLayout.PREFERRED_SIZE) + .addGap(19, 19, 19).addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(lIng).addPreferredGap( + LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lEgr).addGap(26, 26, 26)) + .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(meses.get(0)).addComponent(meses.get(1)) + .addComponent(meses.get(2)).addComponent(meses.get(3)) + .addComponent(meses.get(4)).addComponent(meses.get(5))) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(ingresos.get(0), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(egresos.get(0), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout + .createParallelGroup( + GroupLayout.Alignment.BASELINE) + .addComponent(saldos.get(0), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(lSaldo))) + .addGroup(layout.createSequentialGroup() + .addComponent(ingresos.get(1), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(egresos.get(1), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(saldos.get(1), GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(ingresos.get(2), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(egresos.get(2), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(saldos.get(2), GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(ingresos.get(3), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(egresos.get(3), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(saldos.get(3), GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup().addGroup(layout + .createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(ingresos.get(4), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(ingresos.get(5), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout + .createParallelGroup( + GroupLayout.Alignment.BASELINE) + .addComponent(egresos.get(4), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(egresos.get(5), + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(saldos.get(4), GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup().addGap(52, 52, 52) + .addComponent(saldos.get(5), GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE))))) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(panelGraphs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup( + layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(boxGraph, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(selectGraph)) + .addGap(19, 19, 19))); + + } + + private void comboActionPerformed(ActionEvent evt) { + + CardLayout cardLayout = (CardLayout) panelGraphs.getLayout(); + cardLayout.show(panelGraphs, (String) boxGraph.getSelectedItem()); + + } + + public void iniciarTextFieldYLabel() { + + ingresos = new ArrayList(); + egresos = new ArrayList(); + saldos = new ArrayList(); + meses = new ArrayList(); + + for (int x = 0; x < 6; x++) { + + ingresos.add(new JTextField()); + egresos.add(new JTextField()); + saldos.add(new JTextField()); + ingresos.get(x).setBackground(new Color(178, 223, 219)); + ingresos.get(x).setEditable(false); + egresos.get(x).setBackground(new Color(178, 223, 219)); + egresos.get(x).setEditable(false); + saldos.get(x).setBackground(new Color(178, 223, 219)); + saldos.get(x).setEditable(false); + meses.add(new JLabel()); + meses.get(x).setFont(new Font("Candara", 1, 14)); // NOI18N + meses.get(x).setForeground(new Color(255, 255, 255)); + + } + + hideTextFieldsYLabels(); + } + + private void hideTextFieldsYLabels() { + + borde = ingresos.get(0).getBorder(); + + for (int x = 0; x < 6; x++) { + + meses.get(x).setText(""); + + ingresos.get(x).setOpaque(false); + ingresos.get(x).setText(""); + + egresos.get(x).setOpaque(false); + egresos.get(x).setText(""); + + saldos.get(x).setOpaque(false); + saldos.get(x).setText(""); + + ingresos.get(x).setBorder(javax.swing.BorderFactory.createEmptyBorder()); + egresos.get(x).setBorder(javax.swing.BorderFactory.createEmptyBorder()); + saldos.get(x).setBorder(javax.swing.BorderFactory.createEmptyBorder()); + + } + + } + + public void llenarResumen() { + + ControlPrincipal control = new ControlPrincipal(usuario); + + hideTextFieldsYLabels(); + actualizarGraphDoc(); + actualizarGraphMes(); + + String[][] resumen = control.resumenMes(); + + if (resumen[0][0] != null) { + + for (int x = resumen[0].length - 1, z = 0; x > resumen[0].length - 7 && x >= 0; x--, z++) { + + ingresos.get(z).setText(resumen[2][x]); + ingresos.get(z).setBorder(borde); + ingresos.get(z).setOpaque(true); + + egresos.get(z).setText(resumen[3][x]); + egresos.get(z).setBorder(borde); + egresos.get(z).setOpaque(true); + + saldos.get(z).setText(resumen[1][x]); + saldos.get(z).setBorder(borde); + saldos.get(z).setOpaque(true); + + if (resumen[0][x].matches("[0-9]{4}-01")) { + + meses.get(z).setText("Enero"); + + } else if (resumen[0][x].matches("[0-9]{4}-02")) { + + meses.get(z).setText("Febrero"); + + } else if (resumen[0][x].matches("[0-9]{4}-03")) { + + meses.get(z).setText("Marzo"); + + } else if (resumen[0][x].matches("[0-9]{4}-04")) { + + meses.get(z).setText("Abril"); + + } else if (resumen[0][x].matches("[0-9]{4}-05")) { + + meses.get(z).setText("Mayo"); + + } else if (resumen[0][x].matches("[0-9]{4}-06")) { + + meses.get(z).setText("Junio"); + + } else if (resumen[0][x].matches("[0-9]{4}-07")) { + + meses.get(z).setText("Julio"); + + } else if (resumen[0][x].matches("[0-9]{4}-08")) { + + meses.get(z).setText("Agosto"); + + } else if (resumen[0][x].matches("[0-9]{4}-09")) { + + meses.get(z).setText("Septiembre"); + + } else if (resumen[0][x].matches("[0-9]{4}-10")) { + + meses.get(z).setText("Octubre"); + + } else if (resumen[0][x].matches("[0-9]{4}-11")) { + + meses.get(z).setText("Noviembre"); + + } else if (resumen[0][x].matches("[0-9]{4}-12")) { + + meses.get(z).setText("Diciembre"); + + } + } + + } + + } + + private ChartPanel crearGraphMes() { + + ControlPrincipal control = new ControlPrincipal(usuario); + + String[][] resumen = control.resumenMes(); + + dataSetMes = new DefaultCategoryDataset(); + + JFreeChart chart = ChartFactory.createBarChart("Resumen Mensual", "Mes", "Saldo", dataSetMes, + PlotOrientation.VERTICAL, false, true, false); + + CategoryPlot plot = chart.getCategoryPlot(); + BarRenderer renderer = (BarRenderer) plot.getRenderer(); + ValueAxis axis = plot.getRangeAxis(); + axis.setTickLabelPaint(new Color(0,0,0)); + CategoryAxis domain = plot.getDomainAxis(); + domain.setTickLabelPaint(new Color(0,0,0)); + renderer.setGradientPaintTransformer(null); + renderer.setBarPainter(new StandardBarPainter()); + plot.setBackgroundPaint(new Color(0,103, 103)); + renderer.setSeriesPaint(0, new Color(0,205,205)); + chart.setBackgroundPaint(new Color(0, 128, 128 )); + + ChartPanel graph = new ChartPanel(chart); + + return graph; + + } + + private ChartPanel crearGraphDoc() { + + ControlPrincipal control = new ControlPrincipal(usuario); + + int[] resumen = control.resumenDoc(); + + dataSetDoc = new DefaultCategoryDataset(); + JFreeChart chart = ChartFactory.createBarChart("Resumen por Documentos", "Documento", "Saldo", dataSetDoc, + PlotOrientation.VERTICAL, false, true, false); + + CategoryPlot plot = chart.getCategoryPlot(); + BarRenderer renderer = (BarRenderer) plot.getRenderer(); + ValueAxis axis = plot.getRangeAxis(); + axis.setTickLabelPaint(new Color(0,0,0)); + CategoryAxis domain = plot.getDomainAxis(); + domain.setTickLabelPaint(new Color(0,0,0)); + renderer.setGradientPaintTransformer(null); + renderer.setBarPainter(new StandardBarPainter()); + plot.setBackgroundPaint(new Color(0,103, 103)); + renderer.setSeriesPaint(0, new Color(0,205,205)); + chart.setBackgroundPaint(new Color(0, 128, 128 )); + + ChartPanel graph = new ChartPanel(chart); + + return graph; + } + + private void actualizarGraphMes() { + + dataSetMes.clear(); + + ControlPrincipal control = new ControlPrincipal(usuario); + String[][] resumen = control.resumenMes(); + + if (resumen[0][0] != null) { + + for (int x = 0; x < resumen[0].length; x++) { + + dataSetMes.setValue(Integer.parseInt(resumen[1][x]), "Saldo", resumen[0][x]); + } + + } + + } + + private void actualizarGraphDoc() { + + ControlPrincipal control = new ControlPrincipal(usuario); + + dataSetDoc.clear(); + + int[] resumen = control.resumenDoc(); + + dataSetDoc.setValue(resumen[0], "Saldo", "Efectivo"); + dataSetDoc.setValue(resumen[1], "Saldo", "Transferencia"); + dataSetDoc.setValue(resumen[2], "Saldo", "Credito"); + + } +} diff --git a/src/visualV2/PanelSuperior.java b/src/visualV2/PanelSuperior.java new file mode 100644 index 0000000..e09533c --- /dev/null +++ b/src/visualV2/PanelSuperior.java @@ -0,0 +1,150 @@ +package visualV2; + +import javax.swing.*; + +import java.awt.event.*; +import java.util.Calendar; +import java.awt.*; + +public class PanelSuperior extends JPanel { + + private JButton bCartola; + private JButton bResumen; + + private JTextField fFecha; + private JTextField fUsuario; + + private JLabel lFecha; + private JLabel lUsuario; + private JLabel logo; + + private String usuario; + + public PanelSuperior(String usuario) { + + this.usuario = usuario; + initComponents(); + } + + private void initComponents() { + + + logo = new JLabel(); + lUsuario = new JLabel(); + fUsuario = new JTextField(); + lFecha = new JLabel(); + fFecha = new JTextField(); + bResumen = new JButton(); + bCartola = new JButton(); + + setBackground(new Color(0, 128, 128)); + + logo.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/logo.png"))); // NOI18N + + lUsuario.setFont(new Font("Candara", 1, 14)); // NOI18N + lUsuario.setForeground(new Color(255, 255, 255)); + lUsuario.setText("Usuario:"); + + fUsuario.setBackground(new Color(178, 223, 219)); + fUsuario.setEnabled(false); + fUsuario.setText(usuario); + + lFecha.setFont(new Font("Candara", 1, 14)); // NOI18N + lFecha.setForeground(new Color(255, 255, 255)); + lFecha.setText("Fecha:"); + + Calendar hoy = Calendar.getInstance(); + fFecha.setBackground(new Color(178, 223, 219)); + fFecha.setEnabled(false); + fFecha.setText((String.valueOf(hoy.get(Calendar.DATE)) + "/" + String.valueOf(hoy.get(Calendar.MONTH)+1) + "/" + + String.valueOf(hoy.get(Calendar.YEAR)))); + + bResumen.setBackground(new Color(0, 188, 212)); + bResumen.setText("Resumen"); + bResumen.setBorder(BorderFactory.createTitledBorder("")); + bResumen.setContentAreaFilled(false); + bResumen.setOpaque(true); + bResumen.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + bResumenActionPerformed(evt); + } + }); + + bCartola.setBackground(new Color(0, 188, 212)); + bCartola.setText("Cartola"); + bCartola.setBorder(BorderFactory.createTitledBorder("")); + bCartola.setContentAreaFilled(false); + bCartola.setOpaque(true); + bCartola.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + bCartolaActionPerformed(evt); + } + }); + + GroupLayout layout = new GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(logo) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(lUsuario) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)) + .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(lFecha) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fFecha, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGap(333, 333, 333) + .addComponent(bCartola, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bResumen, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE) + .addContainerGap(473, Short.MAX_VALUE)))) + ); + layout.setVerticalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addComponent(lUsuario)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lFecha) + .addComponent(fFecha, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addGap(9, 9, 9) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(bResumen, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE) + .addComponent(bCartola, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(logo, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE) + ); + + + } + + private void bResumenActionPerformed(ActionEvent evt) { + + + + FramePrincipal parent = (FramePrincipal) SwingUtilities.getWindowAncestor(this); + parent.toResumen(); + + } + + private void bCartolaActionPerformed(ActionEvent evt) { + + + + FramePrincipal parent = (FramePrincipal) SwingUtilities.getWindowAncestor(this); + parent.toCartola(); + + } +}