Generacion de informes desde la interfaz :3
This commit is contained in:
@@ -184,7 +184,6 @@ public class ArqueoController {
|
||||
this.view.getCienField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getCincuentaField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getDiezField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"save");
|
||||
this.view.getGuardarEfectivoButton().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"save");
|
||||
|
||||
this.view.getVeinteMilField().getActionMap().put("nextField", new NextAction(this.view.getDiezMilField()));
|
||||
this.view.getDiezMilField().getActionMap().put("nextField", new NextAction(this.view.getCincoMilField()));
|
||||
@@ -195,14 +194,20 @@ public class ArqueoController {
|
||||
this.view.getCienField().getActionMap().put("nextField", new NextAction(this.view.getCincuentaField()));
|
||||
this.view.getCincuentaField().getActionMap().put("nextField", new NextAction(this.view.getDiezField()));
|
||||
this.view.getDiezField().getActionMap().put("save", new GuardarEfectivoAction(this));
|
||||
this.view.getGuardarEfectivoButton().getActionMap().put("save", new GuardarEfectivoAction(this));
|
||||
|
||||
|
||||
this.view.getChequesField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getTarjetasField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"save");
|
||||
this.view.getChequesField().getActionMap().put("nextField", new NextAction(this.view.getTarjetasField()));
|
||||
this.view.getTarjetasField().getActionMap().put("save", new GuardarDocumentosAction(this));
|
||||
this.view.getGuardarDocumentosButton().getActionMap().put("save", new GuardarDocumentosAction(this));
|
||||
|
||||
this.view.getGuardarEfectivoButton().addActionListener(e ->{
|
||||
this.guardarEfectivoActionListener();
|
||||
});
|
||||
this.view.getGuardarDocumentosButton().addActionListener(e ->{
|
||||
this.guardarEfectivoActionListener();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
93
src/danielcortes/xyz/controllers/InformesController.java
Normal file
93
src/danielcortes/xyz/controllers/InformesController.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.controllers;
|
||||
|
||||
import danielcortes.xyz.informes.InformeMensual;
|
||||
import danielcortes.xyz.views.InformeMensualDialog;
|
||||
import danielcortes.xyz.views.InformesView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class InformesController {
|
||||
private InformesView view;
|
||||
|
||||
public InformesController(InformesView view) {
|
||||
this.view = view;
|
||||
this.setupViewEvents();
|
||||
}
|
||||
|
||||
private void setupViewEvents() {
|
||||
this.view.getInformeMensualButton().addActionListener(e -> generarInformeMensualListener());
|
||||
}
|
||||
|
||||
private void generarInformeMensualListener() {
|
||||
LocalDate month = askForMonth();
|
||||
if (month == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM YYYY");
|
||||
String formatedName = month.format(formatter);
|
||||
String capitalized = formatedName.substring(0, 1).toUpperCase() + formatedName.substring(1);
|
||||
File saveFile = askForFile("Informe "+ capitalized);
|
||||
if (saveFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
InformeMensual informeMensual = new InformeMensual(month, saveFile);
|
||||
informeMensual.generarInforme();
|
||||
}
|
||||
|
||||
private LocalDate askForMonth() {
|
||||
InformeMensualDialog informeMensualDialog = new InformeMensualDialog(this.view.getContentPanel());
|
||||
if (informeMensualDialog.isAcepted()) {
|
||||
return informeMensualDialog.getMonth();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private File askForFile(String suggestedName) {
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setDialogType(JFileChooser.SAVE_DIALOG);
|
||||
chooser.setSelectedFile(new File(suggestedName+".xls"));
|
||||
chooser.setFileFilter(new FileNameExtensionFilter("Excel 2007", "xls"));
|
||||
|
||||
if (chooser.showSaveDialog(this.view.getContentPanel()) == JFileChooser.APPROVE_OPTION) {
|
||||
String filename = chooser.getSelectedFile().toString();
|
||||
if (!filename.endsWith(".xls"))
|
||||
filename += ".xls";
|
||||
|
||||
return new File(filename);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,10 +41,7 @@ import danielcortes.xyz.models.tipo_egreso.MysqlTipoEgresoDAO;
|
||||
import danielcortes.xyz.models.tipo_ingreso.MysqlTipoIngresoDAO;
|
||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngreso;
|
||||
import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO;
|
||||
import danielcortes.xyz.views.ArqueoView;
|
||||
import danielcortes.xyz.views.EgresosView;
|
||||
import danielcortes.xyz.views.IngresosView;
|
||||
import danielcortes.xyz.views.ManagerView;
|
||||
import danielcortes.xyz.views.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -60,6 +57,7 @@ public class ManagerController {
|
||||
private IngresosController ingresosController;
|
||||
private EgresosController egresosController;
|
||||
private ArqueoController arqueoController;
|
||||
private InformesController informesController;
|
||||
|
||||
private CajaDAO cajaDAO;
|
||||
private DocumentosDAO documentosDAO;
|
||||
@@ -123,6 +121,10 @@ public class ManagerController {
|
||||
CardLayout layout = (CardLayout) this.view.getCardPanel().getLayout();
|
||||
layout.show(this.view.getCardPanel(), "ARQUEO");
|
||||
});
|
||||
this.view.getInformesButton().addActionListener(e -> {
|
||||
CardLayout layout = (CardLayout) this.view.getCardPanel().getLayout();
|
||||
layout.show(this.view.getCardPanel(), "INFORMES");
|
||||
});
|
||||
this.view.getDatePicker().addDateChangeListener(e -> updateCaja());
|
||||
}
|
||||
|
||||
@@ -159,6 +161,7 @@ public class ManagerController {
|
||||
this.loadEgresosView();
|
||||
this.loadIngresosView();
|
||||
this.loadArqueoView();
|
||||
this.loadInformesView();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,6 +197,13 @@ public class ManagerController {
|
||||
this.arqueoController = new ArqueoController(arqueoView, this.efectivoDAO, this.documentosDAO, this.ingresoDAO, this.egresoDAO);
|
||||
}
|
||||
|
||||
private void loadInformesView() {
|
||||
InformesView informesView = new InformesView();
|
||||
this.view.getCardPanel().add(informesView.getContentPanel(), "INFORMES");
|
||||
|
||||
this.informesController = new InformesController(informesView);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activa el primer boton del manager
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user