diff --git a/bin/.directory b/bin/.directory deleted file mode 100644 index a281b3d..0000000 --- a/bin/.directory +++ /dev/null @@ -1,3 +0,0 @@ -[Dolphin] -Timestamp=2016,10,31,23,7,53 -Version=3 diff --git a/bin/control/ControlAdmin.class b/bin/control/ControlAdmin.class new file mode 100644 index 0000000..910e91f Binary files /dev/null and b/bin/control/ControlAdmin.class differ diff --git a/bin/control/ControlLogin.class b/bin/control/ControlLogin.class index 9df1d14..549da67 100644 Binary files a/bin/control/ControlLogin.class and b/bin/control/ControlLogin.class differ diff --git a/bin/control/ControlPrincipal.class b/bin/control/ControlPrincipal.class index 399cccf..c0b86bd 100644 Binary files a/bin/control/ControlPrincipal.class and b/bin/control/ControlPrincipal.class differ diff --git a/bin/utiles/Archivo.class b/bin/utiles/Archivo.class index c2caf3d..fb8c621 100644 Binary files a/bin/utiles/Archivo.class and b/bin/utiles/Archivo.class differ diff --git a/bin/utiles/ControlLogin.class b/bin/utiles/ControlLogin.class deleted file mode 100644 index 83f67e3..0000000 Binary files a/bin/utiles/ControlLogin.class and /dev/null differ diff --git a/bin/utiles/ControlPrincipal.class b/bin/utiles/ControlPrincipal.class deleted file mode 100644 index f2136ce..0000000 Binary files a/bin/utiles/ControlPrincipal.class and /dev/null differ diff --git a/bin/visual/FrameLogin$1.class b/bin/visual/FrameLogin$1.class deleted file mode 100644 index c650891..0000000 Binary files a/bin/visual/FrameLogin$1.class and /dev/null differ diff --git a/bin/visual/FrameLogin$2.class b/bin/visual/FrameLogin$2.class deleted file mode 100644 index 99c83ee..0000000 Binary files a/bin/visual/FrameLogin$2.class and /dev/null differ diff --git a/bin/visual/FrameLogin$3.class b/bin/visual/FrameLogin$3.class deleted file mode 100644 index 7b0103e..0000000 Binary files a/bin/visual/FrameLogin$3.class and /dev/null differ diff --git a/bin/visual/FrameLogin.class b/bin/visual/FrameLogin.class deleted file mode 100644 index c9efe21..0000000 Binary files a/bin/visual/FrameLogin.class and /dev/null differ diff --git a/bin/visual/FramePrincipal.class b/bin/visual/FramePrincipal.class deleted file mode 100644 index 47de43b..0000000 Binary files a/bin/visual/FramePrincipal.class and /dev/null differ diff --git a/bin/visual/FrameRegistro$1.class b/bin/visual/FrameRegistro$1.class deleted file mode 100644 index f821652..0000000 Binary files a/bin/visual/FrameRegistro$1.class and /dev/null differ diff --git a/bin/visual/FrameRegistro$2.class b/bin/visual/FrameRegistro$2.class deleted file mode 100644 index d2662cb..0000000 Binary files a/bin/visual/FrameRegistro$2.class and /dev/null differ diff --git a/bin/visual/FrameRegistro.class b/bin/visual/FrameRegistro.class deleted file mode 100644 index 99f7bbf..0000000 Binary files a/bin/visual/FrameRegistro.class and /dev/null differ diff --git a/bin/visual/JTableTable$1.class b/bin/visual/JTableTable$1.class deleted file mode 100644 index 1e9df4a..0000000 Binary files a/bin/visual/JTableTable$1.class and /dev/null differ diff --git a/bin/visual/JTableTable.class b/bin/visual/JTableTable.class deleted file mode 100644 index 8c0e8c5..0000000 Binary files a/bin/visual/JTableTable.class and /dev/null differ diff --git a/bin/visual/Login$1.class b/bin/visual/Login$1.class deleted file mode 100644 index 980ac78..0000000 Binary files a/bin/visual/Login$1.class and /dev/null differ diff --git a/bin/visual/Login$2.class b/bin/visual/Login$2.class deleted file mode 100644 index 49bc54a..0000000 Binary files a/bin/visual/Login$2.class and /dev/null differ diff --git a/bin/visual/Login$3.class b/bin/visual/Login$3.class deleted file mode 100644 index d260eda..0000000 Binary files a/bin/visual/Login$3.class and /dev/null differ diff --git a/bin/visual/Login.class b/bin/visual/Login.class deleted file mode 100644 index 8f2e045..0000000 Binary files a/bin/visual/Login.class and /dev/null differ diff --git a/bin/visual/P.A.M.v2/catola.png b/bin/visual/P.A.M.v2/catola.png deleted file mode 100644 index 594b23d..0000000 Binary files a/bin/visual/P.A.M.v2/catola.png and /dev/null differ diff --git a/bin/visual/P.A.M.v2/logo.png b/bin/visual/P.A.M.v2/logo.png deleted file mode 100644 index d52b124..0000000 Binary files a/bin/visual/P.A.M.v2/logo.png and /dev/null differ diff --git a/bin/visual/P.A.M.v2/resumen.png b/bin/visual/P.A.M.v2/resumen.png deleted file mode 100644 index 520c843..0000000 Binary files a/bin/visual/P.A.M.v2/resumen.png and /dev/null differ diff --git a/bin/visual/PanelCartola$1.class b/bin/visual/PanelCartola$1.class deleted file mode 100644 index ff298b1..0000000 Binary files a/bin/visual/PanelCartola$1.class and /dev/null differ diff --git a/bin/visual/PanelCartola$2.class b/bin/visual/PanelCartola$2.class deleted file mode 100644 index 44357b0..0000000 Binary files a/bin/visual/PanelCartola$2.class and /dev/null differ diff --git a/bin/visual/PanelCartola$3.class b/bin/visual/PanelCartola$3.class deleted file mode 100644 index 37e20e0..0000000 Binary files a/bin/visual/PanelCartola$3.class and /dev/null differ diff --git a/bin/visual/PanelCartola$4.class b/bin/visual/PanelCartola$4.class deleted file mode 100644 index f9961a4..0000000 Binary files a/bin/visual/PanelCartola$4.class and /dev/null differ diff --git a/bin/visual/PanelCartola$5.class b/bin/visual/PanelCartola$5.class deleted file mode 100644 index a3f028b..0000000 Binary files a/bin/visual/PanelCartola$5.class and /dev/null differ diff --git a/bin/visual/PanelCartola.class b/bin/visual/PanelCartola.class deleted file mode 100644 index 008deaf..0000000 Binary files a/bin/visual/PanelCartola.class and /dev/null differ diff --git a/bin/visual/PanelPrincipal$1.class b/bin/visual/PanelPrincipal$1.class deleted file mode 100644 index 76cf310..0000000 Binary files a/bin/visual/PanelPrincipal$1.class and /dev/null differ diff --git a/bin/visual/PanelPrincipal$2.class b/bin/visual/PanelPrincipal$2.class deleted file mode 100644 index f362161..0000000 Binary files a/bin/visual/PanelPrincipal$2.class and /dev/null differ diff --git a/bin/visual/PanelPrincipal.class b/bin/visual/PanelPrincipal.class deleted file mode 100644 index c9b0475..0000000 Binary files a/bin/visual/PanelPrincipal.class and /dev/null differ diff --git a/bin/visual/PanelResumen$1.class b/bin/visual/PanelResumen$1.class deleted file mode 100644 index 1b245a5..0000000 Binary files a/bin/visual/PanelResumen$1.class and /dev/null differ diff --git a/bin/visual/PanelResumen.class b/bin/visual/PanelResumen.class deleted file mode 100644 index 3b02a87..0000000 Binary files a/bin/visual/PanelResumen.class and /dev/null differ diff --git a/bin/visual/Principal$1.class b/bin/visual/Principal$1.class deleted file mode 100644 index 29ffff7..0000000 Binary files a/bin/visual/Principal$1.class and /dev/null differ diff --git a/bin/visual/Principal$2.class b/bin/visual/Principal$2.class deleted file mode 100644 index 7a9792f..0000000 Binary files a/bin/visual/Principal$2.class and /dev/null differ diff --git a/bin/visual/Principal$3.class b/bin/visual/Principal$3.class deleted file mode 100644 index a54c183..0000000 Binary files a/bin/visual/Principal$3.class and /dev/null differ diff --git a/bin/visual/Principal$4.class b/bin/visual/Principal$4.class deleted file mode 100644 index 5d92c4b..0000000 Binary files a/bin/visual/Principal$4.class and /dev/null differ diff --git a/bin/visual/Principal$5.class b/bin/visual/Principal$5.class deleted file mode 100644 index 2e3767c..0000000 Binary files a/bin/visual/Principal$5.class and /dev/null differ diff --git a/bin/visual/Principal$6.class b/bin/visual/Principal$6.class deleted file mode 100644 index 65e869a..0000000 Binary files a/bin/visual/Principal$6.class and /dev/null differ diff --git a/bin/visual/Principal$7.class b/bin/visual/Principal$7.class deleted file mode 100644 index b7439e0..0000000 Binary files a/bin/visual/Principal$7.class and /dev/null differ diff --git a/bin/visual/Principal.class b/bin/visual/Principal.class deleted file mode 100644 index 06ad91f..0000000 Binary files a/bin/visual/Principal.class and /dev/null differ diff --git a/bin/visual/Registro$1.class b/bin/visual/Registro$1.class deleted file mode 100644 index 375fc5b..0000000 Binary files a/bin/visual/Registro$1.class and /dev/null differ diff --git a/bin/visual/Registro$2.class b/bin/visual/Registro$2.class deleted file mode 100644 index 3767648..0000000 Binary files a/bin/visual/Registro$2.class and /dev/null differ diff --git a/bin/visual/Registro.class b/bin/visual/Registro.class deleted file mode 100644 index b14a104..0000000 Binary files a/bin/visual/Registro.class and /dev/null differ diff --git a/bin/visualV2/FrameAdministrador$1.class b/bin/visualV2/FrameAdministrador$1.class new file mode 100644 index 0000000..267ed44 Binary files /dev/null and b/bin/visualV2/FrameAdministrador$1.class differ diff --git a/bin/visualV2/FrameAdministrador$2.class b/bin/visualV2/FrameAdministrador$2.class new file mode 100644 index 0000000..99ccbe5 Binary files /dev/null and b/bin/visualV2/FrameAdministrador$2.class differ diff --git a/bin/visualV2/FrameAdministrador$3.class b/bin/visualV2/FrameAdministrador$3.class new file mode 100644 index 0000000..c438b63 Binary files /dev/null and b/bin/visualV2/FrameAdministrador$3.class differ diff --git a/bin/visualV2/FrameAdministrador$4.class b/bin/visualV2/FrameAdministrador$4.class new file mode 100644 index 0000000..6d4b788 Binary files /dev/null and b/bin/visualV2/FrameAdministrador$4.class differ diff --git a/bin/visualV2/FrameAdministrador.class b/bin/visualV2/FrameAdministrador.class new file mode 100644 index 0000000..93af99f Binary files /dev/null and b/bin/visualV2/FrameAdministrador.class differ diff --git a/bin/visualV2/FrameCrear$1.class b/bin/visualV2/FrameCrear$1.class new file mode 100644 index 0000000..2d50e57 Binary files /dev/null and b/bin/visualV2/FrameCrear$1.class differ diff --git a/bin/visualV2/FrameCrear.class b/bin/visualV2/FrameCrear.class new file mode 100644 index 0000000..3a70818 Binary files /dev/null and b/bin/visualV2/FrameCrear.class differ diff --git a/bin/visualV2/FrameLogin$1.class b/bin/visualV2/FrameLogin$1.class index bc4a4d5..d9b7924 100644 Binary files a/bin/visualV2/FrameLogin$1.class and b/bin/visualV2/FrameLogin$1.class differ diff --git a/bin/visualV2/FrameLogin$2.class b/bin/visualV2/FrameLogin$2.class index a568299..b0fa6b5 100644 Binary files a/bin/visualV2/FrameLogin$2.class and b/bin/visualV2/FrameLogin$2.class differ diff --git a/bin/visualV2/FrameLogin$3.class b/bin/visualV2/FrameLogin$3.class index 3789fd7..08d7bac 100644 Binary files a/bin/visualV2/FrameLogin$3.class and b/bin/visualV2/FrameLogin$3.class differ diff --git a/bin/visualV2/FrameLogin$4.class b/bin/visualV2/FrameLogin$4.class new file mode 100644 index 0000000..eee8eca Binary files /dev/null and b/bin/visualV2/FrameLogin$4.class differ diff --git a/bin/visualV2/FrameLogin.class b/bin/visualV2/FrameLogin.class index c6197ac..2eb41aa 100644 Binary files a/bin/visualV2/FrameLogin.class and b/bin/visualV2/FrameLogin.class differ diff --git a/bin/visualV2/FrameModificar$1.class b/bin/visualV2/FrameModificar$1.class new file mode 100644 index 0000000..3854792 Binary files /dev/null and b/bin/visualV2/FrameModificar$1.class differ diff --git a/bin/visualV2/FrameModificar$2.class b/bin/visualV2/FrameModificar$2.class new file mode 100644 index 0000000..7f50689 Binary files /dev/null and b/bin/visualV2/FrameModificar$2.class differ diff --git a/bin/visualV2/FrameModificar$3.class b/bin/visualV2/FrameModificar$3.class new file mode 100644 index 0000000..25e0b71 Binary files /dev/null and b/bin/visualV2/FrameModificar$3.class differ diff --git a/bin/visualV2/FrameModificar.class b/bin/visualV2/FrameModificar.class new file mode 100644 index 0000000..66b7301 Binary files /dev/null and b/bin/visualV2/FrameModificar.class differ diff --git a/bin/visualV2/FramePrincipal.class b/bin/visualV2/FramePrincipal.class index 19dd311..1fcdcc2 100644 Binary files a/bin/visualV2/FramePrincipal.class and b/bin/visualV2/FramePrincipal.class differ diff --git a/src/control/ControlAdmin.java b/src/control/ControlAdmin.java new file mode 100644 index 0000000..256999f --- /dev/null +++ b/src/control/ControlAdmin.java @@ -0,0 +1,89 @@ +package control; + +import utiles.Archivo; + +public class ControlAdmin { + + Archivo archivo; + + public ControlAdmin() { + archivo = new Archivo("UserData"); + } + + public int getRowCount() { + + String[] arch = archivo.entregarProcesado(); + return arch.length; + + } + + public String[] getRow(int id) { + + String[] arch = archivo.entregarProcesado(); + return arch[id].split(";"); + + } + + public boolean añadirUsuario(String user, String pass) { + + if (!isUser(user)) { + if (user.length() > 4) { + 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, "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 modificarUser(String original, String user, String pass) { + + if (user.length() > 4) { + if (pass.length() > 6) { + archivo.modificarLinea(original, user + ";" + pass); + Archivo.changeName(user, original.split(";")[0]); + 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, "El usuario es muy corto", null, + javax.swing.JOptionPane.ERROR_MESSAGE); + return false; + } + + } +} diff --git a/src/control/ControlLogin.java b/src/control/ControlLogin.java index 34a754f..ba1dd85 100644 --- a/src/control/ControlLogin.java +++ b/src/control/ControlLogin.java @@ -7,7 +7,7 @@ public class ControlLogin { public ControlLogin() { - archivo = new Archivo("dataUser"); + archivo = new Archivo("UserData"); } public boolean añadirUsuario(String user, String pass, String pass2) { diff --git a/src/control/ControlPrincipal.java b/src/control/ControlPrincipal.java index 794db26..2707b27 100644 --- a/src/control/ControlPrincipal.java +++ b/src/control/ControlPrincipal.java @@ -7,11 +7,11 @@ import java.util.GregorianCalendar; import utiles.Archivo; -public class ControlPrincipal extends Archivo { - +public class ControlPrincipal{ + Archivo archivo; public ControlPrincipal(String usuario) { - super(usuario); + archivo = new Archivo(usuario); ordenar(); actId(); actSaldos(); @@ -22,7 +22,7 @@ public class ControlPrincipal extends Archivo { int id = 1; int saldo = 0; - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); String[] lastRow = arch[arch.length - 1].split(";"); if(isFiled()){ @@ -36,14 +36,14 @@ public class ControlPrincipal extends Archivo { String fila = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";" + saldo; - escribirArchivo(fila); + archivo.escribirArchivo(fila); } public void modificarFila(String id, String fecha, String documento, String fd, String desc, String ing, String egr) { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); for (int x = 0; x < arch.length; x++) { @@ -57,19 +57,19 @@ public class ControlPrincipal extends Archivo { } actSaldos(); - actArchivo(arch); + archivo.actArchivo(arch); } public void eliminarFila(String id) { - borrarLinea(id); + archivo.borrarLinea(id); actSaldos(); } public void ordenar() { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); boolean swapped = true; int j = 0; @@ -101,12 +101,12 @@ public class ControlPrincipal extends Archivo { } } - actArchivo(arch); + archivo.actArchivo(arch); } public void actSaldos() { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); if(isFiled()){ for (int x = 0; x < arch.length; x++) { @@ -141,7 +141,7 @@ public class ControlPrincipal extends Archivo { } - actArchivo(arch); + archivo.actArchivo(arch); } @@ -149,7 +149,7 @@ public class ControlPrincipal extends Archivo { public void actId() { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); int id = 1; for (int x = 0; x < arch.length; x++) { @@ -167,33 +167,33 @@ public class ControlPrincipal extends Archivo { arch[x] = linea; } - actArchivo(arch); + archivo.actArchivo(arch); } public String[] getLastRow() { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); return arch[arch.length - 1].split(";"); } public String[] getRow(int id) { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); return arch[id].split(";"); } public int getRowCount() { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); return arch.length; } public boolean isFiled() { - return (leerArchivo().length() > 5); + return (archivo.leerArchivo().length() > 5); } @@ -201,9 +201,9 @@ public class ControlPrincipal extends Archivo { String[][] fin = new String[4][1]; - if (leerArchivo().length() > 5) { + if (archivo.leerArchivo().length() > 5) { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); ArrayList fechas = new ArrayList(); ArrayList ings = new ArrayList(); ArrayList egrs = new ArrayList(); @@ -303,10 +303,10 @@ public class ControlPrincipal extends Archivo { public int[] resumenDoc() { - String[] arch = entregarProcesado(); + String[] arch = archivo.entregarProcesado(); int[] docs = { 0, 0, 0 }; - if (leerArchivo().length() > 5) { + if (archivo.leerArchivo().length() > 5) { for (int x = 0; x < arch.length; x++) { diff --git a/src/utiles/Archivo.java b/src/utiles/Archivo.java index b6d56f9..67dbc52 100644 --- a/src/utiles/Archivo.java +++ b/src/utiles/Archivo.java @@ -15,7 +15,6 @@ public class Archivo { public Archivo(String archivo) { - String ruta = getRuta(archivo); try { @@ -27,8 +26,17 @@ public class Archivo { } catch (Exception e) { } } + + public static void changeName(String nuevo, String old){ + + File oldArch = new File(getRuta(old)); + File newArch = new File(getRuta(nuevo)); + + oldArch.renameTo(newArch); + + } - public String getRuta(String archivo) { + public static String getRuta(String archivo) { String ruta = ""; String os = System.getProperty("os.name"); @@ -139,6 +147,21 @@ public class Archivo { } } + + public void modificarLinea(String linea, String nueva){ + + abrirEscribir(); + String[] arch = entregarProcesado(); + for(int x = 0; x < arch.length; x++){ + if(arch[x].equals(linea)){ + arch[x] = nueva; + break; + } + } + actArchivo(arch); + cerrarEscribir(); + + } private void abrirLeer() { try { diff --git a/src/utiles/ControlLogin.java b/src/utiles/ControlLogin.java deleted file mode 100644 index 89a903d..0000000 --- a/src/utiles/ControlLogin.java +++ /dev/null @@ -1,56 +0,0 @@ -package utiles; - -public class ControlLogin extends Archivo { - public ControlLogin() { - super("userData"); - } - - 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) { - 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 = 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 = 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/utiles/ControlPrincipal.java b/src/utiles/ControlPrincipal.java deleted file mode 100644 index 4098791..0000000 --- a/src/utiles/ControlPrincipal.java +++ /dev/null @@ -1,340 +0,0 @@ -package utiles; - -import java.time.YearMonth; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.GregorianCalendar; - -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/visual/FrameLogin.java b/src/visual/FrameLogin.java deleted file mode 100644 index fb86fa6..0000000 --- a/src/visual/FrameLogin.java +++ /dev/null @@ -1,169 +0,0 @@ -package visual; - -import java.awt.event.*; -import javax.swing.*; -import utiles.ControlLogin; - -public class FrameLogin extends JFrame { - - private JButton bIngresar; - private JButton bRegistrar; - private JButton bSalir; - private JPanel bar; - private JLabel bienvenido; - private JPasswordField fContraseña1; - private JTextField fUsuario; - private JLabel lContraseña; - private JLabel lUsuario; - private JLabel pam; - - public FrameLogin() { - initComponents(); - } - - private void initComponents() { - - bienvenido = new JLabel(); - bIngresar = new JButton(); - bSalir = new JButton(); - fUsuario = new JTextField(); - lUsuario = new JLabel(); - lContraseña = new JLabel(); - fContraseña1 = new JPasswordField(); - bar = new JPanel(); - pam = new JLabel(); - bRegistrar = new JButton(); - - setResizable(false); - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - getContentPane().setBackground(new java.awt.Color(21, 21, 21)); - - bienvenido.setFont(new java.awt.Font("Eras Light ITC", 0, 18)); // NOI18N - bienvenido.setForeground(new java.awt.Color(255, 255, 255)); - bienvenido.setText(" Bienvenido de nuevo "); - - bIngresar.setText("Ingresar"); - bIngresar.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bIngresarActionPerformed(evt); - } - }); - - bSalir.setText("Salir"); - bSalir.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bSalirActionPerformed(evt); - } - }); - - lUsuario.setFont(new java.awt.Font("Eras Light ITC", 0, 18)); // NOI18N - lUsuario.setForeground(new java.awt.Color(0, 204, 204)); - lUsuario.setText(" Usuario"); - - lContraseña.setFont(new java.awt.Font("Eras Light ITC", 0, 18)); // NOI18N - lContraseña.setForeground(new java.awt.Color(0, 204, 204)); - lContraseña.setText(" Contraseña"); - - bar.setBackground(new java.awt.Color(0, 204, 204)); - bar.setPreferredSize(new java.awt.Dimension(215, 2)); - - GroupLayout barLayout = new GroupLayout(bar); - bar.setLayout(barLayout); - barLayout.setHorizontalGroup( - barLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 251, Short.MAX_VALUE)); - barLayout.setVerticalGroup( - barLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 9, Short.MAX_VALUE)); - - pam.setFont(new java.awt.Font("Eras Light ITC", 2, 60)); // NOI18N - pam.setForeground(new java.awt.Color(0, 204, 204)); - pam.setText(" P.A.M"); - - bRegistrar.setText("Registrarse"); - bRegistrar.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bRegistrarActionPerformed(evt); - } - }); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout - .createSequentialGroup().addGap(147, 147, 147) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(bar, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 251, - GroupLayout.PREFERRED_SIZE) - .addComponent(bienvenido, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 251, - GroupLayout.PREFERRED_SIZE) - .addComponent(pam, GroupLayout.Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 251, - GroupLayout.PREFERRED_SIZE) - .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout - .createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(layout.createSequentialGroup().addComponent(bRegistrar).addGap(30, 30, 30)) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) - .addComponent(fUsuario, GroupLayout.Alignment.LEADING) - .addComponent(fContraseña1, GroupLayout.Alignment.LEADING) - .addComponent(lContraseña, GroupLayout.Alignment.LEADING, - GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(lUsuario, GroupLayout.Alignment.LEADING, - GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addComponent(bIngresar, GroupLayout.PREFERRED_SIZE, 90, - GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(bSalir, GroupLayout.PREFERRED_SIZE, 65, - GroupLayout.PREFERRED_SIZE)))) - .addGap(47, 47, 47))) - .addContainerGap(150, Short.MAX_VALUE))); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup().addContainerGap(16, Short.MAX_VALUE).addComponent(pam) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(bar, GroupLayout.PREFERRED_SIZE, 9, GroupLayout.PREFERRED_SIZE).addGap(18, 18, 18) - .addComponent(lUsuario).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(lContraseña) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fContraseña1, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,20,20) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(bIngresar) - .addComponent(bSalir)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(bRegistrar) - .addGap(69, 69, 69))); - - setTitle("Login - P.A.M"); - setUndecorated(true); - pack(); - getRootPane().setDefaultButton(bIngresar); - 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/visual/FramePrincipal.java b/src/visual/FramePrincipal.java deleted file mode 100644 index 0af56ee..0000000 --- a/src/visual/FramePrincipal.java +++ /dev/null @@ -1,79 +0,0 @@ -package visual; - -import java.awt.*; -import javax.swing.*; - -public class FramePrincipal extends JFrame{ - - private JPanel panel; - - private PanelPrincipal panelPrincipal; - private PanelCartola panelCartola; - private PanelResumen panelResumen; - - private String usuario; - - public FramePrincipal(String usuario) { - - this.usuario = usuario; - initComponents(); - - } - - private void initComponents() { - panel = new JPanel(); - panelResumen = new PanelResumen(usuario); - panelPrincipal = new PanelPrincipal(usuario); - panelCartola = new PanelCartola(usuario); - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - panel.setBackground(new Color(204, 204, 204)); - panel.setRequestFocusEnabled(false); - panel.setLayout(new CardLayout()); - panel.add(panelCartola, "card2"); - panel.add(panelResumen, "card3"); - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup().addGap(0, 0, 0) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(panelPrincipal, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE)))); - layout.setVerticalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, - layout.createSequentialGroup() - .addComponent(panelPrincipal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0).addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE))); - - setTitle("P.A.M - (Personal Account Managger)"); - pack(); - setLocationRelativeTo(null); - setVisible(true); - } - - public void openResumen(){ - CardLayout cardLayout = (CardLayout) panel.getLayout(); - cardLayout.show(panel, "card3"); - } - - public void openCartola(){ - CardLayout cardLayout = (CardLayout) panel.getLayout(); - cardLayout.show(panel, "card2"); - } - - public void actResumen(){ - panelResumen.actualizarGraphDoc(); - panelResumen.actualizarGraphMes(); - panelResumen.llenarResumen(); - } - - - - - - - -} diff --git a/src/visual/FrameRegistro.java b/src/visual/FrameRegistro.java deleted file mode 100644 index 274856f..0000000 --- a/src/visual/FrameRegistro.java +++ /dev/null @@ -1,155 +0,0 @@ -package visual; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import utiles.ControlLogin; - -public class FrameRegistro extends JFrame{ - private JButton bRegister; - private JButton bSalir; - private JLabel bienvenido; - private JPasswordField fPass; - private JPasswordField fPass2; - private JTextField fUser; - private JLabel lPass; - private JLabel lPass2; - private JLabel lUser; - private JPanel panel; - private JLabel registrarse; - private JPanel registro; - - public FrameRegistro() { - initComponents(); - } - - private void initComponents() { - panel = new JPanel(); - registro = new JPanel(); - registrarse = new JLabel(); - bienvenido = new JLabel(); - bRegister = new JButton(); - bSalir = new JButton(); - fUser = new JTextField(); - lUser = new JLabel(); - lPass = new JLabel(); - lPass2 = new JLabel(); - fPass = new JPasswordField(); - fPass2 = new JPasswordField(); - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - setResizable(false); - panel.setBackground(new Color(204, 204, 204)); - panel.setRequestFocusEnabled(false); - panel.setLayout(new CardLayout()); - registro.setBackground(new Color(21, 21, 21)); - registrarse.setBackground(new Color(0, 204, 204)); - registrarse.setFont(new Font("Eras Light ITC", 2, 48)); // NOI18N - registrarse.setForeground(new Color(0, 204, 204)); - registrarse.setText("Registrarse!"); - bienvenido.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - bienvenido.setForeground(new Color(255, 255, 255)); - bienvenido.setText("Bienvenido a P.A.M!"); - bRegister.setText("Registrarse"); - bRegister.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bRegisterActionPerformed(evt); - } - }); - bSalir.setText("Salir"); - bSalir.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bSalirActionPerformed(evt); - } - }); - lUser.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lUser.setForeground(new Color(0, 204, 204)); - lUser.setText("Usuario"); - lPass.setBackground(new Color(0, 204, 204)); - lPass.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lPass.setForeground(new Color(0, 204, 204)); - lPass.setText("Contraseña"); - lPass2.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lPass2.setForeground(new Color(0, 204, 204)); - lPass2.setText("Verificar Contraseña"); - GroupLayout registroLayout = new GroupLayout(registro); - registro.setLayout(registroLayout); - registroLayout.setHorizontalGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( - GroupLayout.Alignment.TRAILING, - registroLayout.createSequentialGroup().addContainerGap(272, Short.MAX_VALUE).addGroup(registroLayout - .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( - registroLayout.createSequentialGroup().addGap(33, 33, 33).addGroup(registroLayout - .createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(registroLayout.createSequentialGroup().addGap(52, 52, 52) - .addComponent(lUser)) - .addGroup(registroLayout.createSequentialGroup().addGap(34, 34, 34) - .addComponent(lPass)) - .addGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(fUser, GroupLayout.PREFERRED_SIZE, 161, - GroupLayout.PREFERRED_SIZE) - .addComponent(fPass, GroupLayout.PREFERRED_SIZE, 161, - GroupLayout.PREFERRED_SIZE)) - .addGroup(registroLayout - .createParallelGroup(GroupLayout.Alignment.TRAILING, false) - .addGroup(GroupLayout.Alignment.LEADING, - registroLayout.createSequentialGroup().addComponent(bRegister) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, - GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(bSalir)) - .addComponent(fPass2, GroupLayout.Alignment.LEADING, - GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE)) - .addComponent(lPass2))) - .addComponent(registrarse)).addGap(266, 266, 266)) - .addGroup(registroLayout.createSequentialGroup().addGap(323, 323, 323) - .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - registroLayout - .setVerticalGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(registroLayout.createSequentialGroup().addContainerGap() - .addComponent(registrarse, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) - .addGap(32, 32, 32).addComponent(lUser) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fUser, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(lPass) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fPass, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(lPass2) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(fPass2, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(bRegister).addComponent(bSalir)) - .addContainerGap(76, Short.MAX_VALUE))); - panel.add(registro, "card2"); - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup().addGap(0, 0, 0).addComponent(panel, GroupLayout.DEFAULT_SIZE, - GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) - .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - - setUndecorated(true); - pack(); - getRootPane().setDefaultButton(bRegister); - setVisible(true); - setLocationRelativeTo(null); - } - - private void bRegisterActionPerformed(ActionEvent evt) { - ControlLogin control = new ControlLogin(); - if (control.añadirUsuario(fUser.getText(), String.valueOf(fPass.getPassword()), - String.valueOf(fPass2.getPassword()))) { - FrameLogin login = new FrameLogin(); - dispose(); - } - } - - private void bSalirActionPerformed(ActionEvent evt) { - FrameLogin login = new FrameLogin(); - dispose(); - } -} diff --git a/src/visual/JTableTable.java b/src/visual/JTableTable.java deleted file mode 100644 index c55cdd6..0000000 --- a/src/visual/JTableTable.java +++ /dev/null @@ -1,57 +0,0 @@ -package visual; - -import java.awt.Color; - -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.table.DefaultTableModel; - -import utiles.ControlPrincipal; - -public class JTableTable extends JTable{ - - String usuario; - public JTableTable(String usuario){ - - this.usuario = usuario; - iniciar(); - - } - public void iniciar(){ - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - setBackground(new Color(0, 204, 204)); - setModel(new DefaultTableModel(new Object[][] {}, 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)); - setSelectionForeground(new Color(0, 120, 215)); - - } - - 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/visual/Login.java b/src/visual/Login.java deleted file mode 100644 index ec1abc7..0000000 --- a/src/visual/Login.java +++ /dev/null @@ -1,185 +0,0 @@ -package visual; - -import java.awt.Color; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JPasswordField; -import javax.swing.JTextField; -import javax.swing.LayoutStyle; -import javax.swing.WindowConstants; - -import utiles.ControlLogin; - -public class Login{ - - private JFrame frame; - private JLabel Ingresar; - private JButton bIngresar; - private JButton bRegistrar; - private JButton bSalir; - private JLabel bienvenido; - private JPasswordField fPass; - private JTextField fUser; - private JLabel lPass; - private JLabel lUser; - private JPanel panel; - - public Login() { - initComponents(); - } - - private void initComponents() { - - frame = new JFrame(); - panel = new JPanel(); - Ingresar = new JLabel(); - bienvenido = new JLabel(); - bIngresar = new JButton(); - bSalir = new JButton(); - fUser = new JTextField(); - lUser = new JLabel(); - lPass = new JLabel(); - fPass = new JPasswordField(); - bRegistrar = new JButton(); - - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - panel.setBackground(new Color(21, 21, 21)); - - Ingresar.setBackground(new Color(0, 204, 204)); - Ingresar.setFont(new Font("Eras Light ITC", 2, 48)); // NOI18N - Ingresar.setForeground(new Color(0, 204, 204)); - Ingresar.setText("Ingresar!"); - - bienvenido.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - bienvenido.setForeground(new Color(255, 255, 255)); - bienvenido.setText("Bienvenido de nuevo a P.A.M!"); - - bIngresar.setText("Ingresar"); - bIngresar.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bIngresarActionPerformed(evt); - } - }); - - bSalir.setText("Salir"); - bSalir.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bSalirActionPerformed(evt); - } - }); - lUser.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lUser.setForeground(new Color(0, 204, 204)); - lUser.setText("Usuario"); - - lPass.setBackground(new Color(0, 204, 204)); - lPass.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lPass.setForeground(new Color(0, 204, 204)); - lPass.setText("Contraseña"); - - bRegistrar.setText("Registrarse"); - bRegistrar.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - bRegistrarActionPerformed(evt); - } - }); - - GroupLayout panelCartola1Layout = new GroupLayout(panel); - panel.setLayout(panelCartola1Layout); - panelCartola1Layout.setHorizontalGroup( - panelCartola1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addContainerGap(267, Short.MAX_VALUE) - .addGroup(panelCartola1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(bienvenido) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addGroup(panelCartola1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(Ingresar, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addGroup(panelCartola1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addGap(52, 52, 52) - .addComponent(lUser)) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addGap(34, 34, 34) - .addComponent(lPass)) - .addComponent(fUser) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addComponent(bIngresar, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(bSalir, GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)) - .addComponent(fPass)) - .addGap(38, 38, 38))) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 107, Short.MAX_VALUE) - .addComponent(bRegistrar, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))) - .addContainerGap()) - ); - panelCartola1Layout.setVerticalGroup( - panelCartola1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelCartola1Layout.createSequentialGroup() - .addGap(32, 32, 32) - .addComponent(Ingresar, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(lUser) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fUser, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(lPass) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fPass, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE) - .addGap(35, 35, 35) - .addGroup(panelCartola1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(bSalir) - .addComponent(bIngresar)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE) - .addComponent(bRegistrar) - .addContainerGap()) - ); - - GroupLayout layout = new GroupLayout(frame.getContentPane()); - frame.getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - ); - frame.getRootPane().setDefaultButton(bIngresar); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - } - - - private void bIngresarActionPerformed(ActionEvent evt) { - ControlLogin control = new ControlLogin(); - if(control.isUserPass(fUser.getText(), String.valueOf(fPass.getPassword()))) - { - Principal principal = new Principal(fUser.getText()); - frame.dispose(); - }else - { - javax.swing.JOptionPane.showMessageDialog(null, "Usuario o contraseña incorrectas", null, - javax.swing.JOptionPane.ERROR_MESSAGE); - } - } - private void bSalirActionPerformed(ActionEvent evt) { - System.exit(0); - } - private void bRegistrarActionPerformed(ActionEvent evt) { - Registro registro = new Registro(); - frame.dispose(); - } - -} diff --git a/src/visual/P.A.M.v2/catola.png b/src/visual/P.A.M.v2/catola.png deleted file mode 100644 index 594b23d..0000000 Binary files a/src/visual/P.A.M.v2/catola.png and /dev/null differ diff --git a/src/visual/P.A.M.v2/logo.png b/src/visual/P.A.M.v2/logo.png deleted file mode 100644 index d52b124..0000000 Binary files a/src/visual/P.A.M.v2/logo.png and /dev/null differ diff --git a/src/visual/P.A.M.v2/resumen.png b/src/visual/P.A.M.v2/resumen.png deleted file mode 100644 index 520c843..0000000 Binary files a/src/visual/P.A.M.v2/resumen.png and /dev/null differ diff --git a/src/visual/PanelCartola.java b/src/visual/PanelCartola.java deleted file mode 100644 index 7d6f4f5..0000000 --- a/src/visual/PanelCartola.java +++ /dev/null @@ -1,459 +0,0 @@ -package visual; - -import java.awt.Color; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.text.SimpleDateFormat; -import java.util.Calendar; - -import javax.swing.DefaultComboBoxModel; -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.LayoutStyle; - -import org.jdesktop.swingx.JXDatePicker; - -import utiles.ControlPrincipal; -import utiles.Validador; - -public class PanelCartola extends JPanel { - - private JButton añadir; - private JButton eliminar; - private JButton modificar; - - private JScrollPane jScrollPane1; - private JTableTable tabla; - - private String usuario; - - private JLabel lFD; - private JLabel lFD1; - private JLabel lEgr; - private JLabel lEgr1; - private JLabel lIng; - private JLabel lIng1; - private JLabel lDesc; - private JLabel lDesc1; - private JLabel lDocumento; - private JLabel lDocumento1; - private JLabel lFecha2; - private JLabel lFecha3; - private JLabel lFecha4; - - private JComboBox documento; - private JComboBox documento1; - - private JTextField fFD; - private JTextField fFD1; - private JTextField fDesc; - private JTextField fDesc1; - private JTextField fIng; - private JTextField fIng1; - private JTextField fEgr; - private JTextField fEgr1; - private JTextField fNumber; - - private JXDatePicker jXDatePicker1; - private JXDatePicker jXDatePicker2; - - public PanelCartola(String usuario) { - - this.usuario = usuario; - init(); - tabla.actTabla(); - - } - - private void init() { - - tabla = new JTableTable(usuario); - jScrollPane1 = new JScrollPane(); - jScrollPane1.getViewport().setBackground(new Color(128, 203, 196)); - jScrollPane1.setViewportView(tabla); - - if (tabla.getColumnModel().getColumnCount() > 0) { - - tabla.getColumnModel().getColumn(0).setResizable(false); - - } - - lFD = new JLabel(); - lFD.setBackground(new Color(0, 204, 204)); - lFD.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFD.setForeground(new Color(0, 204, 204)); - lFD.setText("Fuente/Destino:"); - - lFD1 = new JLabel(); - lFD1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFD1.setForeground(new Color(0, 204, 204)); - lFD1.setText("Fuente/Destino:"); - - lEgr = new JLabel(); - lEgr.setBackground(new Color(0, 204, 204)); - lEgr.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lEgr.setForeground(new Color(0, 204, 204)); - lEgr.setText("Egreso:"); - - lEgr1 = new JLabel(); - lEgr1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lEgr1.setForeground(new Color(0, 204, 204)); - lEgr1.setText("Egreso:"); - - lIng = new JLabel(); - lIng.setBackground(new Color(0, 204, 204)); - lIng.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lIng.setForeground(new Color(0, 204, 204)); - lIng.setText("Ingreso:"); - - lIng1 = new JLabel(); - lIng1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lIng1.setForeground(new Color(0, 204, 204)); - lIng1.setText("Ingreso:"); - - lDesc = new JLabel(); - lDesc.setBackground(new Color(0, 204, 204)); - lDesc.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDesc.setForeground(new Color(0, 204, 204)); - lDesc.setText("Descripcion:"); - - lDesc1 = new JLabel(); - lDesc1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDesc1.setForeground(new Color(0, 204, 204)); - lDesc1.setText("Descripcion:"); - - lDocumento = new JLabel(); - lDocumento.setBackground(new Color(0, 204, 204)); - lDocumento.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDocumento.setForeground(new Color(0, 204, 204)); - lDocumento.setText("Documento:"); - - lDocumento1 = new JLabel(); - lDocumento1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDocumento1.setForeground(new Color(0, 204, 204)); - lDocumento1.setText("Documento:"); - - lFecha2 = new JLabel(); - lFecha2.setBackground(new Color(0, 204, 204)); - lFecha2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha2.setForeground(new Color(0, 204, 204)); - lFecha2.setText("Fecha:"); - - lFecha3 = new JLabel(); - lFecha3.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha3.setForeground(new Color(0, 204, 204)); - lFecha3.setText("Fecha:"); - - lFecha4 = new JLabel(); - lFecha4.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha4.setForeground(new Color(0, 204, 204)); - lFecha4.setText("N°:"); - - documento = new JComboBox<>(); - documento.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - documento.setModel(new DefaultComboBoxModel<>(new String[] { "Efectivo", "Credito", "Transferencia" })); - - documento1 = new JComboBox<>(); - documento1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - documento1.setModel(new DefaultComboBoxModel<>(new String[] { "Efectivo", "Credito", "Transferencia" })); - - fFD = new JTextField(); - fFD1 = new JTextField(); - - fDesc = new JTextField(); - fDesc1 = new JTextField(); - - fIng = new JTextField(); - fIng.addKeyListener(new KeyAdapter() { - - public void keyTyped(KeyEvent e) { - - char c = e.getKeyChar(); - - if (!Character.isDigit(c)) { - e.consume(); - } - - } - - }); - fIng.setText("0"); - fIng1 = new JTextField(); - fIng1.addKeyListener(new KeyAdapter() { - - public void keyTyped(KeyEvent e) { - - char c = e.getKeyChar(); - - if (!Character.isDigit(c)) { - e.consume(); - } - - } - - }); - fIng1.setText("0"); - - fEgr = new JTextField(); - fEgr.setText("0"); - fEgr1 = new JTextField(); - fEgr1.setText("0"); - - fNumber = new JTextField(); - - Calendar today = Calendar.getInstance(); - - jXDatePicker1 = new JXDatePicker(); - jXDatePicker1.setDate(today.getTime()); - jXDatePicker2 = new JXDatePicker(); - jXDatePicker2.setDate(today.getTime()); - - eliminar = new JButton(); - eliminar.setText("Eliminar Fila Seleccionada"); - eliminar.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - - eliminarActionPerformed(evt); - - } - - }); - - añadir = new JButton(); - añadir.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - añadir.setText("añadir"); - añadir.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - - añadirActionPerformed(evt); - - } - - }); - - modificar = new JButton(); - modificar.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - modificar.setText("Modificar"); - modificar.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - - modificarActionPerformed(evt); - - } - - }); - - setBackground(new Color(21, 21, 21)); - GroupLayout panelCartolaLayout = new GroupLayout(this); - setLayout(panelCartolaLayout); - panelCartolaLayout.setHorizontalGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelCartolaLayout.createSequentialGroup() - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( - panelCartolaLayout.createSequentialGroup().addGap(747, 747, 747).addComponent(eliminar)) - .addGroup(panelCartolaLayout.createSequentialGroup().addContainerGap() - .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 933, Short.MAX_VALUE))) - .addGap(30, 30, - 30) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(panelCartolaLayout.createSequentialGroup() - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(lFD).addComponent(lEgr, GroupLayout.Alignment.TRAILING) - .addComponent(lIng, GroupLayout.Alignment.TRAILING) - .addComponent(lDesc, GroupLayout.Alignment.TRAILING) - .addComponent(lDocumento, GroupLayout.Alignment.TRAILING) - .addComponent(lFecha2, GroupLayout.Alignment.TRAILING)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout - .createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(documento, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(fFD).addComponent(fDesc).addComponent(fIng) - .addComponent(fEgr, GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE) - .addComponent(jXDatePicker1, GroupLayout.DEFAULT_SIZE, - GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addGroup(panelCartolaLayout.createSequentialGroup() - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(lFD1).addComponent(lEgr1, GroupLayout.Alignment.TRAILING) - .addComponent(lIng1, GroupLayout.Alignment.TRAILING) - .addComponent(lDesc1, GroupLayout.Alignment.TRAILING) - .addComponent(lDocumento1, GroupLayout.Alignment.TRAILING) - .addComponent(lFecha3, GroupLayout.Alignment.TRAILING) - .addComponent(lFecha4, GroupLayout.Alignment.TRAILING)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout - .createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(documento1, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(fFD1).addComponent(fDesc1).addComponent(fIng1) - .addComponent(fEgr1, GroupLayout.PREFERRED_SIZE, 170, - GroupLayout.PREFERRED_SIZE) - .addComponent(fNumber).addComponent(jXDatePicker2, - GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE))) - .addGroup(panelCartolaLayout.createSequentialGroup().addComponent(añadir).addGap(125, - 125, 125)) - .addGroup(panelCartolaLayout.createSequentialGroup().addComponent(modificar).addGap(105, - 105, 105))) - .addGap(62, 62, 62))); - panelCartolaLayout.setVerticalGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelCartolaLayout.createSequentialGroup().addGroup(panelCartolaLayout - .createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(panelCartolaLayout.createSequentialGroup().addGap(40, 40, 40) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha2).addComponent(jXDatePicker1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDocumento).addComponent(documento, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFD).addComponent(fFD, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDesc).addComponent(fDesc, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lIng).addComponent(fIng, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(fEgr, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE) - .addComponent(lEgr)) - .addGap(18, 18, 18).addComponent(añadir) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha4).addComponent(fNumber, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha3).addComponent(jXDatePicker2, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDocumento1).addComponent(documento1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFD1).addComponent(fFD1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDesc1).addComponent(fDesc1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lIng1).addComponent(fIng1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(fEgr1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE) - .addComponent(lEgr1)) - .addGap(18, 18, 18).addComponent(modificar)) - .addGroup(GroupLayout.Alignment.LEADING, - panelCartolaLayout.createSequentialGroup().addGap(20, 20, 20) - .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(eliminar))) - .addGap(29, 29, 29))); - - } - - private void añadirActionPerformed(ActionEvent evt) { - - ControlPrincipal control = new ControlPrincipal(usuario); - SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); - String fecha = formateador.format(jXDatePicker1.getDate()); - String documento = this.documento.getSelectedItem().toString(); - - String fD = fFD.getText(); - fFD.setText(""); - - String desc = fDesc.getText(); - fDesc.setText(""); - - String ing = fIng.getText(); - if (ing.equals("")) { - ing = "0"; - } else if (!Validador.isNumber(ing)) { - JOptionPane.showMessageDialog(null, "Dato ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); - } - - fIng.setText("0"); - String egr = fEgr.getText(); - if (egr.equals("")) { - egr = "0"; - } else if (!Validador.isNumber(egr)) { - JOptionPane.showMessageDialog(null, "Dato ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); - } - - fEgr.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(!fNumber.getText().equals("")){ - - System.out.println("Entro"); - SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); - - String number = fNumber.getText(); - String fecha = formateador.format(jXDatePicker2.getDate()); - String documento = this.documento1.getSelectedItem().toString(); - String fD = fFD1.getText(); - String desc = fDesc1.getText(); - String ing = fIng1.getText(); - - if (ing.equals("")) { - ing = "0"; - } else if (!Validador.isNumber(ing)) { - JOptionPane.showMessageDialog(null, "Dato ingresado incorrecto", "Error", JOptionPane.ERROR_MESSAGE); - } - - String egr = fEgr1.getText(); - if (egr.equals("")) { - egr = "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/visual/PanelPrincipal.java b/src/visual/PanelPrincipal.java deleted file mode 100644 index 9d061fe..0000000 --- a/src/visual/PanelPrincipal.java +++ /dev/null @@ -1,151 +0,0 @@ -package visual; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Calendar; - -import javax.swing.*; - -public class PanelPrincipal extends JPanel { - - private JLabel pam; - - private JButton cartola; - private JButton resumen; - - private JLabel lUsuario; - private JLabel lFecha1; - - private JTextField fUsuario; - private JTextField fFecha; - - private String usuario; - - public PanelPrincipal(String usuario) { - - this.usuario = usuario; - iniciar(); - - } - - public void iniciar() { - - pam = new JLabel(); - pam.setFont(new Font("LM Roman Caps 10", 1, 60)); // NOI18N - pam.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/logo.png"))); // NOI18N - - cartola = new JButton(); - cartola.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - cartola.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/catola.png"))); // NOI18N - cartola.setText("Cartola"); - cartola.setMaximumSize(new Dimension(50, 17)); - cartola.setMinimumSize(new Dimension(50, 17)); - cartola.setPreferredSize(new Dimension(50, 17)); - cartola.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cartolaActionPerformed(evt); - } - }); - - resumen = new JButton(); - resumen.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - resumen.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/resumen.png"))); // NOI18N - resumen.setText("Resumen"); - resumen.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - resumenActionPerformed(evt); - } - }); - - lUsuario = new JLabel(); - lUsuario.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lUsuario.setForeground(new Color(0, 204, 204)); - lUsuario.setText("Usuario"); - - lFecha1 = new JLabel(); - lFecha1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha1.setForeground(new Color(0, 204, 204)); - lFecha1.setText("Fecha"); - - fUsuario = new JTextField(); - fUsuario.setText(usuario); - fUsuario.setEditable(false); - fUsuario.setFocusable(false); - - fFecha = new JTextField(); - fFecha.setEditable(false); - fFecha.setFocusable(false); - - Calendar c = Calendar.getInstance(); - fFecha.setText(String.valueOf(c.get(Calendar.DATE)) + "/" + String.valueOf(c.get(Calendar.MONTH)) + "/" - + String.valueOf(c.get(Calendar.YEAR))); - - setBackground(new Color(21, 21, 21)); - - GroupLayout panelPrincipalLayout = new GroupLayout(this); - setLayout(panelPrincipalLayout); - panelPrincipalLayout.setHorizontalGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelPrincipalLayout.createSequentialGroup().addGap(21, 21, 21).addComponent(pam) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent(cartola, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(resumen, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) - .addComponent(lUsuario).addComponent(lFecha1)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(fFecha).addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, 123, - GroupLayout.PREFERRED_SIZE)) - .addGap(23, 23, 23))); - panelPrincipalLayout.setVerticalGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, panelPrincipalLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.LEADING).addComponent( - pam) - .addGroup(panelPrincipalLayout.createSequentialGroup().addGap(7, 7, 7) - .addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(panelPrincipalLayout.createSequentialGroup() - .addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lUsuario).addComponent(fUsuario, - GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE)) - .addGap(6, 6, 6) - .addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha1).addComponent(fFecha, - GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE))) - .addGroup(panelPrincipalLayout - .createParallelGroup( - GroupLayout.Alignment.BASELINE) - .addComponent(cartola, GroupLayout.PREFERRED_SIZE, 27, - GroupLayout.PREFERRED_SIZE) - .addComponent(resumen, GroupLayout.PREFERRED_SIZE, 27, - GroupLayout.PREFERRED_SIZE))))))); - } - - protected void resumenActionPerformed(ActionEvent evt) { - - FramePrincipal parent = (FramePrincipal) SwingUtilities.getWindowAncestor(this); - parent.actResumen(); - parent.openResumen(); - - } - - protected void cartolaActionPerformed(ActionEvent evt) { - - FramePrincipal parent = (FramePrincipal) SwingUtilities.getWindowAncestor(this); - parent.openCartola(); - - } -} diff --git a/src/visual/PanelResumen.java b/src/visual/PanelResumen.java deleted file mode 100644 index 770f105..0000000 --- a/src/visual/PanelResumen.java +++ /dev/null @@ -1,591 +0,0 @@ -package visual; - -import java.awt.*; -import java.awt.event.*; -import java.util.ArrayList; -import javax.swing.*; -import org.jfree.chart.*; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.DefaultCategoryDataset; - -import utiles.ControlPrincipal; - -public class PanelResumen extends JPanel { - - private JPanel graph; - private ChartPanel graphDoc; - private ChartPanel graphMes; - - private JLabel lIng; - private JLabel lSaldo; - private JLabel lEgr2; - private JLabel lBalance; - private JLabel select; - - private ArrayList mes; - private ArrayList egresos; - private ArrayList ingresos; - private ArrayList saldos; - - private JComboBox tipoGraph; - - private DefaultCategoryDataset dataSetMes; - private DefaultCategoryDataset dataSetDoc; - - private String usuario; - - public PanelResumen(String usuario) { - - this.usuario = usuario; - iniciar(); - - } - - public void iniciar() { - - iniciarTextFieldYLabel(); - - setBackground(new Color(21, 21, 21)); - setForeground(new Color(255, 255, 255)); - - graphMes = crearGraphMes(); - graphDoc = crearGraphDoc(); - - graph = new JPanel(); - graph.setBackground(new Color(153, 153, 153)); - graph.setLayout(new CardLayout()); - graph.add(graphMes, "Mes"); - graph.add(graphDoc, "Documento"); - - lIng = new JLabel(); - lIng.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lIng.setForeground(new Color(255, 255, 255)); - lIng.setText("Ingresos"); - - lSaldo = new JLabel(); - lSaldo.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lSaldo.setForeground(new Color(255, 255, 255)); - lSaldo.setText("Saldo"); - - lEgr2 = new JLabel(); - lEgr2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lEgr2.setForeground(new Color(255, 255, 255)); - lEgr2.setText("Egresos"); - - lBalance = new JLabel(); - lBalance.setFont(new Font("Eras Light ITC", 0, 36)); // NOI18N - lBalance.setForeground(new Color(255, 255, 255)); - lBalance.setText("Balance Mensual"); - - select = new JLabel(); - select.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - select.setForeground(new Color(255, 255, 255)); - select.setText("Seleccionar Grafico:"); - - tipoGraph = new JComboBox<>(); - tipoGraph.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - tipoGraph.setModel(new DefaultComboBoxModel<>(new String[] { "Mes", "Documento" })); - tipoGraph.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - - comboActionPerformed(evt); - - } - - }); - - GroupLayout panelResumenLayout = new GroupLayout(this); - setLayout(panelResumenLayout); - panelResumenLayout - .setHorizontalGroup(panelResumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, - panelResumenLayout.createSequentialGroup().addContainerGap().addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lIng, javax.swing.GroupLayout.Alignment.TRAILING).addGroup( - javax.swing.GroupLayout.Alignment.TRAILING, panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lSaldo).addComponent(lEgr2))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, - Short.MAX_VALUE) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelResumenLayout - .createSequentialGroup() - .addComponent(lBalance, javax.swing.GroupLayout.PREFERRED_SIZE, - 310, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(116, 116, 116)) - .addGroup(panelResumenLayout.createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(saldos.get(0), - javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(0), - javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(0), - javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(mes.get(0))) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(mes.get(1)) - .addComponent(saldos.get(1), - javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(1), - javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(1), - javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(mes.get(2)) - .addGroup(panelResumenLayout.createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(saldos.get(2), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(2), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(2), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(saldos.get(3), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(saldos.get(4), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(saldos.get(5), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(egresos.get(3), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(egresos.get(4), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(egresos.get(5), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent( - ingresos.get(3), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent( - mes.get(3))) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent( - ingresos.get(4), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent( - mes.get(4))) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent( - mes.get(5)) - .addComponent( - ingresos.get(5), - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)))))) - .addGap(35, 35, 35))) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout.createSequentialGroup() - .addComponent(select).addGap(4, 4, 4) - .addComponent(tipoGraph, javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(graph, javax.swing.GroupLayout.PREFERRED_SIZE, 719, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(6, 6, 6))); - panelResumenLayout - .setVerticalGroup( - panelResumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - panelResumenLayout - .createSequentialGroup().addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(graph, javax.swing.GroupLayout.PREFERRED_SIZE, - 449, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(panelResumenLayout.createSequentialGroup().addGap(50, - 50, 50) - .addComponent(lBalance, - javax.swing.GroupLayout.PREFERRED_SIZE, 52, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(40, 40, 40) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(mes.get(0)).addComponent(mes.get(1)) - .addComponent(mes.get(2)).addComponent(mes.get(3)) - .addComponent(mes.get(4)).addComponent(mes.get(5))) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(ingresos.get(0), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(1), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(3), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(4), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(ingresos.get(5), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(egresos.get(0), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(1), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(3), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(4), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(egresos.get(5), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(saldos.get(0), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(saldos.get(1), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(saldos.get(3), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(saldos.get(4), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(saldos.get(5), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(lIng) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addGap(26, 26, 26) - .addComponent(lSaldo)) - .addComponent(lEgr2))) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(ingresos.get(2), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(egresos.get(2), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(saldos.get(2), - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE))))) - .addGap(43, 43, 43) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(tipoGraph, javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(select)) - .addGap(0, 65, Short.MAX_VALUE))); - } - - public void iniciarTextFieldYLabel() { - - ingresos = new ArrayList(); - egresos = new ArrayList(); - saldos = new ArrayList(); - mes = 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(0, 204, 204)); - ingresos.get(x).setVisible(false); - ingresos.get(x).setEditable(false); - egresos.get(x).setBackground(new Color(0, 204, 204)); - egresos.get(x).setVisible(false); - egresos.get(x).setEditable(false); - saldos.get(x).setBackground(new Color(0, 204, 204)); - saldos.get(x).setVisible(false); - saldos.get(x).setEditable(false); - mes.add(new JLabel()); - mes.get(x).setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - mes.get(x).setForeground(new Color(255, 255, 255)); - mes.get(x).setText("Mes"); - mes.get(x).setVisible(false); - - } - - } - - private void comboActionPerformed(ActionEvent evt) { - - CardLayout cardLayout = (CardLayout) graph.getLayout(); - cardLayout.show(graph, (String) tipoGraph.getSelectedItem()); - - } - - public void llenarResumen() { - - ControlPrincipal control = new ControlPrincipal(usuario); - 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).setVisible(true); - egresos.get(z).setText(resumen[3][x]); - egresos.get(z).setVisible(true); - saldos.get(z).setText(resumen[1][x]); - saldos.get(z).setVisible(true); - - if (resumen[0][x].matches("[0-9]{4}-01")) { - - mes.get(z).setText("Enero"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-02")) { - - mes.get(z).setText("Febrero"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-03")) { - - mes.get(z).setText("Marzo"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-04")) { - - mes.get(z).setText("Abril"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-05")) { - - mes.get(z).setText("Mayo"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-06")) { - - mes.get(z).setText("Junio"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-07")) { - - mes.get(z).setText("Julio"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-08")) { - - mes.get(z).setText("Agosto"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-09")) { - - mes.get(z).setText("Septiembre"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-10")) { - - mes.get(z).setText("Octubre"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-11")) { - - mes.get(z).setText("Noviembre"); - mes.get(z).setVisible(true); - - } else if (resumen[0][x].matches("[0-9]{4}-12")) { - - mes.get(z).setText("Diciembre"); - mes.get(z).setVisible(true); - - } - - } - - } - - } - - private ChartPanel crearGraphMes() { - - ControlPrincipal control = new ControlPrincipal(usuario); - String[][] resumen = control.resumenMes(); - - dataSetMes = new DefaultCategoryDataset(); - - 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]); - - } - - } - - JFreeChart chart = ChartFactory.createBarChart("Resumen Mensual", "Mes", "Saldo", dataSetMes, - PlotOrientation.VERTICAL, false, true, false); - - chart.getPlot().setBackgroundPaint(new Color(0, 204, 204)); - chart.getCategoryPlot().getRenderer().setSeriesPaint(0, new Color(21, 21, 21)); - chart.setBackgroundPaint(new Color(0, 204, 204)); - - ChartPanel graph = new ChartPanel(chart); - return graph; - - } - - private ChartPanel crearGraphDoc() { - - ControlPrincipal control = new ControlPrincipal(usuario); - int[] resumen = control.resumenDoc(); - - dataSetDoc = new DefaultCategoryDataset(); - dataSetDoc.setValue(resumen[0], "Saldo", "Efectivo"); - dataSetDoc.setValue(resumen[1], "Saldo", "Transferencia"); - dataSetDoc.setValue(resumen[2], "Saldo", "Credito"); - - JFreeChart chart = ChartFactory.createBarChart("Resumen por Documentos", "Documento", "Saldo", dataSetDoc, - PlotOrientation.VERTICAL, false, true, false); - - chart.getPlot().setBackgroundPaint(new Color(0, 204, 204)); - chart.getCategoryPlot().getRenderer().setSeriesPaint(0, new Color(21, 21, 21)); - chart.setBackgroundPaint(new Color(0, 204, 204)); - - ChartPanel graph = new ChartPanel(chart); - return graph; - } - - public 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]); - - } - - } - - } - - public 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/visual/Principal.java b/src/visual/Principal.java deleted file mode 100644 index d7a7778..0000000 --- a/src/visual/Principal.java +++ /dev/null @@ -1,1078 +0,0 @@ -package visual; - -import java.awt.*; -import java.awt.event.*; -import java.text.*; -import java.util.*; -import javax.swing.*; -import javax.swing.table.*; -import org.jdesktop.swingx.JXDatePicker; -import org.jfree.chart.*; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.data.category.DefaultCategoryDataset; -import utiles.ControlPrincipal; - -public class Principal -{ - private JFrame principal; - private JButton añadir; - private JToggleButton cartola; - private JComboBox documento; - private JComboBox documento1; - private JTextField eM1; - private JTextField eM2; - private JTextField eM3; - private JTextField eM4; - private JTextField eM5; - private JTextField eM6; - private JButton eliminar; - private JTextField fDesc; - private JTextField fDesc1; - private JTextField fEgr; - private JTextField fEgr1; - private JTextField fFD; - private JTextField fFD1; - private JTextField fFecha1; - private JTextField fIng; - private JTextField fIng1; - private JTextField fNumber; - private JTextField fUsuario; - private JPanel graph; - private ChartPanel graphDoc; - private ChartPanel graphMes; - private JTextField iM1; - private JTextField iM2; - private JTextField iM3; - private JTextField iM4; - private JTextField iM5; - private JTextField iM6; - private JLabel jLabel1; - private JLabel jLabel2; - private JScrollPane jScrollPane1; - private JLabel lDesc; - private JLabel lDesc1; - private JLabel lDocumento; - private JLabel lDocumento1; - private JLabel lEgr; - private JLabel lEgr1; - private JLabel lEgr2; - private JLabel lFD; - private JLabel lFD1; - private JLabel lFecha1; - private JLabel lFecha2; - private JLabel lFecha3; - private JLabel lFecha4; - private JLabel lIng; - private JLabel lIng1; - private JLabel lIng2; - private JLabel lMes1; - private JLabel lMes2; - private JLabel lMes3; - private JLabel lMes4; - private JLabel lMes5; - private JLabel lMes6; - private JLabel lSaldo2; - private JLabel lUsuario; - private JButton modificar; - private JLabel pam; - private JPanel panel; - private JPanel panelCartola; - private JPanel panelPrincipal; - private JPanel panelResumen; - private JToggleButton resumen; - private JTextField sM1; - private JTextField sM2; - private JTextField sM3; - private JTextField sM4; - private JTextField sM5; - private JTextField sM6; - private JTable tabla; - private JComboBox tipoGraph; - private JXDatePicker jXDatePicker1; - private JXDatePicker jXDatePicker2; - private String usuario; - private DefaultCategoryDataset dataSetMes; - private DefaultCategoryDataset dataSetDoc; - - public Principal(String usuario) - { - this.usuario = usuario; - initComponents(); - iniciarTabla(); - } - private void initComponents() - { - principal = new JFrame(); - panel = new JPanel(); - panelCartola = new JPanel(); - eliminar = new JButton(); - jScrollPane1 = new JScrollPane(); - tabla = new JTable(); - lFecha2 = new JLabel(); - lDocumento = new JLabel(); - lFD = new JLabel(); - lDesc = new JLabel(); - lIng = new JLabel(); - lEgr = new JLabel(); - documento = new JComboBox<>(); - fFD = new JTextField(); - fDesc = new JTextField(); - fIng = new JTextField(); - fEgr = new JTextField(); - añadir = new JButton(); - lFecha3 = new JLabel(); - lDocumento1 = new JLabel(); - lFD1 = new JLabel(); - lDesc1 = new JLabel(); - lIng1 = new JLabel(); - lEgr1 = new JLabel(); - fEgr1 = new JTextField(); - fIng1 = new JTextField(); - fDesc1 = new JTextField(); - fFD1 = new JTextField(); - documento1 = new JComboBox<>(); - modificar = new JButton(); - lFecha4 = new JLabel(); - fNumber = new JTextField(); - panelResumen = new JPanel(); - graph = new JPanel(); - tipoGraph = new JComboBox<>(); - jLabel1 = new JLabel(); - lMes1 = new JLabel(); - lMes2 = new JLabel(); - lMes3 = new JLabel(); - lMes4 = new JLabel(); - lMes5 = new JLabel(); - lMes6 = new JLabel(); - iM1 = new JTextField(); - iM2 = new JTextField(); - iM3 = new JTextField(); - iM4 = new JTextField(); - iM5 = new JTextField(); - iM6 = new JTextField(); - lIng2 = new JLabel(); - lEgr2 = new JLabel(); - eM2 = new JTextField(); - eM3 = new JTextField(); - eM4 = new JTextField(); - eM5 = new JTextField(); - eM6 = new JTextField(); - eM1 = new JTextField(); - sM2 = new JTextField(); - sM4 = new JTextField(); - sM3 = new JTextField(); - lSaldo2 = new JLabel(); - sM6 = new JTextField(); - sM5 = new JTextField(); - sM1 = new JTextField(); - jLabel2 = new JLabel(); - panelPrincipal = new JPanel(); - pam = new JLabel(); - cartola = new JToggleButton(); - resumen = new JToggleButton(); - lUsuario = new JLabel(); - fUsuario = new JTextField(); - fFecha1 = new JTextField(); - lFecha1 = new JLabel(); - jXDatePicker1 = new JXDatePicker(); - Calendar today = Calendar.getInstance(); - jXDatePicker1.setDate(today.getTime()); - jXDatePicker2 = new JXDatePicker(); - jXDatePicker2.setDate(today.getTime()); - fIng.setText("0"); - fEgr.setText("0"); - fIng1.setText("0"); - fEgr1.setText("0"); - principal.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - panel.setBackground(new Color(204, 204, 204)); - panel.setRequestFocusEnabled(false); - panel.setLayout(new CardLayout()); - panelCartola.setBackground(new Color(21, 21, 21)); - eliminar.setText("Eliminar Fila Seleccionada"); - eliminar.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - eliminarActionPerformed(evt); - } - }); - jScrollPane1.getViewport().setBackground(new Color(128, 203, 196)); - tabla.setBackground(new Color(0, 204, 204)); - tabla.setForeground(SystemColor.textHighlight); - tabla.setModel(new DefaultTableModel(new Object[][] {}, 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]; - } - }); - tabla.setGridColor(new Color(255, 255, 255)); - tabla.setSelectionForeground(new Color(0, 120, 215)); - jScrollPane1.setViewportView(tabla); - if (tabla.getColumnModel().getColumnCount() > 0) - { - tabla.getColumnModel().getColumn(0).setResizable(false); - } - lFecha2.setBackground(new Color(0, 204, 204)); - lFecha2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha2.setForeground(new Color(0, 204, 204)); - lFecha2.setText("Fecha:"); - lDocumento.setBackground(new Color(0, 204, 204)); - lDocumento.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDocumento.setForeground(new Color(0, 204, 204)); - lDocumento.setText("Documento:"); - lFD.setBackground(new Color(0, 204, 204)); - lFD.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFD.setForeground(new Color(0, 204, 204)); - lFD.setText("Fuente/Destino:"); - lDesc.setBackground(new Color(0, 204, 204)); - lDesc.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDesc.setForeground(new Color(0, 204, 204)); - lDesc.setText("Descripcion:"); - lIng.setBackground(new Color(0, 204, 204)); - lIng.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lIng.setForeground(new Color(0, 204, 204)); - lIng.setText("Ingreso:"); - lEgr.setBackground(new Color(0, 204, 204)); - lEgr.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lEgr.setForeground(new Color(0, 204, 204)); - lEgr.setText("Egreso:"); - documento.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - documento.setModel(new DefaultComboBoxModel<>(new String[] { "Efectivo", "Credito", "Transferencia" })); - fFD.setToolTipText(""); - añadir.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - añadir.setText("Añadir"); - añadir.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - añadirActionPerformed(evt); - } - }); - lFecha3.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha3.setForeground(new Color(0, 204, 204)); - lFecha3.setText("Fecha:"); - lDocumento1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDocumento1.setForeground(new Color(0, 204, 204)); - lDocumento1.setText("Documento:"); - lFD1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFD1.setForeground(new Color(0, 204, 204)); - lFD1.setText("Fuente/Destino:"); - lDesc1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lDesc1.setForeground(new Color(0, 204, 204)); - lDesc1.setText("Descripcion:"); - lIng1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lIng1.setForeground(new Color(0, 204, 204)); - lIng1.setText("Ingreso:"); - lEgr1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lEgr1.setForeground(new Color(0, 204, 204)); - lEgr1.setText("Egreso:"); - fFD1.setToolTipText(""); - documento1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - documento1.setModel(new DefaultComboBoxModel<>(new String[] { "Efectivo", "Credito", "Transferencia" })); - modificar.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - modificar.setText("Modificar"); - modificar.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - modificarActionPerformed(evt); - } - }); - lFecha4.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha4.setForeground(new Color(0, 204, 204)); - lFecha4.setText("N°:"); - fNumber.setToolTipText(""); - GroupLayout panelCartolaLayout = new GroupLayout(panelCartola); - panelCartola.setLayout(panelCartolaLayout); - panelCartolaLayout.setHorizontalGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelCartolaLayout.createSequentialGroup() - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( - panelCartolaLayout.createSequentialGroup().addGap(747, 747, 747).addComponent(eliminar)) - .addGroup(panelCartolaLayout.createSequentialGroup().addContainerGap() - .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 933, Short.MAX_VALUE))) - .addGap(30, 30, - 30) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(panelCartolaLayout.createSequentialGroup() - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(lFD).addComponent(lEgr, GroupLayout.Alignment.TRAILING) - .addComponent(lIng, GroupLayout.Alignment.TRAILING) - .addComponent(lDesc, GroupLayout.Alignment.TRAILING) - .addComponent(lDocumento, GroupLayout.Alignment.TRAILING) - .addComponent(lFecha2, GroupLayout.Alignment.TRAILING)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout - .createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(documento, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(fFD).addComponent(fDesc).addComponent(fIng) - .addComponent(fEgr, GroupLayout.DEFAULT_SIZE, 170, Short.MAX_VALUE) - .addComponent(jXDatePicker1, GroupLayout.DEFAULT_SIZE, - GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - .addGroup(panelCartolaLayout.createSequentialGroup() - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(lFD1).addComponent(lEgr1, GroupLayout.Alignment.TRAILING) - .addComponent(lIng1, GroupLayout.Alignment.TRAILING) - .addComponent(lDesc1, GroupLayout.Alignment.TRAILING) - .addComponent(lDocumento1, GroupLayout.Alignment.TRAILING) - .addComponent(lFecha3, GroupLayout.Alignment.TRAILING) - .addComponent(lFecha4, GroupLayout.Alignment.TRAILING)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout - .createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(documento1, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(fFD1).addComponent(fDesc1).addComponent(fIng1) - .addComponent(fEgr1, GroupLayout.PREFERRED_SIZE, 170, - GroupLayout.PREFERRED_SIZE) - .addComponent(fNumber).addComponent(jXDatePicker2, - GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE))) - .addGroup(panelCartolaLayout.createSequentialGroup().addComponent(añadir).addGap(125, - 125, 125)) - .addGroup(panelCartolaLayout.createSequentialGroup().addComponent(modificar).addGap(105, - 105, 105))) - .addGap(62, 62, 62))); - panelCartolaLayout.setVerticalGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelCartolaLayout.createSequentialGroup().addGroup(panelCartolaLayout - .createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(panelCartolaLayout.createSequentialGroup().addGap(40, 40, 40) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha2).addComponent(jXDatePicker1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDocumento).addComponent(documento, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFD).addComponent(fFD, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDesc).addComponent(fDesc, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lIng).addComponent(fIng, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(fEgr, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE) - .addComponent(lEgr)) - .addGap(18, 18, 18).addComponent(añadir) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha4).addComponent(fNumber, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha3).addComponent(jXDatePicker2, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDocumento1).addComponent(documento1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFD1).addComponent(fFD1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lDesc1).addComponent(fDesc1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lIng1).addComponent(fIng1, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelCartolaLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(fEgr1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE) - .addComponent(lEgr1)) - .addGap(18, 18, 18).addComponent(modificar)) - .addGroup(GroupLayout.Alignment.LEADING, - panelCartolaLayout.createSequentialGroup().addGap(20, 20, 20) - .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(eliminar))) - .addGap(29, 29, 29))); - panel.add(panelCartola, "card2"); - graphMes = crearGraphMes(); - graphDoc = crearGraphDoc(); - panelResumen.setBackground(new Color(21, 21, 21)); - panelResumen.setForeground(new Color(255, 255, 255)); - graph.setBackground(new Color(153, 153, 153)); - graph.setLayout(new CardLayout()); - graph.add(graphMes, "Mes"); - graphDoc.setBackground(new Color(255, 255, 255)); - graphDoc.setLayout(new BorderLayout()); - graph.add(graphDoc, "Documento"); - tipoGraph.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - tipoGraph.setModel(new DefaultComboBoxModel<>(new String[] { "Mes", "Documento" })); - tipoGraph.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - comboActionPerformed(evt); - } - }); - jLabel1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - jLabel1.setForeground(new Color(255, 255, 255)); - jLabel1.setText("Seleccionar Grafico:"); - lMes1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lMes1.setForeground(new Color(255, 255, 255)); - lMes1.setText("Mes 1"); - lMes2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lMes2.setForeground(new Color(255, 255, 255)); - lMes2.setText("Mes 2"); - lMes3.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lMes3.setForeground(new Color(255, 255, 255)); - lMes3.setText("Mes 3"); - lMes4.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lMes4.setForeground(new Color(255, 255, 255)); - lMes4.setText("Mes 4"); - lMes5.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lMes5.setForeground(new Color(255, 255, 255)); - lMes5.setText("Mes 5"); - lMes6.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lMes6.setForeground(new Color(255, 255, 255)); - lMes6.setText("Mes 6"); - iM1.setBackground(new Color(0, 204, 204)); - iM2.setBackground(new Color(0, 204, 204)); - iM3.setBackground(new Color(0, 204, 204)); - iM4.setBackground(new Color(0, 204, 204)); - iM5.setBackground(new Color(0, 204, 204)); - iM6.setBackground(new Color(0, 204, 204)); - lIng2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lIng2.setForeground(new Color(255, 255, 255)); - lIng2.setText("Ingresos"); - lEgr2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lEgr2.setForeground(new Color(255, 255, 255)); - lEgr2.setText("Egresos"); - eM2.setBackground(new Color(0, 204, 204)); - eM3.setBackground(new Color(0, 204, 204)); - eM4.setBackground(new Color(0, 204, 204)); - eM5.setBackground(new Color(0, 204, 204)); - eM6.setBackground(new Color(0, 204, 204)); - eM1.setBackground(new Color(0, 204, 204)); - sM2.setBackground(new Color(0, 204, 204)); - sM4.setBackground(new Color(0, 204, 204)); - sM3.setBackground(new Color(0, 204, 204)); - lSaldo2.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lSaldo2.setForeground(new Color(255, 255, 255)); - lSaldo2.setText("Saldo"); - sM6.setBackground(new Color(0, 204, 204)); - sM5.setBackground(new Color(0, 204, 204)); - sM1.setBackground(new Color(0, 204, 204)); - jLabel2.setFont(new Font("Eras Light ITC", 0, 36)); // NOI18N - jLabel2.setForeground(new Color(255, 255, 255)); - jLabel2.setText("Balance Mensual"); - GroupLayout panelResumenLayout = new GroupLayout(panelResumen); - panelResumen.setLayout(panelResumenLayout); - panelResumenLayout - .setHorizontalGroup(panelResumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelResumenLayout.createSequentialGroup() - .addContainerGap().addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( - lIng2, javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, - panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lSaldo2).addComponent(lEgr2))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, - Short.MAX_VALUE) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, - panelResumenLayout.createSequentialGroup() - .addComponent( - jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 310, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(116, 116, 116)) - .addGroup(panelResumenLayout.createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(sM1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM1, javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lMes1)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lMes2) - .addComponent(sM2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lMes3) - .addGroup(panelResumenLayout.createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(sM3, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM3, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM3, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(sM4, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(sM5, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18).addComponent(sM6, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(eM4, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(eM5, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18).addComponent(eM6, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(iM4, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lMes4)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(iM5, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lMes5)) - .addGap(18, 18, 18) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(lMes6) - .addComponent(iM6, - javax.swing.GroupLayout.PREFERRED_SIZE, - 63, - javax.swing.GroupLayout.PREFERRED_SIZE)))))) - .addGap(35, 35, 35))) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout.createSequentialGroup().addComponent(jLabel1) - .addGap(4, 4, 4) - .addComponent(tipoGraph, javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(graph, javax.swing.GroupLayout.PREFERRED_SIZE, 719, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(6, 6, 6))); - panelResumenLayout - .setVerticalGroup( - panelResumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup( - panelResumenLayout - .createSequentialGroup().addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(graph, javax.swing.GroupLayout.PREFERRED_SIZE, - 449, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(panelResumenLayout.createSequentialGroup().addGap(50, - 50, 50) - .addComponent(jLabel2, - javax.swing.GroupLayout.PREFERRED_SIZE, 52, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(40, 40, 40) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lMes1).addComponent(lMes2) - .addComponent(lMes3).addComponent(lMes4) - .addComponent(lMes5).addComponent(lMes6)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(iM1, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM2, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM4, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM5, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(iM6, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(eM1, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM2, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM4, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM5, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(eM6, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(sM1, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(sM2, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(sM4, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(sM5, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(sM6, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(lIng2) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelResumenLayout - .createParallelGroup( - javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addGap(26, 26, 26) - .addComponent(lSaldo2)) - .addComponent(lEgr2))) - .addGroup(panelResumenLayout - .createSequentialGroup() - .addComponent(iM3, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(eM3, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap( - javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(sM3, - javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE))))) - .addGap(43, 43, 43) - .addGroup(panelResumenLayout - .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(tipoGraph, javax.swing.GroupLayout.PREFERRED_SIZE, - javax.swing.GroupLayout.DEFAULT_SIZE, - javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel1)) - .addGap(0, 65, Short.MAX_VALUE))); - panel.add(panelResumen, "card3"); - panelPrincipal.setBackground(new Color(21, 21, 21)); - pam.setFont(new Font("LM Roman Caps 10", 1, 60)); // NOI18N - pam.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/logo.png"))); // NOI18N - cartola.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - cartola.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/catola.png"))); // NOI18N - cartola.setText("Cartola"); - cartola.setMaximumSize(new Dimension(50, 17)); - cartola.setMinimumSize(new Dimension(50, 17)); - cartola.setPreferredSize(new Dimension(50, 17)); - cartola.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - cartolaActionPerformed(evt); - } - }); - resumen.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - resumen.setIcon(new ImageIcon(getClass().getResource("P.A.M.v2/resumen.png"))); // NOI18N - resumen.setText("Resumen"); - resumen.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - resumenActionPerformed(evt); - } - }); - lUsuario.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lUsuario.setForeground(new Color(0, 204, 204)); - lUsuario.setText("Usuario"); - fUsuario.setEditable(false); - fUsuario.setFocusable(false); - fUsuario.setText(usuario); - fFecha1.setEditable(false); - fFecha1.setFocusable(false); - Calendar c = Calendar.getInstance(); - fFecha1.setText(String.valueOf(c.get(Calendar.DATE)) + "/" + String.valueOf(c.get(Calendar.MONTH)) + "/" - + String.valueOf(c.get(Calendar.YEAR))); - lFecha1.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - lFecha1.setForeground(new Color(0, 204, 204)); - lFecha1.setText("Fecha"); - GroupLayout panelPrincipalLayout = new GroupLayout(panelPrincipal); - panelPrincipal.setLayout(panelPrincipalLayout); - panelPrincipalLayout.setHorizontalGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(panelPrincipalLayout.createSequentialGroup().addGap(21, 21, 21).addComponent(pam) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent(cartola, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addComponent(resumen, GroupLayout.PREFERRED_SIZE, 107, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.TRAILING, false) - .addComponent(lUsuario).addComponent(lFecha1)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(fFecha1).addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, 123, - GroupLayout.PREFERRED_SIZE)) - .addGap(23, 23, 23))); - panelPrincipalLayout.setVerticalGroup(panelPrincipalLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, panelPrincipalLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.LEADING).addComponent( - pam) - .addGroup(panelPrincipalLayout.createSequentialGroup().addGap(7, 7, 7) - .addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.TRAILING) - .addGroup(panelPrincipalLayout.createSequentialGroup() - .addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lUsuario).addComponent(fUsuario, - GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE)) - .addGap(6, 6, 6) - .addGroup(panelPrincipalLayout - .createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(lFecha1).addComponent(fFecha1, - GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE))) - .addGroup(panelPrincipalLayout - .createParallelGroup( - GroupLayout.Alignment.BASELINE) - .addComponent(cartola, GroupLayout.PREFERRED_SIZE, 27, - GroupLayout.PREFERRED_SIZE) - .addComponent(resumen, GroupLayout.PREFERRED_SIZE, 27, - GroupLayout.PREFERRED_SIZE))))))); - GroupLayout layout = new GroupLayout(principal.getContentPane()); - principal.getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup().addGap(0, 0, 0) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(panelPrincipal, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE) - .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE)))); - layout.setVerticalGroup( - layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(GroupLayout.Alignment.TRAILING, - layout.createSequentialGroup() - .addComponent(panelPrincipal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, - GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0).addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, - Short.MAX_VALUE))); - principal.pack(); - principal.setLocationRelativeTo(null); - principal.setVisible(true); - } - private void resumenActionPerformed(ActionEvent evt) - { - actualizarGraphMes(); - actualizarGraphDoc(); - llenarResumen(); - CardLayout cardLayout = (CardLayout) panel.getLayout(); - cardLayout.show(panel, "card3"); - } - private void cartolaActionPerformed(ActionEvent evt) - { - CardLayout cardLayout = (CardLayout) panel.getLayout(); - cardLayout.show(panel, "card2"); - } - private void modificarActionPerformed(ActionEvent evt) - { - modificarFila(); - } - private void añadirActionPerformed(ActionEvent evt) - { - añadirFila(); - } - private void eliminarActionPerformed(ActionEvent evt) - { - ControlPrincipal control = new ControlPrincipal(usuario); - control.eliminarFila((String) tabla.getValueAt(tabla.getSelectedRow(), 0)); - iniciarTabla(); - } - private void comboActionPerformed(ActionEvent evt) - { - CardLayout cardLayout = (CardLayout) graph.getLayout(); - cardLayout.show(graph, (String) tipoGraph.getSelectedItem()); - } - private void añadirFila() - { - ControlPrincipal control = new ControlPrincipal(usuario); - SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); - String fecha = formateador.format(jXDatePicker1.getDate()); - String documento = this.documento.getSelectedItem().toString(); - String fD = fFD.getText(); - fFD.setText(""); - String desc = fDesc.getText(); - fDesc.setText(""); - String ing = fIng.getText(); - fIng.setText("0"); - String egr = fEgr.getText(); - fEgr.setText("0"); - control.añadir(fecha, documento, fD, desc, ing, egr); - Object[] fila = control.getLastRow(); - DefaultTableModel modelo = (DefaultTableModel) tabla.getModel(); - modelo.addRow(fila); - tabla.setModel(modelo); - } - private void iniciarTabla() - { - ControlPrincipal control = new ControlPrincipal(usuario); - if (control.isFiled()) - { - control.actSaldos(); - DefaultTableModel modelo = (DefaultTableModel) tabla.getModel(); - modelo.setRowCount(0); - tabla.setModel(modelo); - for (int x = 0; x < control.getRowCount(); x++) - { - Object[] fila = control.getRow(x); - modelo.addRow(fila); - } - tabla.setModel(modelo); - } - } - private void modificarFila() - { - SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy"); - String number = fNumber.getText(); - String fecha = formateador.format(jXDatePicker2.getDate()); - String documento = this.documento1.getSelectedItem().toString(); - String fD = fFD1.getText(); - String desc = fDesc1.getText(); - String ing = fIng1.getText(); - String egr = fEgr1.getText(); - ControlPrincipal control = new ControlPrincipal(usuario); - control.modificarFila(number, fecha, documento, fD, desc, ing, egr); - iniciarTabla(); - } - private void llenarResumen() - { - ControlPrincipal control = new ControlPrincipal(usuario); - String[][] resumen = control.resumenMes(); - ArrayList lMeses = new ArrayList(); - ArrayList fIngresos = new ArrayList(); - ArrayList fEgresos = new ArrayList(); - ArrayList fSaldo = new ArrayList(); - lMeses.add(lMes1); - lMeses.add(lMes2); - lMeses.add(lMes3); - lMeses.add(lMes4); - lMeses.add(lMes5); - lMeses.add(lMes6); - fIngresos.add(iM1); - fIngresos.add(iM2); - fIngresos.add(iM3); - fIngresos.add(iM4); - fIngresos.add(iM5); - fIngresos.add(iM6); - fEgresos.add(eM1); - fEgresos.add(eM2); - fEgresos.add(eM3); - fEgresos.add(eM4); - fEgresos.add(eM5); - fEgresos.add(eM6); - fSaldo.add(sM1); - fSaldo.add(sM2); - fSaldo.add(sM3); - fSaldo.add(sM4); - fSaldo.add(sM5); - fSaldo.add(sM6); - if (resumen[0][0] != null) - { - for (int x = resumen[0].length - 1, z = lMeses.size() - 1; x > resumen[0].length - 7&& x >= 0; x--, z--) - { - System.out.println(x); - fIngresos.get(z).setText(resumen[2][x]); - fEgresos.get(z).setText(resumen[3][x]); - fSaldo.get(z).setText(resumen[1][x]); - if (resumen[0][x].matches("[0-9]{4}-01")) - { - lMeses.get(z).setText("Enero"); - } else if (resumen[0][x].matches("[0-9]{4}-02")) - { - lMeses.get(z).setText("Febrero"); - } else if (resumen[0][x].matches("[0-9]{4}-03")) - { - lMeses.get(z).setText("Marzo"); - } else if (resumen[0][x].matches("[0-9]{4}-04")) - { - lMeses.get(z).setText("Abril"); - } else if (resumen[0][x].matches("[0-9]{4}-05")) - { - lMeses.get(z).setText("Mayo"); - } else if (resumen[0][x].matches("[0-9]{4}-06")) - { - lMeses.get(z).setText("Junio"); - } else if (resumen[0][x].matches("[0-9]{4}-07")) - { - lMeses.get(z).setText("Julio"); - } else if (resumen[0][x].matches("[0-9]{4}-08")) - { - lMeses.get(z).setText("Agosto"); - } else if (resumen[0][x].matches("[0-9]{4}-09")) - { - lMeses.get(z).setText("Septiembre"); - } else if (resumen[0][x].matches("[0-9]{4}-10")) - { - lMeses.get(z).setText("Octubre"); - } else if (resumen[0][x].matches("[0-9]{4}-11")) - { - lMeses.get(z).setText("Noviembre"); - } else if (resumen[0][x].matches("[0-9]{4}-12")) - { - lMeses.get(z).setText("Diciembre"); - } - } - } - } - private ChartPanel crearGraphMes() - { - ControlPrincipal control = new ControlPrincipal(usuario); - String[][] resumen = control.resumenMes(); - dataSetMes = new DefaultCategoryDataset(); - 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]); - } - } - JFreeChart chart = ChartFactory.createBarChart("Resumen Mensual", "Mes", "Saldo", dataSetMes, - PlotOrientation.VERTICAL, false, true, false); - chart.getPlot().setBackgroundPaint(new Color(0, 204, 204)); - chart.getCategoryPlot().getRenderer().setSeriesPaint(0, new Color(21, 21, 21)); - chart.setBackgroundPaint(new Color(0, 204, 204)); - ChartPanel graph = new ChartPanel(chart); - return graph; - } - private ChartPanel crearGraphDoc() - { - ControlPrincipal control = new ControlPrincipal(usuario); - int[] resumen = control.resumenDoc(); - dataSetDoc = new DefaultCategoryDataset(); - dataSetDoc.setValue(resumen[0], "Saldo", "Efectivo"); - dataSetDoc.setValue(resumen[1], "Saldo", "Transferencia"); - dataSetDoc.setValue(resumen[2], "Saldo", "Credito"); - JFreeChart chart = ChartFactory.createBarChart("Resumen por Documentos", "Documento", "Saldo", dataSetDoc, - PlotOrientation.VERTICAL, false, true, false); - chart.getPlot().setBackgroundPaint(new Color(0, 204, 204)); - chart.getCategoryPlot().getRenderer().setSeriesPaint(0, new Color(21, 21, 21)); - chart.setBackgroundPaint(new Color(0, 204, 204)); - 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/visual/Registro.java b/src/visual/Registro.java deleted file mode 100644 index 84e1d7e..0000000 --- a/src/visual/Registro.java +++ /dev/null @@ -1,161 +0,0 @@ -package visual; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import utiles.ControlLogin; - -public class Registro -{ - private JFrame frame; - private JButton bRegister; - private JButton bSalir; - private JLabel bienvenido; - private JPasswordField fPass; - private JPasswordField fPass2; - private JTextField fUser; - private JLabel lPass; - private JLabel lPass2; - private JLabel lUser; - private JPanel panel; - private JLabel registrarse; - private JPanel registro; - - public Registro() - { - initComponents(); - } - private void initComponents() - { - frame = new JFrame(); - panel = new JPanel(); - registro = new JPanel(); - registrarse = new JLabel(); - bienvenido = new JLabel(); - bRegister = new JButton(); - bSalir = new JButton(); - fUser = new JTextField(); - lUser = new JLabel(); - lPass = new JLabel(); - lPass2 = new JLabel(); - fPass = new JPasswordField(); - fPass2 = new JPasswordField(); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.setResizable(false); - panel.setBackground(new Color(204, 204, 204)); - panel.setRequestFocusEnabled(false); - panel.setLayout(new CardLayout()); - registro.setBackground(new Color(21, 21, 21)); - registrarse.setBackground(new Color(0, 204, 204)); - registrarse.setFont(new Font("Eras Light ITC", 2, 48)); // NOI18N - registrarse.setForeground(new Color(0, 204, 204)); - registrarse.setText("Registrarse!"); - bienvenido.setFont(new Font("Eras Light ITC", 0, 14)); // NOI18N - bienvenido.setForeground(new Color(255, 255, 255)); - bienvenido.setText("Bienvenido a P.A.M!"); - bRegister.setText("Registrarse"); - bRegister.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - bRegisterActionPerformed(evt); - } - }); - bSalir.setText("Salir"); - bSalir.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent evt) - { - bSalirActionPerformed(evt); - } - }); - lUser.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lUser.setForeground(new Color(0, 204, 204)); - lUser.setText("Usuario"); - lPass.setBackground(new Color(0, 204, 204)); - lPass.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lPass.setForeground(new Color(0, 204, 204)); - lPass.setText("Contraseña"); - lPass2.setFont(new Font("Eras Light ITC", 0, 18)); // NOI18N - lPass2.setForeground(new Color(0, 204, 204)); - lPass2.setText("Verificar Contraseña"); - GroupLayout registroLayout = new GroupLayout(registro); - registro.setLayout(registroLayout); - registroLayout.setHorizontalGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( - GroupLayout.Alignment.TRAILING, - registroLayout.createSequentialGroup().addContainerGap(272, Short.MAX_VALUE).addGroup(registroLayout - .createParallelGroup(GroupLayout.Alignment.LEADING).addGroup( - registroLayout.createSequentialGroup().addGap(33, 33, 33).addGroup(registroLayout - .createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(registroLayout.createSequentialGroup().addGap(52, 52, 52) - .addComponent(lUser)) - .addGroup(registroLayout.createSequentialGroup().addGap(34, 34, 34) - .addComponent(lPass)) - .addGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) - .addComponent(fUser, GroupLayout.PREFERRED_SIZE, 161, - GroupLayout.PREFERRED_SIZE) - .addComponent(fPass, GroupLayout.PREFERRED_SIZE, 161, - GroupLayout.PREFERRED_SIZE)) - .addGroup(registroLayout - .createParallelGroup(GroupLayout.Alignment.TRAILING, false) - .addGroup(GroupLayout.Alignment.LEADING, - registroLayout.createSequentialGroup().addComponent(bRegister) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, - GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(bSalir)) - .addComponent(fPass2, GroupLayout.Alignment.LEADING, - GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE)) - .addComponent(lPass2))) - .addComponent(registrarse)).addGap(266, 266, 266)) - .addGroup(registroLayout.createSequentialGroup().addGap(323, 323, 323) - .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - registroLayout - .setVerticalGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(registroLayout.createSequentialGroup().addContainerGap() - .addComponent(registrarse, GroupLayout.PREFERRED_SIZE, 59, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) - .addGap(32, 32, 32).addComponent(lUser) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fUser, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(lPass) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(fPass, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(lPass2) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(fPass2, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) - .addGap(18, 18, 18) - .addGroup(registroLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(bRegister).addComponent(bSalir)) - .addContainerGap(76, Short.MAX_VALUE))); - panel.add(registro, "card2"); - GroupLayout layout = new GroupLayout(frame.getContentPane()); - frame.getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup().addGap(0, 0, 0).addComponent(panel, GroupLayout.DEFAULT_SIZE, - GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) - .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); - frame.pack(); - frame.getRootPane().setDefaultButton(bRegister); - frame.setVisible(true); - frame.setLocationRelativeTo(null); - } - private void bRegisterActionPerformed(ActionEvent evt) - { - ControlLogin control = new ControlLogin(); - if(control.añadirUsuario(fUser.getText(), String.valueOf(fPass.getPassword()), String.valueOf(fPass2.getPassword()))) - { - Login login = new Login(); - frame.dispose(); - } - } - private void bSalirActionPerformed(ActionEvent evt) - { - Login login = new Login(); - frame.dispose(); - } -} diff --git a/src/visualV2/FrameAdministrador.java b/src/visualV2/FrameAdministrador.java new file mode 100644 index 0000000..21c1920 --- /dev/null +++ b/src/visualV2/FrameAdministrador.java @@ -0,0 +1,163 @@ +package visualV2; + +import javax.swing.*; +import javax.swing.table.*; + +import control.ControlAdmin; + +import java.awt.*; +import java.awt.event.*; + +public class FrameAdministrador extends JFrame { + + private JButton bCrear; + private JButton bModificar; + private JScrollPane jScrollPane1; + private JPanel panel; + private JTable tabla; + + public FrameAdministrador() { + initComponents(); + actTabla(); + } + + private void initComponents() { + + panel = new JPanel(); + jScrollPane1 = new JScrollPane(); + tabla = new JTable(); + bModificar = new JButton(); + bCrear = new JButton(); + + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + + @Override + public void windowClosing(WindowEvent e) { + new FrameLogin(); + setVisible(false); + dispose(); + } + }); + + panel.setBackground(new Color(0, 128, 128)); + + jScrollPane1.setBackground(new Color(128, 203, 196)); + + tabla.setBackground(new Color(178, 223, 219)); + tabla.setFont(new Font("Candara", 0, 13)); // NOI18N + tabla.setForeground(new Color(21, 21, 21)); + tabla.setModel( + new DefaultTableModel(new Object[][] { { null, null } }, new String[] { "Usuario", "Contraseña" }) { + boolean[] canEdit = new boolean[] { false, false }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit[columnIndex]; + } + }); + tabla.setGridColor(new Color(255, 255, 255)); + tabla.setOpaque(false); + tabla.setSelectionForeground(new Color(0, 120, 215)); + jScrollPane1.setViewportView(tabla); + + bModificar.setBackground(new Color(33, 150, 243)); + bModificar.setText("Modificar usuario"); + bModificar.setContentAreaFilled(false); + bModificar.setOpaque(true); + bModificar.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + + bModificarActionPerformed(evt); + + } + + }); + + bCrear.setBackground(new Color(33, 150, 243)); + bCrear.setText("Crear Usuario"); + bCrear.setContentAreaFilled(false); + bCrear.setOpaque(true); + bCrear.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + + bCrearActionPerformed(evt); + + } + + }); + + GroupLayout panelLayout = new GroupLayout(panel); + panel.setLayout(panelLayout); + panelLayout + .setHorizontalGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(GroupLayout.Alignment.TRAILING, panelLayout.createSequentialGroup().addContainerGap() + .addComponent(bCrear, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(bModificar, GroupLayout.PREFERRED_SIZE, 177, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup().addContainerGap() + .addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE) + .addContainerGap()))); + panelLayout.setVerticalGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(GroupLayout.Alignment.TRAILING, + panelLayout.createSequentialGroup().addContainerGap(447, Short.MAX_VALUE) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(bModificar).addComponent(bCrear)) + .addContainerGap()) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup() + .addContainerGap().addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap(43, Short.MAX_VALUE)))); + + GroupLayout layout = new GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(panel, + GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(0, 0, 0))); + pack(); + setVisible(true); + setLocationRelativeTo(null); + } + + protected void bCrearActionPerformed(ActionEvent evt) { + new FrameCrear(); + setVisible(false); + dispose(); + + } + + protected void bModificarActionPerformed(ActionEvent evt) { + new FrameModificar(); + setVisible(false); + dispose(); + + } + + public void actTabla() { + + ControlAdmin control = new ControlAdmin(); + DefaultTableModel modelo = (DefaultTableModel) tabla.getModel(); + + tabla.setModel(modelo); + modelo.setRowCount(0); + + for (int x = 0; x < control.getRowCount(); x++) { + + Object[] fila = control.getRow(x); + modelo.addRow(fila); + + } + + } + + +} diff --git a/src/visualV2/FrameCrear.java b/src/visualV2/FrameCrear.java new file mode 100644 index 0000000..15557f7 --- /dev/null +++ b/src/visualV2/FrameCrear.java @@ -0,0 +1,109 @@ +package visualV2; + +import javax.swing.*; + +import control.ControlAdmin; + +import java.awt.event.*; +import java.awt.*; + +public class FrameCrear extends JFrame { + + private JButton bCrear; + private JTextField fContraseña; + private JTextField fUsuario; + private JLabel lContraseña; + private JLabel lUsuario; + private JPanel panel; + + public FrameCrear() { + initComponents(); + } + + private void initComponents() { + + panel = new JPanel(); + bCrear = new JButton(); + lUsuario = new JLabel(); + lContraseña = new JLabel(); + fUsuario = new JTextField(); + fContraseña = new JTextField(); + + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + panel.setBackground(new Color(0, 128, 128)); + + bCrear.setBackground(new Color(33, 150, 243)); + bCrear.setText("Crear Usuario"); + bCrear.setContentAreaFilled(false); + bCrear.setOpaque(true); + bCrear.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + bCrearActionPerformed(evt); + } + }); + + lUsuario.setBackground(new Color(0, 204, 204)); + lUsuario.setFont(new Font("Candara", 1, 14)); // NOI18N + lUsuario.setForeground(new Color(255, 255, 255)); + lUsuario.setText("Usuario:"); + + lContraseña.setBackground(new Color(0, 204, 204)); + lContraseña.setFont(new Font("Candara", 1, 14)); // NOI18N + lContraseña.setForeground(new Color(255, 255, 255)); + lContraseña.setText("Contraseña:"); + + fUsuario.setToolTipText(""); + + fContraseña.setToolTipText(""); + + GroupLayout panelLayout = new GroupLayout(panel); + panel.setLayout(panelLayout); + panelLayout.setHorizontalGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup().addGap(29, 29, 29) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lContraseña, GroupLayout.Alignment.TRAILING) + .addComponent(lUsuario, GroupLayout.Alignment.TRAILING)) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(fContraseña, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) + .addComponent(fUsuario).addComponent(bCrear, GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(48, 48, 48))); + panelLayout.setVerticalGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup().addGap(21, 21, 21) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(lUsuario).addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lContraseña).addComponent(fContraseña, + GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(bCrear) + .addContainerGap(18, Short.MAX_VALUE))); + + GroupLayout layout = new GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent( + panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); + layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup().addComponent(panel, GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addGap(0, 0, 0))); + + pack(); + setVisible(true); + setLocationRelativeTo(null); + + } + + private void bCrearActionPerformed(ActionEvent evt) { + ControlAdmin control = new ControlAdmin(); + if(control.añadirUsuario(fUsuario.getText(), fContraseña.getText())){ + new FrameAdministrador(); + setVisible(false); + dispose(); + } + } + +} diff --git a/src/visualV2/FrameLogin.java b/src/visualV2/FrameLogin.java index 113424d..7460dd9 100644 --- a/src/visualV2/FrameLogin.java +++ b/src/visualV2/FrameLogin.java @@ -2,46 +2,72 @@ package visualV2; import java.awt.event.*; import javax.swing.*; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; 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; - + private JButton bIngresar; + private JButton bRegistrar; + private JButton bSalir; + private JPanel bar; + private JLabel bienvenido; + private JPasswordField fContraseña1; + private JTextField fUsuario; + private JLabel lContraseña; + private JLabel lUsuario; + private JLabel pam; + private JPanel panel; + private JMenuBar menubar; + private JMenu menu; + 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(); + panel = new JPanel(); + pam = new JLabel(); + bienvenido = new JLabel(); + bar = new JPanel(); + lUsuario = new JLabel(); + fUsuario = new JTextField(); + lContraseña = new JLabel(); + fContraseña1 = new JPasswordField(); + bIngresar = new JButton(); + bRegistrar = new JButton(); + bSalir = new JButton(); - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(21, 21, 21)); - setMaximumSize(null); - setMinimumSize(null); + menubar = new JMenuBar(); + menu = new JMenu("Administrador"); + + menu.addMenuListener(new MenuListener() { + + @Override + public void menuSelected(MenuEvent e) { + + openAdmin(); + menu.setSelected(false); + } + + @Override + public void menuDeselected(MenuEvent e) { + } + + @Override + public void menuCanceled(MenuEvent e) { + + } + }); + menubar.add(menu); + setJMenuBar(menubar); + panel.setBackground(new java.awt.Color(0, 128, 128)); pam.setFont(new java.awt.Font("Candara", 1, 60)); // NOI18N @@ -55,14 +81,14 @@ public class FrameLogin extends JFrame { 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); + GroupLayout barLayout = new GroupLayout(bar); bar.setLayout(barLayout); barLayout.setHorizontalGroup( - barLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + barLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGap(0, 251, Short.MAX_VALUE) ); barLayout.setVerticalGroup( - barLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + barLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGap(0, 9, Short.MAX_VALUE) ); @@ -97,60 +123,60 @@ public class FrameLogin extends JFrame { }); - javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel); + GroupLayout panelLayout = new GroupLayout(panel); panel.setLayout(panelLayout); panelLayout.setHorizontalGroup( - panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + panelLayout.createParallelGroup(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) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.CENTER) + .addComponent(bar, GroupLayout.PREFERRED_SIZE, 251, 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(bIngresar, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE) + .addComponent(bSalir, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE) + .addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE) .addComponent(lUsuario) .addComponent(lContraseña) - .addComponent(fContraseña1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(fContraseña1, GroupLayout.PREFERRED_SIZE, 161, GroupLayout.PREFERRED_SIZE)) .addContainerGap(94, Short.MAX_VALUE)) ); panelLayout.setVerticalGroup( - panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(panelLayout.createSequentialGroup() .addGap(29, 29, 29) - .addComponent(pam, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(pam, GroupLayout.PREFERRED_SIZE, 52, 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) + .addComponent(bienvenido, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(bar, GroupLayout.PREFERRED_SIZE, 9, 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) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(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) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(fContraseña1, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(bIngresar) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(bRegistrar) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(bSalir) .addContainerGap(17, Short.MAX_VALUE)) ); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + GroupLayout layout = new 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.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(panel, GroupLayout.DEFAULT_SIZE, 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) + layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); try { @@ -189,7 +215,6 @@ public class FrameLogin extends JFrame { private void bSalirActionPerformed(ActionEvent evt) { - System.exit(0); } @@ -197,10 +222,21 @@ public class FrameLogin extends JFrame { private void bRegistrarActionPerformed(ActionEvent evt) { FrameRegistro registro = new FrameRegistro(); - dispose(); } + private void openAdmin(){ + String opcion = JOptionPane.showInputDialog("Ingrese codigo de administrador"); + if(opcion!=null){ + if(opcion.equals("7419")){ + new FrameAdministrador(); + setVisible(false); + dispose(); + }else{ + JOptionPane.showMessageDialog(null, "Codigo incorrecto"); + } + } + } } diff --git a/src/visualV2/FrameModificar.java b/src/visualV2/FrameModificar.java new file mode 100644 index 0000000..a88c1bc --- /dev/null +++ b/src/visualV2/FrameModificar.java @@ -0,0 +1,159 @@ +package visualV2; + +import javax.swing.*; + +import control.ControlAdmin; + +import java.awt.event.*; +import java.awt.*; + +public class FrameModificar extends JFrame { + + private JButton bModificar; + private JComboBox boxUsuario; + private JTextField fContraseña; + private JTextField fUsuario; + private JLabel lContraseña; + private JLabel lSelectUsuario; + private JLabel lUsuario; + private JPanel panel; + + public FrameModificar() { + initComponents(); + } + + private void initComponents() { + + panel = new JPanel(); + bModificar = new JButton(); + lUsuario = new JLabel(); + lContraseña = new JLabel(); + fUsuario = new JTextField(); + fContraseña = new JTextField(); + boxUsuario = new JComboBox<>(); + lSelectUsuario = new JLabel(); + + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + + @Override + public void windowClosing(WindowEvent e) { + new FrameAdministrador(); + setVisible(false); + dispose(); + } + }); + + panel.setBackground(new Color(0, 128, 128)); + + bModificar.setBackground(new Color(33, 150, 243)); + bModificar.setText("Modificar"); + bModificar.setContentAreaFilled(false); + bModificar.setOpaque(true); + bModificar.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + bModificarActionPerformed(evt); + } + }); + + lUsuario.setBackground(new Color(0, 204, 204)); + lUsuario.setFont(new Font("Candara", 1, 14)); // NOI18N + lUsuario.setForeground(new Color(255, 255, 255)); + lUsuario.setText("Usuario:"); + + lContraseña.setBackground(new Color(0, 204, 204)); + lContraseña.setFont(new Font("Candara", 1, 14)); // NOI18N + lContraseña.setForeground(new Color(255, 255, 255)); + lContraseña.setText("Contraseña:"); + + fUsuario.setToolTipText(""); + + fContraseña.setToolTipText(""); + + boxUsuario.setModel(new DefaultComboBoxModel<>(new String[] {})); + llenarBox(); + boxUsuario.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + boxUsuarioActionPerformed(evt); + } + }); + boxUsuarioActionPerformed(null); + + lSelectUsuario.setBackground(new Color(0, 204, 204)); + lSelectUsuario.setFont(new Font("Candara", 1, 14)); // NOI18N + lSelectUsuario.setForeground(new Color(255, 255, 255)); + lSelectUsuario.setText("Seleccione usuario:"); + + GroupLayout panelLayout = new GroupLayout(panel); + panel.setLayout(panelLayout); + panelLayout.setHorizontalGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup().addGap(35, 35, 35) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.TRAILING) + .addComponent(lContraseña).addComponent(lUsuario).addComponent(lSelectUsuario)) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(boxUsuario, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(fContraseña, GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE) + .addComponent(fUsuario).addComponent(bModificar, GroupLayout.DEFAULT_SIZE, + GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGap(42, 42, 42))); + panelLayout.setVerticalGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addGroup(panelLayout.createSequentialGroup().addGap(25, 25, 25) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(boxUsuario, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(lSelectUsuario)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(fUsuario, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE) + .addComponent(lUsuario)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(lContraseña).addComponent(fContraseña, GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(bModificar) + .addContainerGap(29, Short.MAX_VALUE))); + + GroupLayout layout = new GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(panel, + GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(panel, + GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + + pack(); + setVisible(true); + setLocationRelativeTo(null); + } + + protected void boxUsuarioActionPerformed(ActionEvent evt) { + ControlAdmin control = new ControlAdmin(); + for(int x = 0; x < control.getRowCount(); x++){ + if(control.getRow(x)[0].equals(boxUsuario.getSelectedItem())){ + fContraseña.setText(control.getRow(x)[1]); + fUsuario.setText(control.getRow(x)[0]); + } + } + } + + protected void bModificarActionPerformed(ActionEvent evt) { + ControlAdmin control = new ControlAdmin(); + String original = control.getRow(boxUsuario.getSelectedIndex())[0]+";"+control.getRow(boxUsuario.getSelectedIndex())[1]; + if(control.modificarUser(original, fUsuario.getText(), fContraseña.getText())){ + new FrameAdministrador(); + setVisible(false); + dispose(); + } + } + + private void llenarBox(){ + + ControlAdmin control = new ControlAdmin(); + boxUsuario.removeAllItems(); + for(int x = 0 ; x < control.getRowCount(); x++){ + boxUsuario.addItem(control.getRow(x)[0]); + } + + } +} diff --git a/src/visualV2/FramePrincipal.java b/src/visualV2/FramePrincipal.java index 2e632e6..97ec0ac 100644 --- a/src/visualV2/FramePrincipal.java +++ b/src/visualV2/FramePrincipal.java @@ -2,6 +2,7 @@ package visualV2; import javax.swing.*; import java.awt.*; +import java.awt.event.ActionEvent; public class FramePrincipal extends JFrame { @@ -25,10 +26,8 @@ public class FramePrincipal extends JFrame { 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()); @@ -49,11 +48,12 @@ public class FramePrincipal extends JFrame { 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))); + .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, @@ -70,9 +70,22 @@ public class FramePrincipal extends JFrame { | UnsupportedLookAndFeelException e) { e.printStackTrace(); } - + pack(); + setResizable(false); setVisible(true); + setLocationRelativeTo(null); + } + + protected void salir(ActionEvent evt) { + Object[] opciones = {"Si","No"}; + if(JOptionPane.showOptionDialog( + null,"¿Esta seguro?", "Salir", JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE, null,opciones,"Si") + == 0){ + System.exit(0); + } + } public void toCartola() {