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:
@@ -25,14 +25,10 @@
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.NextAction;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.calculo_fondo.SQLiteCalculoFondoDAO;
|
||||
import danielcortes.xyz.models.documentos.Documentos;
|
||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
||||
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.CalcularFondoView;
|
||||
import danielcortes.xyz.views.components.NumberFormatedTextField;
|
||||
@@ -51,21 +47,11 @@ public class ArqueoController {
|
||||
private Efectivo efectivo;
|
||||
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.
|
||||
*/
|
||||
public ArqueoController(ArqueoView view, EfectivoDAO efectivoDAO, DocumentosDAO documentosDAO, IngresoDAO ingresoDAO, EgresoDAO egresoDAO) {
|
||||
public ArqueoController(ArqueoView view) {
|
||||
this.view = view;
|
||||
this.efectivoDAO = efectivoDAO;
|
||||
this.documentosDAO = documentosDAO;
|
||||
this.ingresoDAO = ingresoDAO;
|
||||
this.egresoDAO = egresoDAO;
|
||||
|
||||
this.setUpViewEvents();
|
||||
}
|
||||
|
||||
@@ -92,7 +78,7 @@ public class ArqueoController {
|
||||
* Rellena los campos del efectivo con la instancia de efectivo que pertenece a la caja
|
||||
*/
|
||||
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.getDiezMilField().setValue(efectivo.getDiezMil());
|
||||
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
|
||||
*/
|
||||
private void fillDocumentos() {
|
||||
this.documentos = this.documentosDAO.findByCaja(caja);
|
||||
this.documentos = DAOManager.getDocumentosDAO().findByCaja(caja);
|
||||
this.view.getTarjetasField().setValue(documentos.getTarjetas());
|
||||
this.view.getChequesField().setValue(documentos.getCheques());
|
||||
this.view.getRetiroField().setValue(documentos.getRetiros());
|
||||
@@ -129,7 +115,7 @@ public class ArqueoController {
|
||||
*/
|
||||
private void updateResumenEfectivo() {
|
||||
NumberFormatedTextField efectivoField = this.view.getEfectivoField();
|
||||
int total = efectivoDAO.getTotalEfectivo(this.caja);
|
||||
int total = DAOManager.getEfectivoDAO().getTotalEfectivo(this.caja);
|
||||
efectivoField.setValue(total);
|
||||
}
|
||||
|
||||
@@ -138,7 +124,7 @@ public class ArqueoController {
|
||||
*/
|
||||
private void updateResumenDocumentos() {
|
||||
NumberFormatedTextField documentosField = this.view.getDocumentosField();
|
||||
int total = documentosDAO.getTotalDocumentos(this.caja);
|
||||
int total = DAOManager.getDocumentosDAO().getTotalDocumentos(this.caja);
|
||||
documentosField.setValue(total);
|
||||
}
|
||||
|
||||
@@ -146,7 +132,7 @@ public class ArqueoController {
|
||||
* Obtiene el total de egresos y lo muestra en el campo de egresosField
|
||||
*/
|
||||
private void updateResumenEgresos() {
|
||||
int total = this.egresoDAO.getTotalEgreso(this.caja);
|
||||
int total = DAOManager.getEgresoDAO().getTotalEgreso(this.caja);
|
||||
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
|
||||
*/
|
||||
private void updateResumenArqueo() {
|
||||
int totalEfectivo = efectivoDAO.getTotalEfectivo(this.caja);
|
||||
int totalDocumentos = documentosDAO.getTotalDocumentos(this.caja);
|
||||
int totalEgresos = egresoDAO.getTotalEgreso(this.caja);
|
||||
int totalIngresos = ingresoDAO.getTotalIngreso(this.caja);
|
||||
int totalEfectivo = DAOManager.getEfectivoDAO().getTotalEfectivo(this.caja);
|
||||
int totalDocumentos = DAOManager.getDocumentosDAO().getTotalDocumentos(this.caja);
|
||||
int totalEgresos = DAOManager.getEgresoDAO().getTotalEgreso(this.caja);
|
||||
int totalIngresos = DAOManager.getIngresoDAO().getTotalIngreso(this.caja);
|
||||
|
||||
int rendido = totalDocumentos + totalEfectivo + totalEgresos;
|
||||
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.
|
||||
*/
|
||||
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.setDiezMil(diezMil);
|
||||
this.efectivo.setVeinteMil(veinteMil);
|
||||
this.efectivoDAO.updateEfectivo(efectivo);
|
||||
DAOManager.getEfectivoDAO().updateEfectivo(efectivo);
|
||||
|
||||
this.updateResumenEfectivo();
|
||||
this.updateResumenArqueo();
|
||||
@@ -286,7 +272,7 @@ public class ArqueoController {
|
||||
this.documentos.setTarjetas(tarjetas);
|
||||
this.documentos.setCheques(cheques);
|
||||
this.documentos.setRetiros(retiros);
|
||||
this.documentosDAO.updateDocumentos(documentos);
|
||||
DAOManager.getDocumentosDAO().updateDocumentos(documentos);
|
||||
|
||||
this.updateResumenDocumentos();
|
||||
this.updateResumenArqueo();
|
||||
|
||||
Reference in New Issue
Block a user