Proyecto en un 99%

Se separaron los diferentes paneles de la pantalla principal en clases
distintas para un codigo mas simple
aparte de la correccion de algunos problemas
seguramente lo que queda seran pequeños bugs y cosas que no se pensaron
This commit is contained in:
Ryuuji
2016-11-15 20:45:30 -04:00
parent f9744e8d6a
commit cab1aea20e
47 changed files with 2154 additions and 254 deletions

9
.classpath Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/jcommon-1.0.23.jar"/>
<classpathentry kind="lib" path="lib/jfreechart-1.0.19.jar"/>
<classpathentry kind="lib" path="lib/swingx-all-1.6.4.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Pam</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,105 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/utiles/Validador.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/visual/FrameLogin.class Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/jcommon-1.0.23.jar Normal file

Binary file not shown.

BIN
lib/jfreechart-1.0.19.jar Normal file

Binary file not shown.

BIN
lib/swingx-all-1.6.4.jar Normal file

Binary file not shown.

View File

@@ -1,9 +1,7 @@
package main; package main;
public class Main public class Main {
{ public static void main(String[] args) {
public static void main(String[] args) visual.FrameLogin login = new visual.FrameLogin();
{
visual.Login login = new visual.Login();
} }
} }

View File

@@ -7,177 +7,166 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
public class Archivo public class Archivo {
{
protected File archivo; protected File archivo;
protected FileReader fr; protected FileReader fr;
protected BufferedReader br; protected BufferedReader br;
protected FileWriter fw; protected FileWriter fw;
public Archivo(String archivo) public Archivo(String archivo) {
{
String ruta = getRuta(archivo); String ruta = getRuta(archivo);
try try {
{
this.archivo = new File(ruta); this.archivo = new File(ruta);
if (!this.archivo.exists()) if (!this.archivo.exists()) {
{
this.archivo.createNewFile(); this.archivo.createNewFile();
} }
} catch (Exception e) } catch (Exception e) {
{
} }
} }
public String getRuta(String archivo)
{ public String getRuta(String archivo) {
String ruta = ""; String ruta = "";
String os = System.getProperty("os.name"); String os = System.getProperty("os.name");
if (os.contains("Windows")) if (os.contains("Windows")) {
{
ruta = "C:\\P.A.M\\"; ruta = "C:\\P.A.M\\";
new File(ruta).mkdir(); new File(ruta).mkdir();
ruta+= archivo; ruta += archivo;
} else if (os.contains("Linux")) } else if (os.contains("Linux")) {
{
ruta = System.getProperty("user.home") + "/P.A.M/"; ruta = System.getProperty("user.home") + "/P.A.M/";
new File(ruta).mkdir(); new File(ruta).mkdir();
ruta += archivo; ruta += archivo;
} }
return ruta; return ruta;
} }
public String leerArchivo()
{ public String leerArchivo() {
abrirLeer(); abrirLeer();
String cadena = ""; String cadena = "";
String cadenaFinal = ""; String cadenaFinal = "";
try try {
{ while ((cadena = br.readLine()) != null) {
while ((cadena = br.readLine()) != null)
{
cadenaFinal += cadena; cadenaFinal += cadena;
} }
} catch (IOException e) } catch (IOException e) {
{
System.out.println("Error en br.readLine()"); System.out.println("Error en br.readLine()");
} }
cerrarLeer(); cerrarLeer();
return cadenaFinal; return cadenaFinal;
} }
public void escribirArchivo(String texto)
{ public void escribirArchivo(String texto) {
abrirEscribir(); abrirEscribir();
try try {
{
fw.append(texto + "*!"); fw.append(texto + "*!");
} catch (IOException e) } catch (IOException e) {
{
System.out.println("Error en fw.write(texto)"); System.out.println("Error en fw.write(texto)");
} }
cerrarEscribir(); cerrarEscribir();
} }
public String[] entregarProcesado()
{ public String[] entregarProcesado() {
String[] datos; String[] datos;
datos = leerArchivo().split("\\*!"); datos = leerArchivo().split("\\*!");
return datos; return datos;
} }
public void borrarLinea(String id)
{ public void borrarLinea(String id) {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
for (int x = 0; x < arch.length; x++)
{ if(arch.length > 1){
if (arch[x].split(";")[0].equals(id))
{ for (int x = 0; x < arch.length; x++) {
arch[x] = "";
break; if (arch[x].split(";")[0].equals(id)) {
arch[x] = "";
break;
}
} }
}
String[] nArch = new String[arch.length - 1]; String[] nArch = new String[arch.length - 1];
int z = 0; int z = 0;
for (int x = 0; x < arch.length; x++)
{ for (int x = 0; x < arch.length; x++) {
if (arch[x].length() > 1)
{ if (arch[x].length() > 1) {
nArch[z] = arch[x];
z++; nArch[z] = arch[x];
z++;
}
} }
actArchivo(nArch);
}else{
clearFile();
} }
actArchivo(nArch);
} }
public void actArchivo(String[] texto)
{ public void actArchivo(String[] texto) {
clearFile(); clearFile();
abrirEscribir(); abrirEscribir();
for (int x = 0; x < texto.length; x++) for (int x = 0; x < texto.length; x++) {
{ try {
try
{
fw.append(texto[x] + "*!"); fw.append(texto[x] + "*!");
} catch (IOException e) } catch (IOException e) {
{
} }
} }
cerrarEscribir(); cerrarEscribir();
} }
public void clearFile()
{ public void clearFile() {
try try {
{
fw = new FileWriter(archivo, false); fw = new FileWriter(archivo, false);
fw.write(""); fw.write("");
fw.close(); fw.close();
} catch (IOException e) } catch (IOException e) {
{
System.out.println("Error al instanciar FileWriter"); System.out.println("Error al instanciar FileWriter");
} }
} }
private void abrirLeer()
{ private void abrirLeer() {
try try {
{
fr = new FileReader(archivo); fr = new FileReader(archivo);
} catch (FileNotFoundException e) } catch (FileNotFoundException e) {
{
System.out.println("Error al instanciar FileReader"); System.out.println("Error al instanciar FileReader");
} }
br = new BufferedReader(fr); br = new BufferedReader(fr);
} }
private void cerrarLeer()
{ private void cerrarLeer() {
try try {
{
fr.close(); fr.close();
} catch (IOException e) } catch (IOException e) {
{
System.out.println("Error en fr.close()"); System.out.println("Error en fr.close()");
} }
try try {
{
br.close(); br.close();
} catch (IOException e) } catch (IOException e) {
{
System.out.println("Error en br.close()"); System.out.println("Error en br.close()");
} }
} }
private void abrirEscribir()
{ private void abrirEscribir() {
try try {
{
fw = new FileWriter(archivo, true); fw = new FileWriter(archivo, true);
} catch (IOException e) } catch (IOException e) {
{
System.out.println("Error al instanciar FileWriter"); System.out.println("Error al instanciar FileWriter");
} }
} }
private void cerrarEscribir()
{ private void cerrarEscribir() {
if (fw != null) if (fw != null) {
{ try {
try
{
fw.close(); fw.close();
} catch (IOException e) } catch (IOException e) {
{
System.out.println("No deberia ocurrir, pero weno\nError en fw.close()"); System.out.println("No deberia ocurrir, pero weno\nError en fw.close()");
} }
} }

View File

@@ -11,16 +11,12 @@ import sun.misc.BASE64Encoder;
* *
* @author idelcano * @author idelcano
*/ */
@SuppressWarnings("restriction") public class Cifrador {
public class Cifrador
{
private static Cifrador instancia; private static Cifrador instancia;
private Cifrador() private Cifrador() {};
{
}; public static Cifrador getInstance() {
public static Cifrador getInstance()
{
if (instancia == null) if (instancia == null)
instancia = new Cifrador(); instancia = new Cifrador();
return instancia; return instancia;
@@ -28,73 +24,63 @@ public class Cifrador
byte[] iv = new byte[16]; byte[] iv = new byte[16];
public String cifrar(String clave, String mensaje) public String cifrar(String clave, String mensaje) {
{ try {
try
{
byte[] mensajeSinCifrar = mensaje.getBytes(); byte[] mensajeSinCifrar = mensaje.getBytes();
SecretKeySpec key = crearSecretKeyUsuarioClave(clave, clave); SecretKeySpec key = crearSecretKeyUsuarioClave(clave, clave);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv)); cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
byte[] mensajeCifrado = cipher.doFinal(mensajeSinCifrar); byte[] mensajeCifrado = cipher.doFinal(mensajeSinCifrar);
return codificarBase64(mensajeCifrado); return codificarBase64(mensajeCifrado);
} catch (Exception e) } catch (Exception e) {
{
System.out.println("Error en el cifrado"); System.out.println("Error en el cifrado");
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
public String descifrar(String clave, String mensaje)
{ public String descifrar(String clave, String mensaje) {
try try {
{
SecretKeySpec key = crearSecretKeyUsuarioClave(clave, clave); SecretKeySpec key = crearSecretKeyUsuarioClave(clave, clave);
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
byte[] mensajeCifrado = decodificarBase64(mensaje); byte[] mensajeCifrado = decodificarBase64(mensaje);
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv)); cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
byte[] mensajeDescifrado = cipher.doFinal(mensajeCifrado); byte[] mensajeDescifrado = cipher.doFinal(mensajeCifrado);
return new String(mensajeDescifrado); return new String(mensajeDescifrado);
} catch (Exception e) } catch (Exception e) {
{
return ""; return "";
} }
} }
private String codificarBase64(byte[] output)
{ private String codificarBase64(byte[] output) {
return new BASE64Encoder().encode(output); return new BASE64Encoder().encode(output);
} }
private byte[] decodificarBase64(String cadena)
{ private byte[] decodificarBase64(String cadena) {
try try {
{
return new BASE64Decoder().decodeBuffer(cadena); return new BASE64Decoder().decodeBuffer(cadena);
} catch (IOException ex) } catch (IOException ex) {
{
System.out.println("Error con la decodificacion en base64"); System.out.println("Error con la decodificacion en base64");
ex.printStackTrace(); ex.printStackTrace();
} }
return null; return null;
} }
private SecretKeySpec crearSecretKeyUsuarioClave(String usuario, String clave)
{ private SecretKeySpec crearSecretKeyUsuarioClave(String usuario, String clave) {
iv = truncarkey(usuario); iv = truncarkey(usuario);
byte[] key = clave.getBytes(); byte[] key = clave.getBytes();
key = truncarkey(clave); key = truncarkey(clave);
return new SecretKeySpec(key, "AES"); return new SecretKeySpec(key, "AES");
} }
private byte[] truncarkey(String clave)
{ private byte[] truncarkey(String clave) {
byte[] key = clave.getBytes(); byte[] key = clave.getBytes();
while (key.length != 16) while (key.length != 16) {
{ if (key.length < 16) {
if (key.length < 16)
{
clave += "0"; clave += "0";
key = clave.getBytes(); key = clave.getBytes();
} }
if (key.length > 16) if (key.length > 16) {
{
clave = clave.substring(0, 16); clave = clave.substring(0, 16);
key = clave.getBytes(); // TODO key = clave.getBytes(); // TODO
} }

View File

@@ -1,67 +1,53 @@
package utiles; package utiles;
public class ControlLogin extends Archivo public class ControlLogin extends Archivo {
{ public ControlLogin() {
public ControlLogin()
{
super("userData"); super("userData");
} }
public boolean añadirUsuario(String user, String pass, String pass2)
{ public boolean añadirUsuario(String user, String pass, String pass2) {
if (!isUser(user)) if (!isUser(user)) {
{ if (user.length() > 4) {
if (user.length() > 4) if (pass.equals(pass2)) {
{ if (pass.length() > 6) {
if (pass.equals(pass2))
{
if (pass.length() > 6)
{
escribirArchivo(user + ";" + pass); escribirArchivo(user + ";" + pass);
return true; return true;
} else } else {
{
javax.swing.JOptionPane.showMessageDialog(null, "La contraseña es muy corta", null, javax.swing.JOptionPane.showMessageDialog(null, "La contraseña es muy corta", null,
javax.swing.JOptionPane.ERROR_MESSAGE); javax.swing.JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
} else } else {
{
javax.swing.JOptionPane.showMessageDialog(null, "Las contraseñas no son iguales", null, javax.swing.JOptionPane.showMessageDialog(null, "Las contraseñas no son iguales", null,
javax.swing.JOptionPane.ERROR_MESSAGE); javax.swing.JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
} else } else {
{
javax.swing.JOptionPane.showMessageDialog(null, "El usuario es muy corto", null, javax.swing.JOptionPane.showMessageDialog(null, "El usuario es muy corto", null,
javax.swing.JOptionPane.ERROR_MESSAGE); javax.swing.JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
} else } else {
{
javax.swing.JOptionPane.showMessageDialog(null, "El usuario ya existe ", null, javax.swing.JOptionPane.showMessageDialog(null, "El usuario ya existe ", null,
javax.swing.JOptionPane.ERROR_MESSAGE); javax.swing.JOptionPane.ERROR_MESSAGE);
return false; return false;
} }
} }
public boolean isUser(String user)
{ public boolean isUser(String user) {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
for (int x = 0; x < arch.length; x++) for (int x = 0; x < arch.length; x++) {
{ if (arch[x].split(";")[0].equals(user)) {
if (arch[x].split(";")[0].equals(user))
{
return true; return true;
} }
} }
return false; return false;
} }
public boolean isUserPass(String user,String pass)
{ public boolean isUserPass(String user, String pass) {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
for(int x = 0; x < arch.length; x++) for (int x = 0; x < arch.length; x++) {
{ if (arch[x].split(";")[0].equals(user) && arch[x].split(";")[1].equals(pass)) {
if(arch[x].split(";")[0].equals(user)&&arch[x].split(";")[1].equals(pass))
{
return true; return true;
} }
} }

View File

@@ -2,195 +2,339 @@ package utiles;
import java.time.YearMonth; import java.time.YearMonth;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
public class ControlPrincipal extends Archivo public class ControlPrincipal extends Archivo {
{
public ControlPrincipal(String usuario) {
public ControlPrincipal(String usuario)
{
super(usuario); super(usuario);
ordenar();
actId();
actSaldos();
} }
public void añadir(String fecha, String documento, String fd, String desc, String ing, String egr)
{ public void añadir(String fecha, String documento, String fd, String desc, String ing, String egr) {
int id = 1; int id = 1;
int saldo = 0; int saldo = 0;
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
String[] lastRow = arch[arch.length - 1].split(";"); String[] lastRow = arch[arch.length - 1].split(";");
try if(isFiled()){
{
id = Integer.parseInt(lastRow[0]) + 1; id = Integer.parseInt(lastRow[0]) + 1;
saldo = Integer.parseInt(lastRow[lastRow.length - 1]) + Integer.parseInt(ing) - Integer.parseInt(egr); saldo = Integer.parseInt(lastRow[lastRow.length - 1]) + Integer.parseInt(ing) - Integer.parseInt(egr);
} catch (Exception e) }else{
{
saldo = Integer.parseInt(ing) - Integer.parseInt(egr);
} }
String fila = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";" + saldo; String fila = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";" + saldo;
escribirArchivo(fila); escribirArchivo(fila);
} }
public void modificarFila(String id, String fecha, String documento, String fd, String desc, String ing, String egr)
{ public void modificarFila(String id, String fecha, String documento, String fd, String desc, String ing,
String egr) {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
for (int x = 0; x < arch.length; x++)
{ for (int x = 0; x < arch.length; x++) {
if (arch[x].split(";")[0].equals(id))
{ if (arch[x].split(";")[0].equals(id)) {
arch[x] = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";" arch[x] = id + ";" + fecha + ";" + documento + ";" + fd + ";" + desc + ";" + ing + ";" + egr + ";"
+ "0"; + "0";
} }
} }
actSaldos(); actSaldos();
actArchivo(arch); actArchivo(arch);
} }
public void eliminarFila(String id)
{ public void eliminarFila(String id) {
borrarLinea(id); borrarLinea(id);
actSaldos(); actSaldos();
} }
public void actSaldos()
{ public void ordenar() {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
for (int x = 0; x < arch.length; x++)
{ boolean swapped = true;
int saldoAnterior = 0; int j = 0;
int saldo = 0; String tmp;
if (x > 0)
{ while (swapped) {
String[] aux = arch[x - 1].split(";");
saldoAnterior = Integer.parseInt(aux[aux.length - 1]); 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;
}
} }
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); actArchivo(arch);
} }
public String[] getLastRow()
{ 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(); String[] arch = entregarProcesado();
return arch[arch.length - 1].split(";"); return arch[arch.length - 1].split(";");
} }
public String[] getRow(int id)
{ public String[] getRow(int id) {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
return arch[id].split(";"); return arch[id].split(";");
} }
public int getRowCount()
{ public int getRowCount() {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
return arch.length; return arch.length;
} }
public boolean isFiled()
{ public boolean isFiled() {
return (leerArchivo().length() > 1);
return (leerArchivo().length() > 5);
} }
public String[][] resumenMes()
{ public String[][] resumenMes() {
String[][] fin = new String[4][1]; String[][] fin = new String[4][1];
if (leerArchivo().length() > 5)
{ if (leerArchivo().length() > 5) {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
ArrayList<String> fechas = new ArrayList<String>(); ArrayList<String> fechas = new ArrayList<String>();
ArrayList<String> ings = new ArrayList<String>(); ArrayList<String> ings = new ArrayList<String>();
ArrayList<String> egrs = new ArrayList<String>(); ArrayList<String> egrs = new ArrayList<String>();
for (int x = 0; x < arch.length; x++)
{ for (int x = 0; x < arch.length; x++) {
String fecha = arch[x].split(";")[1].split("/")[2] + "-" + arch[x].split(";")[1].split("/")[1]; String fecha = arch[x].split(";")[1].split("/")[2] + "-" + arch[x].split(";")[1].split("/")[1];
if (!fechas.contains(fecha))
{ if (!fechas.contains(fecha)) {
fechas.add(fecha); fechas.add(fecha);
ings.add("0"); ings.add("0");
egrs.add("0"); egrs.add("0");
} }
} }
for (int x = 0; x < arch.length; x++)
{ for (int x = 0; x < arch.length; x++) {
String fecha = arch[x].split(";")[1].split("/")[2] + "-" + arch[x].split(";")[1].split("/")[1]; String fecha = arch[x].split(";")[1].split("/")[2] + "-" + arch[x].split(";")[1].split("/")[1];
String ing = arch[x].split(";")[5]; String ing = arch[x].split(";")[5];
String egr = arch[x].split(";")[6]; String egr = arch[x].split(";")[6];
int index = fechas.indexOf(fecha); int index = fechas.indexOf(fecha);
ings.set(index, String.valueOf(Integer.parseInt(ings.get(index)) + Integer.parseInt(ing))); 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))); egrs.set(index, String.valueOf(Integer.parseInt(egrs.get(index)) + Integer.parseInt(egr)));
} }
fin = new String[4][fechas.size()]; fin = new String[4][fechas.size()];
for (int x = 0; x < fechas.size(); x++)
{ for (int x = 0; x < fechas.size(); x++) {
fin[0][x] = fechas.get(x); fin[0][x] = fechas.get(x);
fin[1][x] = String.valueOf(Integer.parseInt(ings.get(x)) - Integer.parseInt(egrs.get(x))); fin[1][x] = String.valueOf(Integer.parseInt(ings.get(x)) - Integer.parseInt(egrs.get(x)));
fin[2][x] = ings.get(x); fin[2][x] = ings.get(x);
fin[3][x] = egrs.get(x); fin[3][x] = egrs.get(x);
} }
fin = ordenarSaldos(fin); fin = ordenarSaldos(fin);
} }
return fin; return fin;
} }
public String[][] ordenarSaldos(String[][] saldos)
{ public String[][] ordenarSaldos(String[][] saldos) {
boolean swapped = true; boolean swapped = true;
int j = 0; int j = 0;
String tmp; String tmp;
String tmp1; String tmp1;
String tmp2; String tmp2;
String tmp3; String tmp3;
while (swapped)
{ while (swapped) {
swapped = false; swapped = false;
j++; j++;
for (int i = 0; i < saldos[0].length - j; i++)
{ for (int i = 0; i < saldos[0].length - j; i++) {
YearMonth f1 = YearMonth.parse(saldos[0][i]); YearMonth f1 = YearMonth.parse(saldos[0][i]);
YearMonth f2 = YearMonth.parse(saldos[0][i + 1]); YearMonth f2 = YearMonth.parse(saldos[0][i + 1]);
if (f1.isAfter(f2))
{ if (f1.isAfter(f2)) {
tmp = saldos[0][i]; tmp = saldos[0][i];
tmp1 = saldos[1][i]; tmp1 = saldos[1][i];
tmp2 = saldos[2][i]; tmp2 = saldos[2][i];
tmp3 = saldos[3][i]; tmp3 = saldos[3][i];
saldos[0][i] = saldos[0][i + 1]; saldos[0][i] = saldos[0][i + 1];
saldos[1][i] = saldos[1][i + 1]; saldos[1][i] = saldos[1][i + 1];
saldos[2][i] = saldos[2][i + 1]; saldos[2][i] = saldos[2][i + 1];
saldos[3][i] = saldos[3][i + 1]; saldos[3][i] = saldos[3][i + 1];
saldos[0][i + 1] = tmp; saldos[0][i + 1] = tmp;
saldos[1][i + 1] = tmp1; saldos[1][i + 1] = tmp1;
saldos[2][i + 1] = tmp2; saldos[2][i + 1] = tmp2;
saldos[3][i + 1] = tmp3; saldos[3][i + 1] = tmp3;
swapped = true; swapped = true;
} }
} }
} }
return saldos; return saldos;
} }
public int[] resumenDoc()
{ public int[] resumenDoc() {
String[] arch = entregarProcesado(); String[] arch = entregarProcesado();
int[] docs = { 0, 0, 0}; int[] docs = { 0, 0, 0 };
if (leerArchivo().length() > 5)
{ if (leerArchivo().length() > 5) {
for (int x = 0; x < arch.length; x++)
{ for (int x = 0; x < arch.length; x++) {
String[] aux = arch[x].split(";"); String[] aux = arch[x].split(";");
switch(aux[2])
{ switch (aux[2]) {
case "Efectivo": case "Efectivo":
docs[0] += Integer.parseInt(aux[5])-Integer.parseInt(aux[6]);
docs[0] += Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]);
break; break;
case "Transferencia": case "Transferencia":
docs[1] += Integer.parseInt(aux[5])-Integer.parseInt(aux[6]);
docs[1] += Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]);
break; break;
case "Credito": case "Credito":
docs[2] += Integer.parseInt(aux[5])-Integer.parseInt(aux[6]);
docs[2] += Integer.parseInt(aux[5]) - Integer.parseInt(aux[6]);
break; break;
} }
} }
} }
return docs; return docs;
} }
} }

10
src/utiles/Validador.java Normal file
View File

@@ -0,0 +1,10 @@
package utiles;
public class Validador {
public static boolean isNumber(String num) {
return (num.matches("\\d"));
}
}

166
src/visual/FrameLogin.java Normal file
View File

@@ -0,0 +1,166 @@
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(40, 40, 40))
.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");
pack();
getRootPane().setDefaultButton(bIngresar);
setVisible(true);
}
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();
}
}

View File

@@ -0,0 +1,79 @@
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();
}
}

View File

@@ -0,0 +1,153 @@
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)));
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();
}
}

View File

@@ -0,0 +1,57 @@
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[] { "", "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);
}
}
}
}

View File

@@ -0,0 +1,459 @@
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<String> documento;
private JComboBox<String> 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º");
}
}
}

View File

@@ -0,0 +1,151 @@
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();
}
}

View File

@@ -0,0 +1,591 @@
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<JLabel> mes;
private ArrayList<JTextField> egresos;
private ArrayList<JTextField> ingresos;
private ArrayList<JTextField> saldos;
private JComboBox<String> 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<JTextField>();
egresos = new ArrayList<JTextField>();
saldos = new ArrayList<JTextField>();
mes = new ArrayList<JLabel>();
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");
}
}