Funcionalidad de ingresar documentos en el arqueo!
This commit is contained in:
@@ -25,6 +25,8 @@
|
|||||||
package danielcortes.xyz.controllers;
|
package danielcortes.xyz.controllers;
|
||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
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.efectivo.EfectivoDAO;
|
||||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
import danielcortes.xyz.models.egreso.EgresoDAO;
|
||||||
@@ -36,15 +38,19 @@ import javax.swing.*;
|
|||||||
|
|
||||||
public class ArqueoController {
|
public class ArqueoController {
|
||||||
private ArqueoView view;
|
private ArqueoView view;
|
||||||
private EfectivoDAO efectivoDAO;
|
|
||||||
private Caja caja;
|
private Caja caja;
|
||||||
private Efectivo efectivo;
|
private Efectivo efectivo;
|
||||||
|
private Documentos documentos;
|
||||||
|
|
||||||
|
private EfectivoDAO efectivoDAO;
|
||||||
|
private DocumentosDAO documentosDAO;
|
||||||
private IngresoDAO ingresoDAO;
|
private IngresoDAO ingresoDAO;
|
||||||
private EgresoDAO egresoDAO;
|
private EgresoDAO egresoDAO;
|
||||||
|
|
||||||
public ArqueoController(ArqueoView view, EfectivoDAO efectivoDAO, IngresoDAO ingresoDAO, EgresoDAO egresoDAO) {
|
public ArqueoController(ArqueoView view, EfectivoDAO efectivoDAO, DocumentosDAO documentosDAO, IngresoDAO ingresoDAO, EgresoDAO egresoDAO) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.efectivoDAO = efectivoDAO;
|
this.efectivoDAO = efectivoDAO;
|
||||||
|
this.documentosDAO = documentosDAO;
|
||||||
this.ingresoDAO = ingresoDAO;
|
this.ingresoDAO = ingresoDAO;
|
||||||
this.egresoDAO = egresoDAO;
|
this.egresoDAO = egresoDAO;
|
||||||
|
|
||||||
@@ -76,7 +82,9 @@ public class ArqueoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillDocumentos() {
|
private void fillDocumentos() {
|
||||||
|
this.documentos = this.documentosDAO.findByCaja(caja);
|
||||||
|
this.view.getTarjetasField().setText(String.valueOf(documentos.getTarjetas()));
|
||||||
|
this.view.getChequesField().setText(String.valueOf(documentos.getCheques()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillResumen() {
|
private void fillResumen() {
|
||||||
@@ -104,7 +112,12 @@ public class ArqueoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateResumenDocumentos() {
|
private void updateResumenDocumentos() {
|
||||||
|
JTextField documentosField = this.view.getDocumentosField();
|
||||||
|
int total = 0;
|
||||||
|
total += this.documentos.getCheques();
|
||||||
|
total += this.documentos.getTarjetas();
|
||||||
|
|
||||||
|
documentosField.setText(String.valueOf(total));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateResumenIngresos() {
|
private void updateResumenIngresos() {
|
||||||
@@ -126,6 +139,10 @@ public class ArqueoController {
|
|||||||
this.normalizeEfectivoInput();
|
this.normalizeEfectivoInput();
|
||||||
this.guardarEfectivo();
|
this.guardarEfectivo();
|
||||||
});
|
});
|
||||||
|
this.view.getGuardarDocumentosButton().addActionListener(e -> {
|
||||||
|
this.normalizeDocumentosInput();
|
||||||
|
this.guardarDocumentos();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void guardarEfectivo() {
|
private void guardarEfectivo() {
|
||||||
@@ -155,6 +172,19 @@ public class ArqueoController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void guardarDocumentos() {
|
||||||
|
String tarjetas = this.view.getTarjetasField().getText();
|
||||||
|
String cheques = this.view.getChequesField().getText();
|
||||||
|
|
||||||
|
if (this.validateDocumentosInput(tarjetas, cheques)) {
|
||||||
|
this.documentos.setTarjetas(Integer.valueOf(tarjetas));
|
||||||
|
this.documentos.setCheques(Integer.valueOf(cheques));
|
||||||
|
this.documentosDAO.updateDocumentos(documentos);
|
||||||
|
|
||||||
|
this.updateResumenDocumentos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean validateEfectivoInput(String diez, String cincuenta, String cien, String quinientos, String mil, String dosMil, String cincoMil, String diezMil, String veinteMil) {
|
private boolean validateEfectivoInput(String diez, String cincuenta, String cien, String quinientos, String mil, String dosMil, String cincoMil, String diezMil, String veinteMil) {
|
||||||
this.hiddeEfectivoErrorMessages();
|
this.hiddeEfectivoErrorMessages();
|
||||||
|
|
||||||
@@ -171,6 +201,15 @@ public class ArqueoController {
|
|||||||
return diezValidation && cincuentaValidation && cienValidation && quinientosValidation && milValidation && dosMilValidation && cincoMilValidation && diezMilValidation && veinteMilValidation;
|
return diezValidation && cincuentaValidation && cienValidation && quinientosValidation && milValidation && dosMilValidation && cincoMilValidation && diezMilValidation && veinteMilValidation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean validateDocumentosInput(String tarjetas, String cheques) {
|
||||||
|
this.hiddeDocumentosErrorMessages();
|
||||||
|
|
||||||
|
boolean tarjetasValidation = validateDocumentosValor(tarjetas, this.view.getErrorTarjetas());
|
||||||
|
boolean chequesValidation = validateDocumentosValor(cheques, this.view.getErrorCheques());
|
||||||
|
|
||||||
|
return tarjetasValidation && chequesValidation;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean validateEfectivoMoneda(String valor, JLabel errorLabel) {
|
private boolean validateEfectivoMoneda(String valor, JLabel errorLabel) {
|
||||||
if (valor == null) {
|
if (valor == null) {
|
||||||
errorLabel.setText("Hubo un problema con los datos");
|
errorLabel.setText("Hubo un problema con los datos");
|
||||||
@@ -199,6 +238,35 @@ public class ArqueoController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean validateDocumentosValor(String valor, JLabel errorLabel) {
|
||||||
|
|
||||||
|
if (valor == null) {
|
||||||
|
errorLabel.setText("Hubo un problema con los datos");
|
||||||
|
errorLabel.setVisible(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valor.isEmpty()) {
|
||||||
|
errorLabel.setText("El campo esta vacio");
|
||||||
|
errorLabel.setVisible(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!valor.chars().allMatch(Character::isDigit)) {
|
||||||
|
errorLabel.setText("Deben ser numeros");
|
||||||
|
errorLabel.setVisible(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (valor.length() > 10) {
|
||||||
|
errorLabel.setText("El numero ingresado es demasiado largo");
|
||||||
|
errorLabel.setVisible(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void hiddeEfectivoErrorMessages() {
|
private void hiddeEfectivoErrorMessages() {
|
||||||
this.view.getErrorDiez().setVisible(false);
|
this.view.getErrorDiez().setVisible(false);
|
||||||
this.view.getErrorCincuenta().setVisible(false);
|
this.view.getErrorCincuenta().setVisible(false);
|
||||||
@@ -211,6 +279,11 @@ public class ArqueoController {
|
|||||||
this.view.getErrorVeinteMil().setVisible(false);
|
this.view.getErrorVeinteMil().setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void hiddeDocumentosErrorMessages(){
|
||||||
|
this.view.getErrorTarjetas().setVisible(false);
|
||||||
|
this.view.getErrorCheques().setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
private void normalizeEfectivoInput() {
|
private void normalizeEfectivoInput() {
|
||||||
this.view.getDiezField().setText(this.view.getDiezField().getText().trim());
|
this.view.getDiezField().setText(this.view.getDiezField().getText().trim());
|
||||||
this.view.getCincuentaField().setText(this.view.getCincuentaField().getText().trim());
|
this.view.getCincuentaField().setText(this.view.getCincuentaField().getText().trim());
|
||||||
@@ -223,4 +296,9 @@ public class ArqueoController {
|
|||||||
this.view.getVeinteMilField().setText(this.view.getVeinteMilField().getText().trim());
|
this.view.getVeinteMilField().setText(this.view.getVeinteMilField().getText().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void normalizeDocumentosInput() {
|
||||||
|
this.view.getChequesField().setText(this.view.getChequesField().getText().trim());
|
||||||
|
this.view.getTarjetasField().setText(this.view.getTarjetasField().getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ package danielcortes.xyz.controllers;
|
|||||||
|
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.caja.CajaDAO;
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
|
import danielcortes.xyz.models.documentos.Documentos;
|
||||||
|
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
||||||
|
import danielcortes.xyz.models.documentos.MysqlDocumentosDAO;
|
||||||
import danielcortes.xyz.models.efectivo.Efectivo;
|
import danielcortes.xyz.models.efectivo.Efectivo;
|
||||||
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
||||||
import danielcortes.xyz.models.efectivo.MysqlEfectivoDAO;
|
import danielcortes.xyz.models.efectivo.MysqlEfectivoDAO;
|
||||||
@@ -91,6 +94,7 @@ 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 = this.cajaDAO.findByFecha(selectedDate);
|
||||||
|
|
||||||
if(caja == null){
|
if(caja == null){
|
||||||
caja = new Caja();
|
caja = new Caja();
|
||||||
caja.setFecha(selectedDate);
|
caja.setFecha(selectedDate);
|
||||||
@@ -101,7 +105,12 @@ public class ManagerController {
|
|||||||
efectivo.setCaja(caja);
|
efectivo.setCaja(caja);
|
||||||
efectivoDAO.insertDefaultEfectivo(efectivo);
|
efectivoDAO.insertDefaultEfectivo(efectivo);
|
||||||
|
|
||||||
|
DocumentosDAO documentosDAO = new MysqlDocumentosDAO();
|
||||||
|
Documentos documentos = new Documentos();
|
||||||
|
documentos.setCaja(caja);
|
||||||
|
documentosDAO.insertDefaultDocumentos(documentos);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ingresosController.updateCaja(caja);
|
this.ingresosController.updateCaja(caja);
|
||||||
this.egresosController.updateCaja(caja);
|
this.egresosController.updateCaja(caja);
|
||||||
this.arqueoController.updateCaja(caja);
|
this.arqueoController.updateCaja(caja);
|
||||||
@@ -136,12 +145,13 @@ public class ManagerController {
|
|||||||
private void loadArqueoView() {
|
private void loadArqueoView() {
|
||||||
ArqueoView arqueoView = new ArqueoView();
|
ArqueoView arqueoView = new ArqueoView();
|
||||||
EfectivoDAO efectivoDAO = new MysqlEfectivoDAO();
|
EfectivoDAO efectivoDAO = new MysqlEfectivoDAO();
|
||||||
|
DocumentosDAO documentosDAO = new MysqlDocumentosDAO();
|
||||||
EgresoDAO egresoDAO = new MysqlEgresoDAO();
|
EgresoDAO egresoDAO = new MysqlEgresoDAO();
|
||||||
IngresoDAO ingresoDAO = new MysqlIngresoDAO();
|
IngresoDAO ingresoDAO = new MysqlIngresoDAO();
|
||||||
|
|
||||||
this.view.getCardPanel().add(arqueoView.getContentPanel(), "ARQUEO");
|
this.view.getCardPanel().add(arqueoView.getContentPanel(), "ARQUEO");
|
||||||
|
|
||||||
this.arqueoController = new ArqueoController(arqueoView, efectivoDAO, ingresoDAO, egresoDAO);
|
this.arqueoController = new ArqueoController(arqueoView, efectivoDAO, documentosDAO, ingresoDAO, egresoDAO);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pressInitialButton() {
|
private void pressInitialButton() {
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 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.models.documentos;
|
||||||
|
|
||||||
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
|
||||||
|
public class Documentos {
|
||||||
|
private int id;
|
||||||
|
private int cheques;
|
||||||
|
private int tarjetas;
|
||||||
|
private Caja caja;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCheques() {
|
||||||
|
return cheques;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCheques(int cheques) {
|
||||||
|
this.cheques = cheques;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTarjetas() {
|
||||||
|
return tarjetas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarjetas(int tarjetas) {
|
||||||
|
this.tarjetas = tarjetas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Caja getCaja() {
|
||||||
|
return caja;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaja(Caja caja) {
|
||||||
|
this.caja = caja;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 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.models.documentos;
|
||||||
|
|
||||||
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface DocumentosDAO {
|
||||||
|
List<Documentos> findAll();
|
||||||
|
Documentos findById(int id);
|
||||||
|
Documentos findByCaja(Caja caja);
|
||||||
|
|
||||||
|
boolean insertDocumentos(Documentos documentos);
|
||||||
|
boolean insertDefaultDocumentos(Documentos documentos);
|
||||||
|
boolean updateDocumentos(Documentos documentos);
|
||||||
|
boolean deleteDocumentos(Documentos documentos);
|
||||||
|
}
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 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.models.documentos;
|
||||||
|
|
||||||
|
import danielcortes.xyz.data.MysqlConnection;
|
||||||
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
|
import danielcortes.xyz.models.caja.MysqlCajaDAO;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MysqlDocumentosDAO implements DocumentosDAO {
|
||||||
|
private MysqlConnection mysqlConnection;
|
||||||
|
|
||||||
|
public MysqlDocumentosDAO() {
|
||||||
|
this.mysqlConnection = new MysqlConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Documentos> findAll() {
|
||||||
|
List<Documentos> documentosList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("select * from documentos");
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
documentosList = this.documentosFromResultSet(rs);
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return documentosList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Documentos findById(int id) {
|
||||||
|
Documentos documentos = null;
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("select * from documentos where id = ?");
|
||||||
|
ps.setInt(1, id);
|
||||||
|
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
List<Documentos> documentosList = this.documentosFromResultSet(rs);
|
||||||
|
if(documentosList.size() > 0){
|
||||||
|
documentos = documentosList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return documentos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Documentos findByCaja(Caja caja) {
|
||||||
|
Documentos documentos = null;
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("select * from documentos where caja_id = ?");
|
||||||
|
ps.setInt(1, caja.getId());
|
||||||
|
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
List<Documentos> documentosList = this.documentosFromResultSet(rs);
|
||||||
|
if(documentosList.size() > 0){
|
||||||
|
documentos = documentosList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return documentos;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertDocumentos(Documentos documentos) {
|
||||||
|
int updates;
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("insert into documentos (cheques, tarjetas, caja_id) values (?,?,?)");
|
||||||
|
ps.setInt(1, documentos.getCheques());
|
||||||
|
ps.setInt(2, documentos.getTarjetas());
|
||||||
|
ps.setInt(3, documentos.getCaja().getId());
|
||||||
|
|
||||||
|
updates = ps.executeUpdate();
|
||||||
|
ps.close();
|
||||||
|
|
||||||
|
ps = conn.prepareStatement("select last_insert_id()");
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
rs.next();
|
||||||
|
documentos.setId(rs.getInt(1));
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return updates > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertDefaultDocumentos(Documentos documentos) {
|
||||||
|
int updates;
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("insert into documentos (cheques, tarjetas, caja_id) values (0,0,?)");
|
||||||
|
ps.setInt(1, documentos.getCaja().getId());
|
||||||
|
|
||||||
|
updates = ps.executeUpdate();
|
||||||
|
ps.close();
|
||||||
|
|
||||||
|
ps = conn.prepareStatement("select last_insert_id()");
|
||||||
|
ResultSet rs = ps.executeQuery();
|
||||||
|
rs.next();
|
||||||
|
documentos.setId(rs.getInt(1));
|
||||||
|
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return updates > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateDocumentos(Documentos documentos) {
|
||||||
|
int updates;
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("update documentos set tarjetas = ?, cheques = ?, caja_id = ? where id = ?");
|
||||||
|
ps.setInt(1, documentos.getTarjetas());
|
||||||
|
ps.setInt(2, documentos.getCheques());
|
||||||
|
ps.setInt(3, documentos.getCaja().getId());
|
||||||
|
ps.setInt(4, documentos.getId());
|
||||||
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return updates > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDocumentos(Documentos documentos) {
|
||||||
|
int updates;
|
||||||
|
try {
|
||||||
|
Connection conn = mysqlConnection.getConnection();
|
||||||
|
PreparedStatement ps = conn.prepareStatement("delete from documentos where id = ?");
|
||||||
|
ps.setInt(1, documentos.getId());
|
||||||
|
|
||||||
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
ps.close();
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return updates > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Documentos> documentosFromResultSet(ResultSet rs) throws SQLException {
|
||||||
|
List<Documentos> documentosList = new ArrayList<>();
|
||||||
|
while (rs.next()) {
|
||||||
|
CajaDAO cajaDAO = new MysqlCajaDAO();
|
||||||
|
Caja caja = cajaDAO.findById(rs.getInt("caja_id"));
|
||||||
|
|
||||||
|
Documentos documentos = new Documentos();
|
||||||
|
documentos.setCaja(caja);
|
||||||
|
documentos.setId(rs.getInt("id"));
|
||||||
|
documentos.setCheques(rs.getInt("cheques"));
|
||||||
|
documentos.setTarjetas(rs.getInt("tarjetas"));
|
||||||
|
|
||||||
|
documentosList.add(documentos);
|
||||||
|
}
|
||||||
|
return documentosList;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<font/>
|
<font/>
|
||||||
</border>
|
</border>
|
||||||
<children>
|
<children>
|
||||||
<grid id="1ca11" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="1ca11" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="10" left="10" bottom="10" right="10"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
@@ -20,14 +20,6 @@
|
|||||||
<font/>
|
<font/>
|
||||||
</border>
|
</border>
|
||||||
<children>
|
<children>
|
||||||
<component id="b855f" class="javax.swing.JLabel">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<text value="Cheques al Dia"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="1b69f" class="javax.swing.JTextField" binding="chequesField">
|
<component id="1b69f" class="javax.swing.JTextField" binding="chequesField">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
@@ -40,7 +32,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="d49a7" class="javax.swing.JLabel">
|
<component id="d49a7" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Tarjetas de Credito"/>
|
<text value="Tarjetas de Credito"/>
|
||||||
@@ -48,7 +40,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="7049f" class="javax.swing.JTextField" binding="tarjetasField">
|
<component id="7049f" class="javax.swing.JTextField" binding="tarjetasField">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||||
<preferred-size width="150" height="-1"/>
|
<preferred-size width="150" height="-1"/>
|
||||||
</grid>
|
</grid>
|
||||||
</constraints>
|
</constraints>
|
||||||
@@ -58,12 +50,40 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="1681b" class="javax.swing.JButton" binding="guardarDocumentosButton">
|
<component id="1681b" class="javax.swing.JButton" binding="guardarDocumentosButton">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Guardar"/>
|
<text value="Guardar"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="a438" class="javax.swing.JLabel" binding="errorCheques">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<foreground color="-65536"/>
|
||||||
|
<text value="Error"/>
|
||||||
|
<visible value="false"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="b855f" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Cheques al Dia"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="4f33f" class="javax.swing.JLabel" binding="errorTarjetas">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<foreground color="-65536"/>
|
||||||
|
<text value="Error"/>
|
||||||
|
<visible value="false"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="84446" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="84446" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public class ArqueoView {
|
|||||||
private JLabel errorCien;
|
private JLabel errorCien;
|
||||||
private JLabel errorCincuenta;
|
private JLabel errorCincuenta;
|
||||||
private JLabel errorDiez;
|
private JLabel errorDiez;
|
||||||
|
private JLabel errorCheques;
|
||||||
|
private JLabel errorTarjetas;
|
||||||
|
|
||||||
public JPanel getContentPanel() {
|
public JPanel getContentPanel() {
|
||||||
return contentPanel;
|
return contentPanel;
|
||||||
@@ -173,6 +175,14 @@ public class ArqueoView {
|
|||||||
return errorDiez;
|
return errorDiez;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JLabel getErrorCheques() {
|
||||||
|
return errorCheques;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JLabel getErrorTarjetas() {
|
||||||
|
return errorTarjetas;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||||
// >>> IMPORTANT!! <<<
|
// >>> IMPORTANT!! <<<
|
||||||
@@ -191,24 +201,34 @@ public class ArqueoView {
|
|||||||
contentPanel = new JPanel();
|
contentPanel = new JPanel();
|
||||||
contentPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
|
contentPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
final JPanel panel1 = new JPanel();
|
final JPanel panel1 = new JPanel();
|
||||||
panel1.setLayout(new GridLayoutManager(3, 2, new Insets(10, 10, 10, 10), -1, -1));
|
panel1.setLayout(new GridLayoutManager(5, 2, new Insets(10, 10, 10, 10), -1, -1));
|
||||||
contentPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
contentPanel.add(panel1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||||
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Detalle Documentos", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel1.getFont())));
|
panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Detalle Documentos", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel1.getFont())));
|
||||||
final JLabel label1 = new JLabel();
|
|
||||||
label1.setText("Cheques al Dia");
|
|
||||||
panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
|
||||||
chequesField = new JTextField();
|
chequesField = new JTextField();
|
||||||
chequesField.setText("0");
|
chequesField.setText("0");
|
||||||
panel1.add(chequesField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
panel1.add(chequesField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||||
final JLabel label2 = new JLabel();
|
final JLabel label1 = new JLabel();
|
||||||
label2.setText("Tarjetas de Credito");
|
label1.setText("Tarjetas de Credito");
|
||||||
panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel1.add(label1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
tarjetasField = new JTextField();
|
tarjetasField = new JTextField();
|
||||||
tarjetasField.setText("0");
|
tarjetasField.setText("0");
|
||||||
panel1.add(tarjetasField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
panel1.add(tarjetasField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
|
||||||
guardarDocumentosButton = new JButton();
|
guardarDocumentosButton = new JButton();
|
||||||
guardarDocumentosButton.setText("Guardar");
|
guardarDocumentosButton.setText("Guardar");
|
||||||
panel1.add(guardarDocumentosButton, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel1.add(guardarDocumentosButton, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
errorCheques = new JLabel();
|
||||||
|
errorCheques.setForeground(new Color(-65536));
|
||||||
|
errorCheques.setText("Error");
|
||||||
|
errorCheques.setVisible(true);
|
||||||
|
panel1.add(errorCheques, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
final JLabel label2 = new JLabel();
|
||||||
|
label2.setText("Cheques al Dia");
|
||||||
|
panel1.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
errorTarjetas = new JLabel();
|
||||||
|
errorTarjetas.setForeground(new Color(-65536));
|
||||||
|
errorTarjetas.setText("Error");
|
||||||
|
errorTarjetas.setVisible(true);
|
||||||
|
panel1.add(errorTarjetas, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
final JPanel panel2 = new JPanel();
|
final JPanel panel2 = new JPanel();
|
||||||
panel2.setLayout(new GridLayoutManager(5, 2, new Insets(10, 10, 10, 10), -1, -1));
|
panel2.setLayout(new GridLayoutManager(5, 2, new Insets(10, 10, 10, 10), -1, -1));
|
||||||
contentPanel.add(panel2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
contentPanel.add(panel2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||||
|
|||||||
Reference in New Issue
Block a user