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();
|
||||
|
||||
@@ -2,9 +2,9 @@ package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.NextAction;
|
||||
import danielcortes.xyz.data.Configuration;
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.calculo_fondo.CalculoFondo;
|
||||
import danielcortes.xyz.models.calculo_fondo.CalculoFondoDAO;
|
||||
import danielcortes.xyz.views.CalcularFondoView;
|
||||
import danielcortes.xyz.views.components.FondoTableModel;
|
||||
|
||||
@@ -17,17 +17,15 @@ public class CalcularFondoController {
|
||||
private JComponent parent;
|
||||
private CalcularFondoView view;
|
||||
private Caja caja;
|
||||
private CalculoFondoDAO calculoFondoDAO;
|
||||
|
||||
private int editingId;
|
||||
private boolean editing;
|
||||
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.parent = parent;
|
||||
this.caja = caja;
|
||||
this.calculoFondoDAO = calculoFondoDAO;
|
||||
|
||||
this.fillTable();
|
||||
this.updateResumen();
|
||||
@@ -48,7 +46,7 @@ public class CalcularFondoController {
|
||||
private void fillTable() {
|
||||
FondoTableModel tableModel = this.view.getTableModel();
|
||||
tableModel.removeRows();
|
||||
for (CalculoFondo calculoFondo : this.calculoFondoDAO.findByCaja(this.caja)) {
|
||||
for (CalculoFondo calculoFondo : DAOManager.getCalculoFondoDAO().findByCaja(this.caja)) {
|
||||
tableModel.addRow(calculoFondo);
|
||||
}
|
||||
}
|
||||
@@ -117,7 +115,7 @@ public class CalcularFondoController {
|
||||
if (selectedID >= 0) {
|
||||
CalculoFondo calculoFondo = this.view.getTableModel().getCalculoFondo(selectedID);
|
||||
this.view.getTableModel().removeRow(selectedID);
|
||||
this.calculoFondoDAO.deleteCalculoFondo(calculoFondo);
|
||||
DAOManager.getCalculoFondoDAO().deleteCalculoFondo(calculoFondo);
|
||||
this.updateResumen();
|
||||
this.updateButtonsEnabled();
|
||||
this.resetFocus();
|
||||
@@ -129,7 +127,7 @@ public class CalcularFondoController {
|
||||
calculoFondo.setValor(valor);
|
||||
calculoFondo.setDescripcion(descripcion);
|
||||
calculoFondo.setCaja(this.caja);
|
||||
this.calculoFondoDAO.insertCalculoFondo(calculoFondo);
|
||||
DAOManager.getCalculoFondoDAO().insertCalculoFondo(calculoFondo);
|
||||
this.view.getTableModel().addRow(calculoFondo);
|
||||
}
|
||||
|
||||
@@ -137,7 +135,7 @@ public class CalcularFondoController {
|
||||
this.editingCalculoFondo.setValor(valor);
|
||||
this.editingCalculoFondo.setDescripcion(descripcion);
|
||||
this.editingCalculoFondo.setCaja(this.caja);
|
||||
this.calculoFondoDAO.updateCalculoFondo(editingCalculoFondo);
|
||||
DAOManager.getCalculoFondoDAO().updateCalculoFondo(editingCalculoFondo);
|
||||
this.view.getTableModel().setCalculoFondo(this.editingId, this.editingCalculoFondo);
|
||||
}
|
||||
|
||||
@@ -153,7 +151,7 @@ public class CalcularFondoController {
|
||||
|
||||
private void updateResumen() {
|
||||
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.getDepositoField().setValue(suma - fondo);
|
||||
}
|
||||
|
||||
@@ -25,11 +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.egreso.Egreso;
|
||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
||||
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
|
||||
import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO;
|
||||
import danielcortes.xyz.views.EgresosView;
|
||||
import danielcortes.xyz.views.components.EgresosTableModel;
|
||||
|
||||
@@ -44,8 +43,6 @@ import java.awt.event.MouseEvent;
|
||||
*/
|
||||
public class EgresosController {
|
||||
private EgresosView view;
|
||||
private EgresoDAO egresoDAO;
|
||||
private TipoEgresoDAO tipoEgresoDAO;
|
||||
private Caja caja;
|
||||
|
||||
private int editingId;
|
||||
@@ -59,33 +56,13 @@ public class EgresosController {
|
||||
* - Metodo que llena los tipos de egresos en la vista.
|
||||
* - Actualiza el estado de los botones.
|
||||
*/
|
||||
public EgresosController(EgresosView view, EgresoDAO egresoDAO, TipoEgresoDAO tipoEgresoDAO) {
|
||||
public EgresosController(EgresosView view) {
|
||||
this.view = view;
|
||||
this.egresoDAO = egresoDAO;
|
||||
this.tipoEgresoDAO = tipoEgresoDAO;
|
||||
this.setUpViewEvents();
|
||||
this.fillTipoEgresoCombo();
|
||||
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.
|
||||
*/
|
||||
@@ -100,7 +77,7 @@ public class EgresosController {
|
||||
*/
|
||||
private void fillTipoEgresoCombo() {
|
||||
JComboBox<TipoEgreso> tipoCombo = view.getTipoCombo();
|
||||
for (TipoEgreso tipoEgreso : this.tipoEgresoDAO.findAll()) {
|
||||
for (TipoEgreso tipoEgreso : DAOManager.getTipoEgresoDAO().findAll()) {
|
||||
tipoCombo.addItem(tipoEgreso);
|
||||
}
|
||||
}
|
||||
@@ -111,7 +88,7 @@ public class EgresosController {
|
||||
private void fillEgresosTable() {
|
||||
EgresosTableModel egresosTableModel = view.getEgresosTableModel();
|
||||
egresosTableModel.removeRows();
|
||||
for (Egreso egreso : this.egresoDAO.findByCaja(this.caja)) {
|
||||
for (Egreso egreso : DAOManager.getEgresoDAO().findByCaja(this.caja)) {
|
||||
egresosTableModel.addRow(egreso);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +159,7 @@ public class EgresosController {
|
||||
if (selectedID >= 0) {
|
||||
Egreso egreso = this.view.getEgresosTableModel().getEgreso(selectedID);
|
||||
this.view.getEgresosTableModel().removeRow(selectedID);
|
||||
this.egresoDAO.deleteEgreso(egreso);
|
||||
DAOManager.getEgresoDAO().deleteEgreso(egreso);
|
||||
this.updateTotalEgresos();
|
||||
this.updateButtonsEnabled();
|
||||
this.resetFocus();
|
||||
@@ -219,7 +196,7 @@ public class EgresosController {
|
||||
* Obtiene el total de egresos y los coloca en el campo de totalEgresosField.
|
||||
*/
|
||||
private void updateTotalEgresos() {
|
||||
int total = this.egresoDAO.getTotalEgreso(this.caja);
|
||||
int total = DAOManager.getEgresoDAO().getTotalEgreso(this.caja);
|
||||
this.view.getTotalEgresosField().setValue(total);
|
||||
}
|
||||
|
||||
@@ -249,7 +226,7 @@ public class EgresosController {
|
||||
egreso.setNro(nro);
|
||||
egreso.setTipoEgreso(tipo);
|
||||
egreso.setCaja(caja);
|
||||
egresoDAO.insertEgreso(egreso);
|
||||
DAOManager.getEgresoDAO().insertEgreso(egreso);
|
||||
this.view.getEgresosTableModel().addRow(egreso);
|
||||
this.updateTotalEgresos();
|
||||
this.clearInputs();
|
||||
@@ -263,11 +240,11 @@ public class EgresosController {
|
||||
*/
|
||||
private void editarEgreso(String nro, String descripcion, int valor, TipoEgreso tipo, Caja caja) {
|
||||
if (this.validateInput(nro, descripcion, tipo, caja)) {
|
||||
this.editingEgreso.setValor(Integer.valueOf(valor));
|
||||
this.editingEgreso.setValor(valor);
|
||||
this.editingEgreso.setDescripcion(descripcion);
|
||||
this.editingEgreso.setNro(nro);
|
||||
this.editingEgreso.setTipoEgreso(tipo);
|
||||
egresoDAO.updateEgreso(this.editingEgreso);
|
||||
DAOManager.getEgresoDAO().updateEgreso(this.editingEgreso);
|
||||
this.view.getEgresosTableModel().setEgreso(this.editingId, this.editingEgreso);
|
||||
this.updateTotalEgresos();
|
||||
this.clearInputs();
|
||||
|
||||
@@ -24,11 +24,10 @@
|
||||
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
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.TipoIngresoDAO;
|
||||
import danielcortes.xyz.views.IngresosView;
|
||||
import danielcortes.xyz.views.components.IngresosTableModel;
|
||||
|
||||
@@ -43,8 +42,6 @@ import java.awt.event.MouseEvent;
|
||||
*/
|
||||
public class IngresosController {
|
||||
private IngresosView view;
|
||||
private IngresoDAO ingresoDAO;
|
||||
private TipoIngresoDAO tipoIngresoDAO;
|
||||
private Caja caja;
|
||||
|
||||
private int editingId;
|
||||
@@ -58,30 +55,13 @@ public class IngresosController {
|
||||
* - Metodo que genera los eventos para la vista
|
||||
* - Metodo que actualiza el estado de los botones
|
||||
*/
|
||||
public IngresosController(IngresosView view, IngresoDAO ingresoDAO, TipoIngresoDAO tipoIngresoDAO) {
|
||||
public IngresosController(IngresosView view) {
|
||||
this.view = view;
|
||||
this.ingresoDAO = ingresoDAO;
|
||||
this.tipoIngresoDAO = tipoIngresoDAO;
|
||||
this.fillTipoIngresoCombo();
|
||||
this.setupViewEvents();
|
||||
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
|
||||
@@ -97,7 +77,7 @@ public class IngresosController {
|
||||
*/
|
||||
private void fillTipoIngresoCombo() {
|
||||
JComboBox<TipoIngreso> tipoCombo = this.view.getTipoCombo();
|
||||
for (TipoIngreso tipo : this.tipoIngresoDAO.findAll()) {
|
||||
for (TipoIngreso tipo : DAOManager.getTipoIngresoDAO().findAll()) {
|
||||
tipoCombo.addItem(tipo);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +88,7 @@ public class IngresosController {
|
||||
private void fillIngresosTable() {
|
||||
IngresosTableModel ingresosTableModel = this.view.getIngresosTableModel();
|
||||
ingresosTableModel.removeRows();
|
||||
for (Ingreso ingreso : this.ingresoDAO.findByCaja(this.caja)) {
|
||||
for (Ingreso ingreso : DAOManager.getIngresoDAO().findByCaja(this.caja)) {
|
||||
ingresosTableModel.addRow(ingreso);
|
||||
}
|
||||
}
|
||||
@@ -186,7 +166,7 @@ public class IngresosController {
|
||||
if (selectedId >= 0) {
|
||||
Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedId);
|
||||
this.view.getIngresosTableModel().removeRow(selectedId);
|
||||
this.ingresoDAO.deleteIngreso(ingreso);
|
||||
DAOManager.getIngresoDAO().deleteIngreso(ingreso);
|
||||
this.updateTotalIngresos();
|
||||
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
|
||||
*/
|
||||
private void updateTotalIngresos() {
|
||||
int total = this.ingresoDAO.getTotalIngreso(this.caja);
|
||||
int total = DAOManager.getIngresoDAO().getTotalIngreso(this.caja);
|
||||
this.view.getTotalIngresoField().setValue(total);
|
||||
}
|
||||
|
||||
@@ -257,7 +237,7 @@ public class IngresosController {
|
||||
ingreso.setNroInicial(nroInicial);
|
||||
ingreso.setNroFinal(nroFinal);
|
||||
|
||||
this.ingresoDAO.insertIngreso(ingreso);
|
||||
DAOManager.getIngresoDAO().insertIngreso(ingreso);
|
||||
this.view.getIngresosTableModel().addRow(ingreso);
|
||||
|
||||
this.clearInputs();
|
||||
@@ -277,7 +257,7 @@ public class IngresosController {
|
||||
this.editingIngreso.setNroZFinal(nroZFinal);
|
||||
this.editingIngreso.setNroInicial(nroInicial);
|
||||
this.editingIngreso.setNroFinal(nroFinal);
|
||||
this.ingresoDAO.updateIngreso(this.editingIngreso);
|
||||
DAOManager.getIngresoDAO().updateIngreso(this.editingIngreso);
|
||||
this.view.getIngresosTableModel().setIngreso(this.editingId, this.editingIngreso);
|
||||
this.updateTotalIngresos();
|
||||
this.clearInputs();
|
||||
|
||||
@@ -24,16 +24,10 @@
|
||||
|
||||
package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.data.DAOManager;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.caja.CajaDAO;
|
||||
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.models.tipo_egreso.TipoEgresoDAO;
|
||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
|
||||
import danielcortes.xyz.views.*;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -51,14 +45,6 @@ public class ManagerController {
|
||||
private ArqueoController arqueoController;
|
||||
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
|
||||
* Necesita todos las interfaces DAO para poder asignarselos a sus vistas,
|
||||
@@ -70,15 +56,8 @@ public class ManagerController {
|
||||
* - Genera los eventos de la vista
|
||||
* - 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.cajaDAO = cajaDAO;
|
||||
this.documentosDAO = documentosDAO;
|
||||
this.efectivoDAO = efectivoDAO;
|
||||
this.egresoDAO = egresoDAO;
|
||||
this.ingresoDAO = ingresoDAO;
|
||||
this.tipoEgresoDAO = tipoEgresoDAO;
|
||||
this.tipoIngresoDAO = tipoIngresoDAO;
|
||||
this.loadCardContents();
|
||||
this.setUpDate();
|
||||
this.setUpViewEvents();
|
||||
@@ -125,20 +104,20 @@ public class ManagerController {
|
||||
*/
|
||||
private void updateCaja() {
|
||||
LocalDate selectedDate = this.view.getDatePicker().getDate();
|
||||
Caja caja = this.cajaDAO.findByFecha(selectedDate);
|
||||
Caja caja = DAOManager.getCajaDAO().findByFecha(selectedDate);
|
||||
|
||||
if (caja == null) {
|
||||
caja = new Caja();
|
||||
caja.setFecha(selectedDate);
|
||||
this.cajaDAO.insertCaja(caja);
|
||||
DAOManager.getCajaDAO().insertCaja(caja);
|
||||
|
||||
Efectivo efectivo = new Efectivo();
|
||||
efectivo.setCaja(caja);
|
||||
this.efectivoDAO.insertDefaultEfectivo(efectivo);
|
||||
DAOManager.getEfectivoDAO().insertDefaultEfectivo(efectivo);
|
||||
|
||||
Documentos documentos = new Documentos();
|
||||
documentos.setCaja(caja);
|
||||
this.documentosDAO.insertDefaultDocumentos(documentos);
|
||||
DAOManager.getDocumentosDAO().insertDefaultDocumentos(documentos);
|
||||
}
|
||||
|
||||
this.ingresosController.updateCaja(caja);
|
||||
@@ -164,7 +143,7 @@ public class ManagerController {
|
||||
|
||||
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.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.arqueoController = new ArqueoController(arqueoView, this.efectivoDAO, this.documentosDAO, this.ingresoDAO, this.egresoDAO);
|
||||
this.arqueoController = new ArqueoController(arqueoView);
|
||||
}
|
||||
|
||||
private void loadInformesView() {
|
||||
|
||||
Reference in New Issue
Block a user