Movida la necesidad de pasaar los objetos dao atravez de los constructores de las clases y se consiguen a travez de una clase estatica la que los crea previamente y simplemente los entrega a la clase que lo pide.
Supongo que dara mayor flexibilidad a cuando se quiera cambiar a un orm o cambiar la conexion a otra base de datos
This commit is contained in:
821
.idea/workspace.xml
generated
821
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
BIN
dist/Programa Caja.jar
vendored
BIN
dist/Programa Caja.jar
vendored
Binary file not shown.
@@ -26,20 +26,6 @@ package danielcortes.xyz;
|
|||||||
|
|
||||||
import danielcortes.xyz.controllers.ManagerController;
|
import danielcortes.xyz.controllers.ManagerController;
|
||||||
import danielcortes.xyz.data.Configuration;
|
import danielcortes.xyz.data.Configuration;
|
||||||
import danielcortes.xyz.models.caja.CajaDAO;
|
|
||||||
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
|
|
||||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
|
||||||
import danielcortes.xyz.models.documentos.SQLiteDocumentosDAO;
|
|
||||||
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
|
||||||
import danielcortes.xyz.models.efectivo.SQLiteEfectivoDAO;
|
|
||||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
|
||||||
import danielcortes.xyz.models.egreso.SQLiteEgresoDAO;
|
|
||||||
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
|
||||||
import danielcortes.xyz.models.ingreso.SQLiteIngresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_egreso.SQLiteTipoEgresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_ingreso.SQLiteTipoIngresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
|
|
||||||
import danielcortes.xyz.views.ManagerView;
|
import danielcortes.xyz.views.ManagerView;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -51,6 +37,26 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void run() {
|
private static void run() {
|
||||||
|
setSystemProperties();
|
||||||
|
|
||||||
|
ManagerView view = new ManagerView();
|
||||||
|
ManagerController managerController = new ManagerController(view);
|
||||||
|
|
||||||
|
executeView(view.getContentPanel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void executeView(JComponent view) {
|
||||||
|
JFrame frame = new JFrame("Caja: " + Configuration.get("nombre_caja"));
|
||||||
|
frame.setContentPane(view);
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
frame.pack();
|
||||||
|
frame.setLocationRelativeTo(null);
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void setSystemProperties() {
|
||||||
System.setProperty("awt.useSystemAAFontSettings", "on");
|
System.setProperty("awt.useSystemAAFontSettings", "on");
|
||||||
System.setProperty("swing.aatext", "true");
|
System.setProperty("swing.aatext", "true");
|
||||||
|
|
||||||
@@ -62,25 +68,7 @@ public class Main {
|
|||||||
|
|
||||||
Locale.setDefault(new Locale("es"));
|
Locale.setDefault(new Locale("es"));
|
||||||
|
|
||||||
|
|
||||||
CajaDAO cajaDAO = new SQLiteCajaDAO();
|
|
||||||
DocumentosDAO documentosDAO = new SQLiteDocumentosDAO();
|
|
||||||
EfectivoDAO efectivoDAO = new SQLiteEfectivoDAO();
|
|
||||||
EgresoDAO egresoDAO = new SQLiteEgresoDAO();
|
|
||||||
IngresoDAO ingresoDAO = new SQLiteIngresoDAO();
|
|
||||||
TipoEgresoDAO tipoEgresoDAO = new SQLiteTipoEgresoDAO();
|
|
||||||
TipoIngresoDAO tipoIngresoDAO = new SQLiteTipoIngresoDAO();
|
|
||||||
|
|
||||||
ManagerView view = new ManagerView();
|
|
||||||
ManagerController managerController = new ManagerController(view, cajaDAO, documentosDAO, efectivoDAO, egresoDAO, ingresoDAO, tipoEgresoDAO, tipoIngresoDAO);
|
|
||||||
|
|
||||||
JFrame frame = new JFrame("Caja: " + Configuration.get("nombre_caja"));
|
|
||||||
frame.setContentPane(view.getContentPanel());
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
|
|
||||||
//frame.setSize(780, 450);
|
|
||||||
frame.pack();
|
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,10 @@
|
|||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.NextAction;
|
import danielcortes.xyz.controllers.actions.NextAction;
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.calculo_fondo.SQLiteCalculoFondoDAO;
|
|
||||||
import danielcortes.xyz.models.documentos.Documentos;
|
import danielcortes.xyz.models.documentos.Documentos;
|
||||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
|
||||||
import danielcortes.xyz.models.efectivo.Efectivo;
|
import danielcortes.xyz.models.efectivo.Efectivo;
|
||||||
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
|
||||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
|
||||||
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
|
||||||
import danielcortes.xyz.views.ArqueoView;
|
import danielcortes.xyz.views.ArqueoView;
|
||||||
import danielcortes.xyz.views.CalcularFondoView;
|
import danielcortes.xyz.views.CalcularFondoView;
|
||||||
import danielcortes.xyz.views.components.NumberFormatedTextField;
|
import danielcortes.xyz.views.components.NumberFormatedTextField;
|
||||||
@@ -51,21 +47,11 @@ public class ArqueoController {
|
|||||||
private Efectivo efectivo;
|
private Efectivo efectivo;
|
||||||
private Documentos documentos;
|
private Documentos documentos;
|
||||||
|
|
||||||
private EfectivoDAO efectivoDAO;
|
|
||||||
private DocumentosDAO documentosDAO;
|
|
||||||
private IngresoDAO ingresoDAO;
|
|
||||||
private EgresoDAO egresoDAO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crea el controlador y ejecuta el metodo que genera los eventos para su vista.
|
* Crea el controlador y ejecuta el metodo que genera los eventos para su vista.
|
||||||
*/
|
*/
|
||||||
public ArqueoController(ArqueoView view, EfectivoDAO efectivoDAO, DocumentosDAO documentosDAO, IngresoDAO ingresoDAO, EgresoDAO egresoDAO) {
|
public ArqueoController(ArqueoView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.efectivoDAO = efectivoDAO;
|
|
||||||
this.documentosDAO = documentosDAO;
|
|
||||||
this.ingresoDAO = ingresoDAO;
|
|
||||||
this.egresoDAO = egresoDAO;
|
|
||||||
|
|
||||||
this.setUpViewEvents();
|
this.setUpViewEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +78,7 @@ public class ArqueoController {
|
|||||||
* Rellena los campos del efectivo con la instancia de efectivo que pertenece a la caja
|
* Rellena los campos del efectivo con la instancia de efectivo que pertenece a la caja
|
||||||
*/
|
*/
|
||||||
private void fillEfectivo() {
|
private void fillEfectivo() {
|
||||||
this.efectivo = this.efectivoDAO.findByCaja(this.caja);
|
this.efectivo = DAOManager.getEfectivoDAO().findByCaja(this.caja);
|
||||||
this.view.getVeinteMilField().setValue(efectivo.getVeinteMil());
|
this.view.getVeinteMilField().setValue(efectivo.getVeinteMil());
|
||||||
this.view.getDiezMilField().setValue(efectivo.getDiezMil());
|
this.view.getDiezMilField().setValue(efectivo.getDiezMil());
|
||||||
this.view.getCincoMilField().setValue(efectivo.getCincoMil());
|
this.view.getCincoMilField().setValue(efectivo.getCincoMil());
|
||||||
@@ -108,7 +94,7 @@ public class ArqueoController {
|
|||||||
* Rellea los campos de documentos con la instancia de documentos que pertenece a la caja
|
* Rellea los campos de documentos con la instancia de documentos que pertenece a la caja
|
||||||
*/
|
*/
|
||||||
private void fillDocumentos() {
|
private void fillDocumentos() {
|
||||||
this.documentos = this.documentosDAO.findByCaja(caja);
|
this.documentos = DAOManager.getDocumentosDAO().findByCaja(caja);
|
||||||
this.view.getTarjetasField().setValue(documentos.getTarjetas());
|
this.view.getTarjetasField().setValue(documentos.getTarjetas());
|
||||||
this.view.getChequesField().setValue(documentos.getCheques());
|
this.view.getChequesField().setValue(documentos.getCheques());
|
||||||
this.view.getRetiroField().setValue(documentos.getRetiros());
|
this.view.getRetiroField().setValue(documentos.getRetiros());
|
||||||
@@ -129,7 +115,7 @@ public class ArqueoController {
|
|||||||
*/
|
*/
|
||||||
private void updateResumenEfectivo() {
|
private void updateResumenEfectivo() {
|
||||||
NumberFormatedTextField efectivoField = this.view.getEfectivoField();
|
NumberFormatedTextField efectivoField = this.view.getEfectivoField();
|
||||||
int total = efectivoDAO.getTotalEfectivo(this.caja);
|
int total = DAOManager.getEfectivoDAO().getTotalEfectivo(this.caja);
|
||||||
efectivoField.setValue(total);
|
efectivoField.setValue(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +124,7 @@ public class ArqueoController {
|
|||||||
*/
|
*/
|
||||||
private void updateResumenDocumentos() {
|
private void updateResumenDocumentos() {
|
||||||
NumberFormatedTextField documentosField = this.view.getDocumentosField();
|
NumberFormatedTextField documentosField = this.view.getDocumentosField();
|
||||||
int total = documentosDAO.getTotalDocumentos(this.caja);
|
int total = DAOManager.getDocumentosDAO().getTotalDocumentos(this.caja);
|
||||||
documentosField.setValue(total);
|
documentosField.setValue(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +132,7 @@ public class ArqueoController {
|
|||||||
* Obtiene el total de egresos y lo muestra en el campo de egresosField
|
* Obtiene el total de egresos y lo muestra en el campo de egresosField
|
||||||
*/
|
*/
|
||||||
private void updateResumenEgresos() {
|
private void updateResumenEgresos() {
|
||||||
int total = this.egresoDAO.getTotalEgreso(this.caja);
|
int total = DAOManager.getEgresoDAO().getTotalEgreso(this.caja);
|
||||||
this.view.getEgresosField().setValue(total);
|
this.view.getEgresosField().setValue(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,10 +140,10 @@ public class ArqueoController {
|
|||||||
* Calcula los datos de arqueo, rendido y ajuste y los muestra en sus campos correspondientes
|
* Calcula los datos de arqueo, rendido y ajuste y los muestra en sus campos correspondientes
|
||||||
*/
|
*/
|
||||||
private void updateResumenArqueo() {
|
private void updateResumenArqueo() {
|
||||||
int totalEfectivo = efectivoDAO.getTotalEfectivo(this.caja);
|
int totalEfectivo = DAOManager.getEfectivoDAO().getTotalEfectivo(this.caja);
|
||||||
int totalDocumentos = documentosDAO.getTotalDocumentos(this.caja);
|
int totalDocumentos = DAOManager.getDocumentosDAO().getTotalDocumentos(this.caja);
|
||||||
int totalEgresos = egresoDAO.getTotalEgreso(this.caja);
|
int totalEgresos = DAOManager.getEgresoDAO().getTotalEgreso(this.caja);
|
||||||
int totalIngresos = ingresoDAO.getTotalIngreso(this.caja);
|
int totalIngresos = DAOManager.getIngresoDAO().getTotalIngreso(this.caja);
|
||||||
|
|
||||||
int rendido = totalDocumentos + totalEfectivo + totalEgresos;
|
int rendido = totalDocumentos + totalEfectivo + totalEgresos;
|
||||||
int diferencia = rendido - totalIngresos;
|
int diferencia = rendido - totalIngresos;
|
||||||
@@ -241,7 +227,7 @@ public class ArqueoController {
|
|||||||
* Lanza la ventana en la que se puede calcular el fondo de la caja.
|
* Lanza la ventana en la que se puede calcular el fondo de la caja.
|
||||||
*/
|
*/
|
||||||
private void calcularFondoActionListener() {
|
private void calcularFondoActionListener() {
|
||||||
new CalcularFondoController(this.view.getContentPanel(), new CalcularFondoView(), this.caja, new SQLiteCalculoFondoDAO());
|
new CalcularFondoController(this.view.getContentPanel(), new CalcularFondoView(), this.caja);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,7 +254,7 @@ public class ArqueoController {
|
|||||||
this.efectivo.setCincoMil(cincoMil);
|
this.efectivo.setCincoMil(cincoMil);
|
||||||
this.efectivo.setDiezMil(diezMil);
|
this.efectivo.setDiezMil(diezMil);
|
||||||
this.efectivo.setVeinteMil(veinteMil);
|
this.efectivo.setVeinteMil(veinteMil);
|
||||||
this.efectivoDAO.updateEfectivo(efectivo);
|
DAOManager.getEfectivoDAO().updateEfectivo(efectivo);
|
||||||
|
|
||||||
this.updateResumenEfectivo();
|
this.updateResumenEfectivo();
|
||||||
this.updateResumenArqueo();
|
this.updateResumenArqueo();
|
||||||
@@ -286,7 +272,7 @@ public class ArqueoController {
|
|||||||
this.documentos.setTarjetas(tarjetas);
|
this.documentos.setTarjetas(tarjetas);
|
||||||
this.documentos.setCheques(cheques);
|
this.documentos.setCheques(cheques);
|
||||||
this.documentos.setRetiros(retiros);
|
this.documentos.setRetiros(retiros);
|
||||||
this.documentosDAO.updateDocumentos(documentos);
|
DAOManager.getDocumentosDAO().updateDocumentos(documentos);
|
||||||
|
|
||||||
this.updateResumenDocumentos();
|
this.updateResumenDocumentos();
|
||||||
this.updateResumenArqueo();
|
this.updateResumenArqueo();
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package danielcortes.xyz.controllers;
|
|||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.NextAction;
|
import danielcortes.xyz.controllers.actions.NextAction;
|
||||||
import danielcortes.xyz.data.Configuration;
|
import danielcortes.xyz.data.Configuration;
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.calculo_fondo.CalculoFondo;
|
import danielcortes.xyz.models.calculo_fondo.CalculoFondo;
|
||||||
import danielcortes.xyz.models.calculo_fondo.CalculoFondoDAO;
|
|
||||||
import danielcortes.xyz.views.CalcularFondoView;
|
import danielcortes.xyz.views.CalcularFondoView;
|
||||||
import danielcortes.xyz.views.components.FondoTableModel;
|
import danielcortes.xyz.views.components.FondoTableModel;
|
||||||
|
|
||||||
@@ -17,17 +17,15 @@ public class CalcularFondoController {
|
|||||||
private JComponent parent;
|
private JComponent parent;
|
||||||
private CalcularFondoView view;
|
private CalcularFondoView view;
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
private CalculoFondoDAO calculoFondoDAO;
|
|
||||||
|
|
||||||
private int editingId;
|
private int editingId;
|
||||||
private boolean editing;
|
private boolean editing;
|
||||||
private CalculoFondo editingCalculoFondo;
|
private CalculoFondo editingCalculoFondo;
|
||||||
|
|
||||||
public CalcularFondoController(JComponent parent, CalcularFondoView view, Caja caja, CalculoFondoDAO calculoFondoDAO) {
|
public CalcularFondoController(JComponent parent, CalcularFondoView view, Caja caja) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.caja = caja;
|
this.caja = caja;
|
||||||
this.calculoFondoDAO = calculoFondoDAO;
|
|
||||||
|
|
||||||
this.fillTable();
|
this.fillTable();
|
||||||
this.updateResumen();
|
this.updateResumen();
|
||||||
@@ -48,7 +46,7 @@ public class CalcularFondoController {
|
|||||||
private void fillTable() {
|
private void fillTable() {
|
||||||
FondoTableModel tableModel = this.view.getTableModel();
|
FondoTableModel tableModel = this.view.getTableModel();
|
||||||
tableModel.removeRows();
|
tableModel.removeRows();
|
||||||
for (CalculoFondo calculoFondo : this.calculoFondoDAO.findByCaja(this.caja)) {
|
for (CalculoFondo calculoFondo : DAOManager.getCalculoFondoDAO().findByCaja(this.caja)) {
|
||||||
tableModel.addRow(calculoFondo);
|
tableModel.addRow(calculoFondo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,7 +115,7 @@ public class CalcularFondoController {
|
|||||||
if (selectedID >= 0) {
|
if (selectedID >= 0) {
|
||||||
CalculoFondo calculoFondo = this.view.getTableModel().getCalculoFondo(selectedID);
|
CalculoFondo calculoFondo = this.view.getTableModel().getCalculoFondo(selectedID);
|
||||||
this.view.getTableModel().removeRow(selectedID);
|
this.view.getTableModel().removeRow(selectedID);
|
||||||
this.calculoFondoDAO.deleteCalculoFondo(calculoFondo);
|
DAOManager.getCalculoFondoDAO().deleteCalculoFondo(calculoFondo);
|
||||||
this.updateResumen();
|
this.updateResumen();
|
||||||
this.updateButtonsEnabled();
|
this.updateButtonsEnabled();
|
||||||
this.resetFocus();
|
this.resetFocus();
|
||||||
@@ -129,7 +127,7 @@ public class CalcularFondoController {
|
|||||||
calculoFondo.setValor(valor);
|
calculoFondo.setValor(valor);
|
||||||
calculoFondo.setDescripcion(descripcion);
|
calculoFondo.setDescripcion(descripcion);
|
||||||
calculoFondo.setCaja(this.caja);
|
calculoFondo.setCaja(this.caja);
|
||||||
this.calculoFondoDAO.insertCalculoFondo(calculoFondo);
|
DAOManager.getCalculoFondoDAO().insertCalculoFondo(calculoFondo);
|
||||||
this.view.getTableModel().addRow(calculoFondo);
|
this.view.getTableModel().addRow(calculoFondo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +135,7 @@ public class CalcularFondoController {
|
|||||||
this.editingCalculoFondo.setValor(valor);
|
this.editingCalculoFondo.setValor(valor);
|
||||||
this.editingCalculoFondo.setDescripcion(descripcion);
|
this.editingCalculoFondo.setDescripcion(descripcion);
|
||||||
this.editingCalculoFondo.setCaja(this.caja);
|
this.editingCalculoFondo.setCaja(this.caja);
|
||||||
this.calculoFondoDAO.updateCalculoFondo(editingCalculoFondo);
|
DAOManager.getCalculoFondoDAO().updateCalculoFondo(editingCalculoFondo);
|
||||||
this.view.getTableModel().setCalculoFondo(this.editingId, this.editingCalculoFondo);
|
this.view.getTableModel().setCalculoFondo(this.editingId, this.editingCalculoFondo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +151,7 @@ public class CalcularFondoController {
|
|||||||
|
|
||||||
private void updateResumen() {
|
private void updateResumen() {
|
||||||
int fondo = this.view.getFondoField().getValue();
|
int fondo = this.view.getFondoField().getValue();
|
||||||
int suma = this.calculoFondoDAO.getTotalCalculoFondo(this.caja);
|
int suma = DAOManager.getCalculoFondoDAO().getTotalCalculoFondo(this.caja);
|
||||||
this.view.getSumaField().setValue(suma);
|
this.view.getSumaField().setValue(suma);
|
||||||
this.view.getDepositoField().setValue(suma - fondo);
|
this.view.getDepositoField().setValue(suma - fondo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,10 @@
|
|||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.controllers.actions.NextAction;
|
import danielcortes.xyz.controllers.actions.NextAction;
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.egreso.Egreso;
|
import danielcortes.xyz.models.egreso.Egreso;
|
||||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||||
import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO;
|
|
||||||
import danielcortes.xyz.views.EgresosView;
|
import danielcortes.xyz.views.EgresosView;
|
||||||
import danielcortes.xyz.views.components.EgresosTableModel;
|
import danielcortes.xyz.views.components.EgresosTableModel;
|
||||||
|
|
||||||
@@ -44,8 +43,6 @@ import java.awt.event.MouseEvent;
|
|||||||
*/
|
*/
|
||||||
public class EgresosController {
|
public class EgresosController {
|
||||||
private EgresosView view;
|
private EgresosView view;
|
||||||
private EgresoDAO egresoDAO;
|
|
||||||
private TipoEgresoDAO tipoEgresoDAO;
|
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
|
|
||||||
private int editingId;
|
private int editingId;
|
||||||
@@ -59,33 +56,13 @@ public class EgresosController {
|
|||||||
* - Metodo que llena los tipos de egresos en la vista.
|
* - Metodo que llena los tipos de egresos en la vista.
|
||||||
* - Actualiza el estado de los botones.
|
* - Actualiza el estado de los botones.
|
||||||
*/
|
*/
|
||||||
public EgresosController(EgresosView view, EgresoDAO egresoDAO, TipoEgresoDAO tipoEgresoDAO) {
|
public EgresosController(EgresosView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.egresoDAO = egresoDAO;
|
|
||||||
this.tipoEgresoDAO = tipoEgresoDAO;
|
|
||||||
this.setUpViewEvents();
|
this.setUpViewEvents();
|
||||||
this.fillTipoEgresoCombo();
|
this.fillTipoEgresoCombo();
|
||||||
this.updateButtonsEnabled();
|
this.updateButtonsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter!
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public EgresoDAO getEgresoDAO() {
|
|
||||||
return egresoDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public TipoEgresoDAO getTipoEgresoDAO() {
|
|
||||||
return tipoEgresoDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guarda la caja entregada y actualiza los datos de la tabla de egresos y actualiza el field con el total de egresos.
|
* Guarda la caja entregada y actualiza los datos de la tabla de egresos y actualiza el field con el total de egresos.
|
||||||
*/
|
*/
|
||||||
@@ -100,7 +77,7 @@ public class EgresosController {
|
|||||||
*/
|
*/
|
||||||
private void fillTipoEgresoCombo() {
|
private void fillTipoEgresoCombo() {
|
||||||
JComboBox<TipoEgreso> tipoCombo = view.getTipoCombo();
|
JComboBox<TipoEgreso> tipoCombo = view.getTipoCombo();
|
||||||
for (TipoEgreso tipoEgreso : this.tipoEgresoDAO.findAll()) {
|
for (TipoEgreso tipoEgreso : DAOManager.getTipoEgresoDAO().findAll()) {
|
||||||
tipoCombo.addItem(tipoEgreso);
|
tipoCombo.addItem(tipoEgreso);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +88,7 @@ public class EgresosController {
|
|||||||
private void fillEgresosTable() {
|
private void fillEgresosTable() {
|
||||||
EgresosTableModel egresosTableModel = view.getEgresosTableModel();
|
EgresosTableModel egresosTableModel = view.getEgresosTableModel();
|
||||||
egresosTableModel.removeRows();
|
egresosTableModel.removeRows();
|
||||||
for (Egreso egreso : this.egresoDAO.findByCaja(this.caja)) {
|
for (Egreso egreso : DAOManager.getEgresoDAO().findByCaja(this.caja)) {
|
||||||
egresosTableModel.addRow(egreso);
|
egresosTableModel.addRow(egreso);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,7 +159,7 @@ public class EgresosController {
|
|||||||
if (selectedID >= 0) {
|
if (selectedID >= 0) {
|
||||||
Egreso egreso = this.view.getEgresosTableModel().getEgreso(selectedID);
|
Egreso egreso = this.view.getEgresosTableModel().getEgreso(selectedID);
|
||||||
this.view.getEgresosTableModel().removeRow(selectedID);
|
this.view.getEgresosTableModel().removeRow(selectedID);
|
||||||
this.egresoDAO.deleteEgreso(egreso);
|
DAOManager.getEgresoDAO().deleteEgreso(egreso);
|
||||||
this.updateTotalEgresos();
|
this.updateTotalEgresos();
|
||||||
this.updateButtonsEnabled();
|
this.updateButtonsEnabled();
|
||||||
this.resetFocus();
|
this.resetFocus();
|
||||||
@@ -219,7 +196,7 @@ public class EgresosController {
|
|||||||
* Obtiene el total de egresos y los coloca en el campo de totalEgresosField.
|
* Obtiene el total de egresos y los coloca en el campo de totalEgresosField.
|
||||||
*/
|
*/
|
||||||
private void updateTotalEgresos() {
|
private void updateTotalEgresos() {
|
||||||
int total = this.egresoDAO.getTotalEgreso(this.caja);
|
int total = DAOManager.getEgresoDAO().getTotalEgreso(this.caja);
|
||||||
this.view.getTotalEgresosField().setValue(total);
|
this.view.getTotalEgresosField().setValue(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +226,7 @@ public class EgresosController {
|
|||||||
egreso.setNro(nro);
|
egreso.setNro(nro);
|
||||||
egreso.setTipoEgreso(tipo);
|
egreso.setTipoEgreso(tipo);
|
||||||
egreso.setCaja(caja);
|
egreso.setCaja(caja);
|
||||||
egresoDAO.insertEgreso(egreso);
|
DAOManager.getEgresoDAO().insertEgreso(egreso);
|
||||||
this.view.getEgresosTableModel().addRow(egreso);
|
this.view.getEgresosTableModel().addRow(egreso);
|
||||||
this.updateTotalEgresos();
|
this.updateTotalEgresos();
|
||||||
this.clearInputs();
|
this.clearInputs();
|
||||||
@@ -263,11 +240,11 @@ public class EgresosController {
|
|||||||
*/
|
*/
|
||||||
private void editarEgreso(String nro, String descripcion, int valor, TipoEgreso tipo, Caja caja) {
|
private void editarEgreso(String nro, String descripcion, int valor, TipoEgreso tipo, Caja caja) {
|
||||||
if (this.validateInput(nro, descripcion, tipo, caja)) {
|
if (this.validateInput(nro, descripcion, tipo, caja)) {
|
||||||
this.editingEgreso.setValor(Integer.valueOf(valor));
|
this.editingEgreso.setValor(valor);
|
||||||
this.editingEgreso.setDescripcion(descripcion);
|
this.editingEgreso.setDescripcion(descripcion);
|
||||||
this.editingEgreso.setNro(nro);
|
this.editingEgreso.setNro(nro);
|
||||||
this.editingEgreso.setTipoEgreso(tipo);
|
this.editingEgreso.setTipoEgreso(tipo);
|
||||||
egresoDAO.updateEgreso(this.editingEgreso);
|
DAOManager.getEgresoDAO().updateEgreso(this.editingEgreso);
|
||||||
this.view.getEgresosTableModel().setEgreso(this.editingId, this.editingEgreso);
|
this.view.getEgresosTableModel().setEgreso(this.editingId, this.editingEgreso);
|
||||||
this.updateTotalEgresos();
|
this.updateTotalEgresos();
|
||||||
this.clearInputs();
|
this.clearInputs();
|
||||||
|
|||||||
@@ -24,11 +24,10 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.ingreso.Ingreso;
|
import danielcortes.xyz.models.ingreso.Ingreso;
|
||||||
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngreso;
|
import danielcortes.xyz.models.tipo_ingreso.TipoIngreso;
|
||||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
|
|
||||||
import danielcortes.xyz.views.IngresosView;
|
import danielcortes.xyz.views.IngresosView;
|
||||||
import danielcortes.xyz.views.components.IngresosTableModel;
|
import danielcortes.xyz.views.components.IngresosTableModel;
|
||||||
|
|
||||||
@@ -43,8 +42,6 @@ import java.awt.event.MouseEvent;
|
|||||||
*/
|
*/
|
||||||
public class IngresosController {
|
public class IngresosController {
|
||||||
private IngresosView view;
|
private IngresosView view;
|
||||||
private IngresoDAO ingresoDAO;
|
|
||||||
private TipoIngresoDAO tipoIngresoDAO;
|
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
|
|
||||||
private int editingId;
|
private int editingId;
|
||||||
@@ -58,30 +55,13 @@ public class IngresosController {
|
|||||||
* - Metodo que genera los eventos para la vista
|
* - Metodo que genera los eventos para la vista
|
||||||
* - Metodo que actualiza el estado de los botones
|
* - Metodo que actualiza el estado de los botones
|
||||||
*/
|
*/
|
||||||
public IngresosController(IngresosView view, IngresoDAO ingresoDAO, TipoIngresoDAO tipoIngresoDAO) {
|
public IngresosController(IngresosView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.ingresoDAO = ingresoDAO;
|
|
||||||
this.tipoIngresoDAO = tipoIngresoDAO;
|
|
||||||
this.fillTipoIngresoCombo();
|
this.fillTipoIngresoCombo();
|
||||||
this.setupViewEvents();
|
this.setupViewEvents();
|
||||||
this.updateButtonsEnabled();
|
this.updateButtonsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter!!
|
|
||||||
*/
|
|
||||||
public IngresoDAO getIngresoDAO() {
|
|
||||||
return ingresoDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Getter!!!
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public TipoIngresoDAO getTipoIngresoDAO() {
|
|
||||||
return tipoIngresoDAO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guarda la caja ingresada y actualiza el contenido de la tabla de ingresos y el campo de total de ingresos
|
* Guarda la caja ingresada y actualiza el contenido de la tabla de ingresos y el campo de total de ingresos
|
||||||
@@ -97,7 +77,7 @@ public class IngresosController {
|
|||||||
*/
|
*/
|
||||||
private void fillTipoIngresoCombo() {
|
private void fillTipoIngresoCombo() {
|
||||||
JComboBox<TipoIngreso> tipoCombo = this.view.getTipoCombo();
|
JComboBox<TipoIngreso> tipoCombo = this.view.getTipoCombo();
|
||||||
for (TipoIngreso tipo : this.tipoIngresoDAO.findAll()) {
|
for (TipoIngreso tipo : DAOManager.getTipoIngresoDAO().findAll()) {
|
||||||
tipoCombo.addItem(tipo);
|
tipoCombo.addItem(tipo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +88,7 @@ public class IngresosController {
|
|||||||
private void fillIngresosTable() {
|
private void fillIngresosTable() {
|
||||||
IngresosTableModel ingresosTableModel = this.view.getIngresosTableModel();
|
IngresosTableModel ingresosTableModel = this.view.getIngresosTableModel();
|
||||||
ingresosTableModel.removeRows();
|
ingresosTableModel.removeRows();
|
||||||
for (Ingreso ingreso : this.ingresoDAO.findByCaja(this.caja)) {
|
for (Ingreso ingreso : DAOManager.getIngresoDAO().findByCaja(this.caja)) {
|
||||||
ingresosTableModel.addRow(ingreso);
|
ingresosTableModel.addRow(ingreso);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +166,7 @@ public class IngresosController {
|
|||||||
if (selectedId >= 0) {
|
if (selectedId >= 0) {
|
||||||
Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedId);
|
Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedId);
|
||||||
this.view.getIngresosTableModel().removeRow(selectedId);
|
this.view.getIngresosTableModel().removeRow(selectedId);
|
||||||
this.ingresoDAO.deleteIngreso(ingreso);
|
DAOManager.getIngresoDAO().deleteIngreso(ingreso);
|
||||||
this.updateTotalIngresos();
|
this.updateTotalIngresos();
|
||||||
this.updateButtonsEnabled();
|
this.updateButtonsEnabled();
|
||||||
}
|
}
|
||||||
@@ -223,7 +203,7 @@ public class IngresosController {
|
|||||||
* Obtiene el total de ingresos de la caja y lo coloca en el el field totalingresos
|
* Obtiene el total de ingresos de la caja y lo coloca en el el field totalingresos
|
||||||
*/
|
*/
|
||||||
private void updateTotalIngresos() {
|
private void updateTotalIngresos() {
|
||||||
int total = this.ingresoDAO.getTotalIngreso(this.caja);
|
int total = DAOManager.getIngresoDAO().getTotalIngreso(this.caja);
|
||||||
this.view.getTotalIngresoField().setValue(total);
|
this.view.getTotalIngresoField().setValue(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,7 +237,7 @@ public class IngresosController {
|
|||||||
ingreso.setNroInicial(nroInicial);
|
ingreso.setNroInicial(nroInicial);
|
||||||
ingreso.setNroFinal(nroFinal);
|
ingreso.setNroFinal(nroFinal);
|
||||||
|
|
||||||
this.ingresoDAO.insertIngreso(ingreso);
|
DAOManager.getIngresoDAO().insertIngreso(ingreso);
|
||||||
this.view.getIngresosTableModel().addRow(ingreso);
|
this.view.getIngresosTableModel().addRow(ingreso);
|
||||||
|
|
||||||
this.clearInputs();
|
this.clearInputs();
|
||||||
@@ -277,7 +257,7 @@ public class IngresosController {
|
|||||||
this.editingIngreso.setNroZFinal(nroZFinal);
|
this.editingIngreso.setNroZFinal(nroZFinal);
|
||||||
this.editingIngreso.setNroInicial(nroInicial);
|
this.editingIngreso.setNroInicial(nroInicial);
|
||||||
this.editingIngreso.setNroFinal(nroFinal);
|
this.editingIngreso.setNroFinal(nroFinal);
|
||||||
this.ingresoDAO.updateIngreso(this.editingIngreso);
|
DAOManager.getIngresoDAO().updateIngreso(this.editingIngreso);
|
||||||
this.view.getIngresosTableModel().setIngreso(this.editingId, this.editingIngreso);
|
this.view.getIngresosTableModel().setIngreso(this.editingId, this.editingIngreso);
|
||||||
this.updateTotalIngresos();
|
this.updateTotalIngresos();
|
||||||
this.clearInputs();
|
this.clearInputs();
|
||||||
|
|||||||
@@ -24,16 +24,10 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.caja.CajaDAO;
|
|
||||||
import danielcortes.xyz.models.documentos.Documentos;
|
import danielcortes.xyz.models.documentos.Documentos;
|
||||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
|
||||||
import danielcortes.xyz.models.efectivo.Efectivo;
|
import danielcortes.xyz.models.efectivo.Efectivo;
|
||||||
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
|
||||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
|
||||||
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO;
|
|
||||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
|
|
||||||
import danielcortes.xyz.views.*;
|
import danielcortes.xyz.views.*;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -51,14 +45,6 @@ public class ManagerController {
|
|||||||
private ArqueoController arqueoController;
|
private ArqueoController arqueoController;
|
||||||
private InformesController informesController;
|
private InformesController informesController;
|
||||||
|
|
||||||
private CajaDAO cajaDAO;
|
|
||||||
private DocumentosDAO documentosDAO;
|
|
||||||
private EfectivoDAO efectivoDAO;
|
|
||||||
private EgresoDAO egresoDAO;
|
|
||||||
private IngresoDAO ingresoDAO;
|
|
||||||
private TipoEgresoDAO tipoEgresoDAO;
|
|
||||||
private TipoIngresoDAO tipoIngresoDAO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crea el controlador
|
* Crea el controlador
|
||||||
* Necesita todos las interfaces DAO para poder asignarselos a sus vistas,
|
* Necesita todos las interfaces DAO para poder asignarselos a sus vistas,
|
||||||
@@ -70,15 +56,8 @@ public class ManagerController {
|
|||||||
* - Genera los eventos de la vista
|
* - Genera los eventos de la vista
|
||||||
* - Presiona el boton de la vista inicial
|
* - Presiona el boton de la vista inicial
|
||||||
*/
|
*/
|
||||||
public ManagerController(ManagerView view, CajaDAO cajaDAO, DocumentosDAO documentosDAO, EfectivoDAO efectivoDAO, EgresoDAO egresoDAO, IngresoDAO ingresoDAO, TipoEgresoDAO tipoEgresoDAO, TipoIngresoDAO tipoIngresoDAO) {
|
public ManagerController(ManagerView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.cajaDAO = cajaDAO;
|
|
||||||
this.documentosDAO = documentosDAO;
|
|
||||||
this.efectivoDAO = efectivoDAO;
|
|
||||||
this.egresoDAO = egresoDAO;
|
|
||||||
this.ingresoDAO = ingresoDAO;
|
|
||||||
this.tipoEgresoDAO = tipoEgresoDAO;
|
|
||||||
this.tipoIngresoDAO = tipoIngresoDAO;
|
|
||||||
this.loadCardContents();
|
this.loadCardContents();
|
||||||
this.setUpDate();
|
this.setUpDate();
|
||||||
this.setUpViewEvents();
|
this.setUpViewEvents();
|
||||||
@@ -125,20 +104,20 @@ public class ManagerController {
|
|||||||
*/
|
*/
|
||||||
private void updateCaja() {
|
private void updateCaja() {
|
||||||
LocalDate selectedDate = this.view.getDatePicker().getDate();
|
LocalDate selectedDate = this.view.getDatePicker().getDate();
|
||||||
Caja caja = this.cajaDAO.findByFecha(selectedDate);
|
Caja caja = DAOManager.getCajaDAO().findByFecha(selectedDate);
|
||||||
|
|
||||||
if (caja == null) {
|
if (caja == null) {
|
||||||
caja = new Caja();
|
caja = new Caja();
|
||||||
caja.setFecha(selectedDate);
|
caja.setFecha(selectedDate);
|
||||||
this.cajaDAO.insertCaja(caja);
|
DAOManager.getCajaDAO().insertCaja(caja);
|
||||||
|
|
||||||
Efectivo efectivo = new Efectivo();
|
Efectivo efectivo = new Efectivo();
|
||||||
efectivo.setCaja(caja);
|
efectivo.setCaja(caja);
|
||||||
this.efectivoDAO.insertDefaultEfectivo(efectivo);
|
DAOManager.getEfectivoDAO().insertDefaultEfectivo(efectivo);
|
||||||
|
|
||||||
Documentos documentos = new Documentos();
|
Documentos documentos = new Documentos();
|
||||||
documentos.setCaja(caja);
|
documentos.setCaja(caja);
|
||||||
this.documentosDAO.insertDefaultDocumentos(documentos);
|
DAOManager.getDocumentosDAO().insertDefaultDocumentos(documentos);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ingresosController.updateCaja(caja);
|
this.ingresosController.updateCaja(caja);
|
||||||
@@ -164,7 +143,7 @@ public class ManagerController {
|
|||||||
|
|
||||||
this.view.getCardPanel().add(ingresosView.getContentPanel(), "INGRESOS");
|
this.view.getCardPanel().add(ingresosView.getContentPanel(), "INGRESOS");
|
||||||
|
|
||||||
this.ingresosController = new IngresosController(ingresosView, this.ingresoDAO, this.tipoIngresoDAO);
|
this.ingresosController = new IngresosController(ingresosView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,7 +154,7 @@ public class ManagerController {
|
|||||||
|
|
||||||
this.view.getCardPanel().add(egresosView.getContentPanel(), "EGRESOS");
|
this.view.getCardPanel().add(egresosView.getContentPanel(), "EGRESOS");
|
||||||
|
|
||||||
this.egresosController = new EgresosController(egresosView, this.egresoDAO, this.tipoEgresoDAO);
|
this.egresosController = new EgresosController(egresosView);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -186,7 +165,7 @@ public class ManagerController {
|
|||||||
|
|
||||||
this.view.getCardPanel().add(arqueoView.getContentPanel(), "ARQUEO");
|
this.view.getCardPanel().add(arqueoView.getContentPanel(), "ARQUEO");
|
||||||
|
|
||||||
this.arqueoController = new ArqueoController(arqueoView, this.efectivoDAO, this.documentosDAO, this.ingresoDAO, this.egresoDAO);
|
this.arqueoController = new ArqueoController(arqueoView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadInformesView() {
|
private void loadInformesView() {
|
||||||
|
|||||||
112
src/danielcortes/xyz/data/DAOManager.java
Normal file
112
src/danielcortes/xyz/data/DAOManager.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018-2019 Daniel Cortes
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package danielcortes.xyz.data;
|
||||||
|
|
||||||
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
|
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
|
||||||
|
import danielcortes.xyz.models.calculo_fondo.CalculoFondoDAO;
|
||||||
|
import danielcortes.xyz.models.calculo_fondo.SQLiteCalculoFondoDAO;
|
||||||
|
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
||||||
|
import danielcortes.xyz.models.documentos.SQLiteDocumentosDAO;
|
||||||
|
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
||||||
|
import danielcortes.xyz.models.efectivo.SQLiteEfectivoDAO;
|
||||||
|
import danielcortes.xyz.models.egreso.EgresoDAO;
|
||||||
|
import danielcortes.xyz.models.egreso.SQLiteEgresoDAO;
|
||||||
|
import danielcortes.xyz.models.informes.egresos.InformeEgresosContentDAO;
|
||||||
|
import danielcortes.xyz.models.informes.egresos.SQLiteInformeEgresosContentDAO;
|
||||||
|
import danielcortes.xyz.models.informes.libro_de_ventas.InformeLibroDeVentasContentDAO;
|
||||||
|
import danielcortes.xyz.models.informes.libro_de_ventas.SQLiteInformeLibroDeVentasContentDAO;
|
||||||
|
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
||||||
|
import danielcortes.xyz.models.ingreso.SQLiteIngresoDAO;
|
||||||
|
import danielcortes.xyz.models.tipo_egreso.SQLiteTipoEgresoDAO;
|
||||||
|
import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO;
|
||||||
|
import danielcortes.xyz.models.tipo_ingreso.SQLiteTipoIngresoDAO;
|
||||||
|
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
|
||||||
|
|
||||||
|
public class DAOManager {
|
||||||
|
private static final CajaDAO cajaDAO;
|
||||||
|
private static final CalculoFondoDAO calculoFondoDAO;
|
||||||
|
private static final DocumentosDAO documentosDAO;
|
||||||
|
private static final EfectivoDAO efectivoDAO;
|
||||||
|
private static final EgresoDAO egresoDAO;
|
||||||
|
private static final InformeEgresosContentDAO egresosContentDAO;
|
||||||
|
private static final InformeLibroDeVentasContentDAO libroDeVentasContentDAO;
|
||||||
|
private static final IngresoDAO ingresoDAO;
|
||||||
|
private static final TipoEgresoDAO tipoEgresoDAO;
|
||||||
|
private static final TipoIngresoDAO tipoIngresoDAO;
|
||||||
|
|
||||||
|
static {
|
||||||
|
cajaDAO = new SQLiteCajaDAO();
|
||||||
|
calculoFondoDAO = new SQLiteCalculoFondoDAO();
|
||||||
|
documentosDAO = new SQLiteDocumentosDAO();
|
||||||
|
efectivoDAO = new SQLiteEfectivoDAO();
|
||||||
|
egresoDAO = new SQLiteEgresoDAO();
|
||||||
|
egresosContentDAO = new SQLiteInformeEgresosContentDAO();
|
||||||
|
libroDeVentasContentDAO = new SQLiteInformeLibroDeVentasContentDAO();
|
||||||
|
ingresoDAO = new SQLiteIngresoDAO();
|
||||||
|
tipoEgresoDAO = new SQLiteTipoEgresoDAO();
|
||||||
|
tipoIngresoDAO = new SQLiteTipoIngresoDAO();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CajaDAO getCajaDAO() {
|
||||||
|
return cajaDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CalculoFondoDAO getCalculoFondoDAO() {
|
||||||
|
return calculoFondoDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DocumentosDAO getDocumentosDAO() {
|
||||||
|
return documentosDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EfectivoDAO getEfectivoDAO() {
|
||||||
|
return efectivoDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EgresoDAO getEgresoDAO() {
|
||||||
|
return egresoDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InformeEgresosContentDAO getEgresosContentDAO() {
|
||||||
|
return egresosContentDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static InformeLibroDeVentasContentDAO getLibroDeVentasContentDAO() {
|
||||||
|
return libroDeVentasContentDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IngresoDAO getIngresoDAO() {
|
||||||
|
return ingresoDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TipoEgresoDAO getTipoEgresoDAO() {
|
||||||
|
return tipoEgresoDAO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TipoIngresoDAO getTipoIngresoDAO() {
|
||||||
|
return tipoIngresoDAO;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.informes;
|
package danielcortes.xyz.informes;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.DAOManager;
|
||||||
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
|
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
|
||||||
import danielcortes.xyz.models.informes.libro_de_ventas.InformeLibroDeVentasContent;
|
import danielcortes.xyz.models.informes.libro_de_ventas.InformeLibroDeVentasContent;
|
||||||
import danielcortes.xyz.models.informes.libro_de_ventas.SQLiteInformeLibroDeVentasContentDAO;
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
@@ -77,7 +77,7 @@ public class InformeLibroDeVentas {
|
|||||||
public InformeLibroDeVentas(LocalDate date, Path saveFile) {
|
public InformeLibroDeVentas(LocalDate date, Path saveFile) {
|
||||||
new SQLiteCajaDAO().createCajasForMonth(date);
|
new SQLiteCajaDAO().createCajasForMonth(date);
|
||||||
|
|
||||||
this.informe = new ArrayList<>(new SQLiteInformeLibroDeVentasContentDAO().getInformeMensual(date));
|
this.informe = new ArrayList<>(DAOManager.getLibroDeVentasContentDAO().getInformeMensual(date));
|
||||||
this.informeSize = this.informe.size();
|
this.informeSize = this.informe.size();
|
||||||
this.saveFile = saveFile;
|
this.saveFile = saveFile;
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.informes.libro_de_ventas;
|
package danielcortes.xyz.models.informes.libro_de_ventas;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import danielcortes.xyz.utils.NaturalOrderComparator;
|
import danielcortes.xyz.utils.NaturalOrderComparator;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -63,6 +64,7 @@ public class SQLiteInformeLibroDeVentasContentDAO extends InformeLibroDeVentasCo
|
|||||||
private HashMap<Integer, InformeLibroDeVentasContent> map;
|
private HashMap<Integer, InformeLibroDeVentasContent> map;
|
||||||
|
|
||||||
public SQLiteInformeLibroDeVentasContentDAO() {
|
public SQLiteInformeLibroDeVentasContentDAO() {
|
||||||
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
this.map = new HashMap<>();
|
this.map = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ package danielcortes.xyz.utils;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class NaturalOrderComparator implements Comparator {
|
public class NaturalOrderComparator implements Comparator {
|
||||||
|
static char charAt(String s, int i) {
|
||||||
|
return i >= s.length() ? 0 : s.charAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
int compareRight(String a, String b) {
|
int compareRight(String a, String b) {
|
||||||
int bias = 0, ia = 0, ib = 0;
|
int bias = 0, ia = 0, ib = 0;
|
||||||
|
|
||||||
@@ -121,8 +125,4 @@ public class NaturalOrderComparator implements Comparator {
|
|||||||
++ib;
|
++ib;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char charAt(String s, int i) {
|
|
||||||
return i >= s.length() ? 0 : s.charAt(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -53,14 +53,6 @@ public class NumberFormatedTextField extends JTextField {
|
|||||||
this.addFocusListener(new FieldFocusListener());
|
this.addFocusListener(new FieldFocusListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Guarda el integer entregado y lo muestra en el campo.
|
|
||||||
*/
|
|
||||||
public void setValue(int value) {
|
|
||||||
this.value = value;
|
|
||||||
this.setText(nf.format(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Llama a readValue por un bug seguramente relacionado con el focus listener:
|
* Llama a readValue por un bug seguramente relacionado con el focus listener:
|
||||||
* - No actualizaba el valor al momento de hacer requestfocus a otro componente, probablemente porque no alcanza
|
* - No actualizaba el valor al momento de hacer requestfocus a otro componente, probablemente porque no alcanza
|
||||||
@@ -73,6 +65,14 @@ public class NumberFormatedTextField extends JTextField {
|
|||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guarda el integer entregado y lo muestra en el campo.
|
||||||
|
*/
|
||||||
|
public void setValue(int value) {
|
||||||
|
this.value = value;
|
||||||
|
this.setText(nf.format(value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lee el valor en el texto, ejecuta la operacion matematica que en caso que exista una y la almacena en el valor
|
* Lee el valor en el texto, ejecuta la operacion matematica que en caso que exista una y la almacena en el valor
|
||||||
* Si la operacion matematica es invalida, almacenara un 0
|
* Si la operacion matematica es invalida, almacenara un 0
|
||||||
|
|||||||
Reference in New Issue
Block a user