From 87fb2f8abbd6354becce6096fb761df265405362 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Date: Fri, 28 Dec 2018 04:32:35 -0300 Subject: [PATCH] Tecnicamente esta terminada la funcionalidad basica --- database/create.sql | 2 + .../xyz/controllers/ArqueoController.java | 8 +- .../xyz/controllers/IngresosController.java | 65 +++++++++++-- .../xyz/models/efectivo/MysqlEfectivoDAO.java | 1 - .../xyz/models/ingreso/Ingreso.java | 47 +++++----- .../xyz/models/ingreso/MysqlIngresoDAO.java | 20 ++-- .../danielcortes/xyz/views/ArqueoView.form | 34 +++++-- .../danielcortes/xyz/views/ArqueoView.java | 25 +++-- .../danielcortes/xyz/views/IngresosView.form | 92 +++++++++++++++---- .../danielcortes/xyz/views/IngresosView.java | 82 ++++++++++++----- .../views/components/IngresosTableModel.java | 28 +++--- 11 files changed, 299 insertions(+), 105 deletions(-) diff --git a/database/create.sql b/database/create.sql index 93e530a..8363e76 100644 --- a/database/create.sql +++ b/database/create.sql @@ -64,6 +64,8 @@ create table ingresos ( id int(10) unsigned primary key auto_increment, valor int(10) not null, + nro_inicial varchar(191) not null, + nro_final varchar(191) not null, tipo_ingreso_id int(10) unsigned not null, caja_id int(10) unsigned not null, foreign key fk_tipo_ingreso (tipo_ingreso_id) references tipos_ingreso (id) on update cascade on delete restrict, diff --git a/src/main/java/danielcortes/xyz/controllers/ArqueoController.java b/src/main/java/danielcortes/xyz/controllers/ArqueoController.java index e6db12d..021ddbe 100644 --- a/src/main/java/danielcortes/xyz/controllers/ArqueoController.java +++ b/src/main/java/danielcortes/xyz/controllers/ArqueoController.java @@ -34,6 +34,7 @@ import danielcortes.xyz.models.ingreso.IngresoDAO; import danielcortes.xyz.views.ArqueoView; import javax.swing.*; +import java.awt.*; public class ArqueoController { @@ -71,7 +72,7 @@ public class ArqueoController { private void fillEfectivo() { this.efectivo = this.efectivoDAO.findByCaja(this.caja); this.view.getVeinteMilField().setText(String.valueOf(efectivo.getVeinteMil())); - this.view.getDiezField().setText(String.valueOf(efectivo.getDiezMil())); + this.view.getDiezMilField().setText(String.valueOf(efectivo.getDiezMil())); this.view.getCincoMilField().setText(String.valueOf(efectivo.getCincoMil())); this.view.getDosMilField().setText(String.valueOf(efectivo.getDosMil())); this.view.getMilField().setText(String.valueOf(efectivo.getMil())); @@ -142,6 +143,11 @@ public class ArqueoController { this.view.getArqueoField().setText(String.valueOf(arqueo)); this.view.getAjusteField().setText(String.valueOf(ajuste)); + if(ajuste < 0) { + this.view.getAjusteField().setForeground(new Color(255,0,0)); + }else{ + this.view.getAjusteField().setForeground(new Color(0,0,0)); + } } diff --git a/src/main/java/danielcortes/xyz/controllers/IngresosController.java b/src/main/java/danielcortes/xyz/controllers/IngresosController.java index 6afd639..181aa44 100644 --- a/src/main/java/danielcortes/xyz/controllers/IngresosController.java +++ b/src/main/java/danielcortes/xyz/controllers/IngresosController.java @@ -90,6 +90,8 @@ public class IngresosController { this.view.getIngresosTable().getSelectionModel().addListSelectionListener(e -> onSelectTableRowListener()); this.view.getGuardarButton().addActionListener(e -> guardarActionListener()); this.view.getValorField().addActionListener(e -> guardarActionListener()); + this.view.getNroInicialField().addActionListener(e -> guardarActionListener()); + this.view.getNroFinalField().addActionListener(e -> guardarActionListener()); this.view.getEliminarButton().addActionListener(e -> eliminarActionListener()); this.view.getEditarButton().addActionListener(e -> editarActionListener()); @@ -115,12 +117,17 @@ public class IngresosController { private void guardarActionListener() { this.normalizeInputs(); String valor = this.view.getValorField().getText(); + String nroInicial = this.view.getNroInicialField().getText(); + String nroFinal = this.view.getNroFinalField().getText(); TipoIngreso tipoIngreso = (TipoIngreso) this.view.getTipoCombo().getSelectedItem(); + System.out.println(nroInicial); + System.out.println(nroFinal); + if(editing) { - this.editarIngreso(valor, tipoIngreso, this.caja); + this.editarIngreso(valor, nroInicial, nroFinal, tipoIngreso, this.caja); } else { - this.guardarIngreso(valor, tipoIngreso, this.caja); + this.guardarIngreso(valor, nroInicial, nroFinal, tipoIngreso, this.caja); } this.resetFocus(); } @@ -147,6 +154,8 @@ public class IngresosController { this.view.getTipoCombo().setSelectedItem(ingreso.getTipoIngreso()); this.view.getValorField().setText(String.valueOf(ingreso.getValor())); + this.view.getNroInicialField().setText(String.valueOf(ingreso.getNroInicial())); + this.view.getNroFinalField().setText(String.valueOf(ingreso.getNroFinal())); } } @@ -170,12 +179,14 @@ public class IngresosController { } } - private void guardarIngreso(String valor, TipoIngreso tipoIngreso, Caja caja){ - if(this.validateInput(valor, tipoIngreso, caja)){ + private void guardarIngreso(String valor, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja){ + if(this.validateInput(valor, nroInicial, nroFinal, tipoIngreso, caja)){ Ingreso ingreso = new Ingreso(); ingreso.setTipoIngreso(tipoIngreso); ingreso.setCaja(caja); ingreso.setValor(Integer.valueOf(valor)); + ingreso.setNroInicial(nroInicial); + ingreso.setNroFinal(nroFinal); this.ingresoDAO.insertIngreso(ingreso); this.view.getIngresosTableModel().addRow(ingreso); @@ -185,10 +196,12 @@ public class IngresosController { } } - private void editarIngreso(String valor, TipoIngreso tipoIngreso, Caja caja){ - if(this.validateInput(valor, tipoIngreso, caja)){ + private void editarIngreso(String valor, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja){ + if(this.validateInput(valor, nroInicial, nroFinal, tipoIngreso, caja)){ this.editingIngreso.setTipoIngreso(tipoIngreso); this.editingIngreso.setValor(Integer.valueOf(valor)); + this.editingIngreso.setNroInicial(nroInicial); + this.editingIngreso.setNroFinal(nroFinal); this.ingresoDAO.updateIngreso(this.editingIngreso); this.view.getIngresosTableModel().setIngreso(this.editingId, this.editingIngreso); this.updateTotalIngresos(); @@ -197,10 +210,12 @@ public class IngresosController { } } - private boolean validateInput(String valor, TipoIngreso tipoIngreso, Caja caja) { + private boolean validateInput(String valor, String nroInicial, String nroFinal, TipoIngreso tipoIngreso, Caja caja) { this.hideErrorMessages(); boolean valorValidation = this.validateValor(valor); + boolean nroInicialValidation = this.validateNroInicial(nroInicial); + boolean nroFinalValidation = this.validateNroFinal(nroFinal); boolean tipoIngresoValidation = this.validateTipoIngreso(tipoIngreso); boolean cajaValidation = this.validateCaja(caja); @@ -241,6 +256,36 @@ public class IngresosController { } + private boolean validateNroInicial(String nroInicial){ + if (nroInicial == null) { + this.view.getErrorNroInicial().setText("Hubo un problema con los datos"); + this.view.getErrorNroInicial().setVisible(true); + return false; + } + + if (nroInicial.isEmpty()) { + this.view.getErrorNroInicial().setText("El campo esta vacio"); + this.view.getErrorNroInicial().setVisible(true); + return false; + } + return true; + } + + private boolean validateNroFinal(String nroFinal){ + if (nroFinal == null) { + this.view.getErrorNroFinal().setText("Hubo un problema con los datos"); + this.view.getErrorNroFinal().setVisible(true); + return false; + } + + if (nroFinal.isEmpty()) { + this.view.getErrorNroFinal().setText("El campo esta vacio"); + this.view.getErrorNroFinal().setVisible(true); + return false; + } + return true; + } + private boolean validateTipoIngreso(TipoIngreso tipoIngreso) { if (tipoIngreso == null) { this.view.getErrorTipoIngreso().setText("Hubo un problema con los datos"); @@ -253,15 +298,21 @@ public class IngresosController { private void hideErrorMessages() { this.view.getErrorTipoIngreso().setVisible(false); this.view.getErrorValor().setVisible(false); + this.view.getErrorNroInicial().setVisible(false); + this.view.getErrorNroFinal().setVisible(false); } private void clearInputs() { this.view.getTipoCombo().setSelectedIndex(0); this.view.getValorField().setText(""); + this.view.getNroInicialField().setText(""); + this.view.getNroFinalField().setText(""); } private void normalizeInputs(){ this.view.getValorField().setText(this.view.getValorField().getText().trim()); + this.view.getNroInicialField().setText(this.view.getNroInicialField().getText().trim()); + this.view.getNroFinalField().setText(this.view.getNroFinalField().getText().trim()); } private void resetFocus(){ diff --git a/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java b/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java index 78e2b3c..e85f390 100644 --- a/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java +++ b/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java @@ -152,7 +152,6 @@ public class MysqlEfectivoDAO implements EfectivoDAO { ps.setInt(1, efectivo.getCaja().getId()); updates = ps.executeUpdate(); - System.out.println(updates); ps.close(); ps = conn.prepareStatement("select last_insert_id()"); diff --git a/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java b/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java index 34b95bd..1df8f89 100644 --- a/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java +++ b/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java @@ -30,22 +30,11 @@ import danielcortes.xyz.models.tipo_ingreso.TipoIngreso; public class Ingreso { private int id; private int valor; + private String nroInicial; + private String nroFinal; private TipoIngreso tipoIngreso; private Caja caja; - public Ingreso(int id, int valor, TipoIngreso tipoIngreso ) { - this.id = id; - this.valor = valor; - this.tipoIngreso = tipoIngreso; - } - - public Ingreso( int valor, TipoIngreso tipoIngreso) { - this.valor = valor; - this.tipoIngreso = tipoIngreso; - } - - public Ingreso(){} - public int getId() { return id; } @@ -54,14 +43,6 @@ public class Ingreso { this.id = id; } - public TipoIngreso getTipoIngreso() { - return tipoIngreso; - } - - public void setTipoIngreso(TipoIngreso tipoIngreso) { - this.tipoIngreso = tipoIngreso; - } - public int getValor() { return valor; } @@ -70,6 +51,30 @@ public class Ingreso { this.valor = valor; } + public String getNroInicial() { + return nroInicial; + } + + public void setNroInicial(String nroInicial) { + this.nroInicial = nroInicial; + } + + public String getNroFinal() { + return nroFinal; + } + + public void setNroFinal(String nroFinal) { + this.nroFinal = nroFinal; + } + + public TipoIngreso getTipoIngreso() { + return tipoIngreso; + } + + public void setTipoIngreso(TipoIngreso tipoIngreso) { + this.tipoIngreso = tipoIngreso; + } + public Caja getCaja() { return caja; } diff --git a/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java b/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java index 55896ce..bdb40e3 100644 --- a/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java +++ b/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java @@ -130,10 +130,12 @@ public class MysqlIngresoDAO implements IngresoDAO{ int updates; try { Connection conn = mysqlConnection.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into ingresos (valor, tipo_ingreso_id, caja_id) values (?,?,?)"); + PreparedStatement ps = conn.prepareStatement("insert into ingresos (valor, nro_inicial, nro_final, tipo_ingreso_id, caja_id) values (?,?,?,?,?)"); ps.setInt(1, ingreso.getValor()); - ps.setInt(2, ingreso.getTipoIngreso().getId()); - ps.setInt(3, ingreso.getCaja().getId()); + ps.setString(2, ingreso.getNroInicial()); + ps.setString(3, ingreso.getNroFinal()); + ps.setInt(4, ingreso.getTipoIngreso().getId()); + ps.setInt(5, ingreso.getCaja().getId()); updates = ps.executeUpdate(); ps.close(); @@ -157,11 +159,13 @@ public class MysqlIngresoDAO implements IngresoDAO{ int updates; try { Connection conn = mysqlConnection.getConnection(); - PreparedStatement ps = conn.prepareStatement("update ingresos set valor = ? , tipo_ingreso_id = ?, caja_id = ? where id = ?"); + PreparedStatement ps = conn.prepareStatement("update ingresos set valor = ? , nro_inicial = ?, nro_final = ?, tipo_ingreso_id = ?, caja_id = ? where id = ?"); ps.setInt(1,ingreso.getValor()); - ps.setInt(2, ingreso.getTipoIngreso().getId()); - ps.setInt(3, ingreso.getCaja().getId()); - ps.setInt(4, ingreso.getId()); + ps.setString(2, ingreso.getNroInicial()); + ps.setString(3, ingreso.getNroFinal()); + ps.setInt(4, ingreso.getTipoIngreso().getId()); + ps.setInt(5, ingreso.getCaja().getId()); + ps.setInt(6, ingreso.getId()); updates = ps.executeUpdate(); @@ -227,6 +231,8 @@ public class MysqlIngresoDAO implements IngresoDAO{ ingreso.setId(rs.getInt("id")); ingreso.setValor(rs.getInt("valor")); + ingreso.setNroInicial(rs.getString("nro_inicial")); + ingreso.setNroFinal(rs.getString("nro_final")); ingreso.setTipoIngreso(tipoIngreso); ingreso.setCaja(caja); diff --git a/src/main/java/danielcortes/xyz/views/ArqueoView.form b/src/main/java/danielcortes/xyz/views/ArqueoView.form index a8fc555..7d79918 100644 --- a/src/main/java/danielcortes/xyz/views/ArqueoView.form +++ b/src/main/java/danielcortes/xyz/views/ArqueoView.form @@ -1,9 +1,9 @@
- + - + @@ -86,7 +86,7 @@ - + @@ -172,7 +172,7 @@ - + @@ -180,40 +180,48 @@ - + + - + + - + + + + + + + - + @@ -484,6 +492,16 @@ + + + + + + + + + + diff --git a/src/main/java/danielcortes/xyz/views/ArqueoView.java b/src/main/java/danielcortes/xyz/views/ArqueoView.java index d955c42..7cbbcc1 100644 --- a/src/main/java/danielcortes/xyz/views/ArqueoView.java +++ b/src/main/java/danielcortes/xyz/views/ArqueoView.java @@ -26,6 +26,7 @@ package danielcortes.xyz.views; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; import javax.swing.*; import javax.swing.border.TitledBorder; @@ -204,7 +205,7 @@ public class ArqueoView { */ private void $$$setupUI$$$() { contentPanel = new JPanel(); - contentPanel.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPanel.setLayout(new GridLayoutManager(4, 2, new Insets(0, 0, 0, 0), -1, -1)); final JPanel panel1 = new JPanel(); 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)); @@ -235,7 +236,7 @@ public class ArqueoView { errorTarjetas.setVisible(false); 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(); - panel2.setLayout(new GridLayoutManager(6, 2, new Insets(10, 10, 10, 10), -1, -1)); + panel2.setLayout(new GridLayoutManager(7, 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)); panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Resumen")); final JLabel label3 = new JLabel(); @@ -268,21 +269,27 @@ public class ArqueoView { panel2.add(ingresosField, 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)); final JLabel label7 = new JLabel(); label7.setText("Arqueo"); - panel2.add(label7, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(label7, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); arqueoField = new JTextField(); arqueoField.setEditable(false); + Font arqueoFieldFont = this.$$$getFont$$$(null, Font.BOLD, -1, arqueoField.getFont()); + if (arqueoFieldFont != null) arqueoField.setFont(arqueoFieldFont); arqueoField.setText("0"); - panel2.add(arqueoField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + panel2.add(arqueoField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); ajusteField = new JTextField(); ajusteField.setEditable(false); + Font ajusteFieldFont = this.$$$getFont$$$(null, Font.BOLD, -1, ajusteField.getFont()); + if (ajusteFieldFont != null) ajusteField.setFont(ajusteFieldFont); ajusteField.setText("0"); - panel2.add(ajusteField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + panel2.add(ajusteField, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); final JLabel label8 = new JLabel(); label8.setText("Ajuste "); - panel2.add(label8, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(label8, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JSeparator separator1 = new JSeparator(); + panel2.add(separator1, new GridConstraints(4, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); panel3.setLayout(new GridLayoutManager(19, 2, new Insets(10, 10, 10, 10), -1, -1)); - contentPanel.add(panel3, new GridConstraints(0, 0, 2, 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(panel3, new GridConstraints(0, 0, 3, 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)); panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Detalle Efectivo", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel3.getFont()))); final JLabel label9 = new JLabel(); label9.setText("$20000"); @@ -386,6 +393,10 @@ public class ArqueoView { errorDiez.setText("Error"); errorDiez.setVisible(false); panel3.add(errorDiez, new GridConstraints(17, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + contentPanel.add(spacer1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer2 = new Spacer(); + contentPanel.add(spacer2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); } /** diff --git a/src/main/java/danielcortes/xyz/views/IngresosView.form b/src/main/java/danielcortes/xyz/views/IngresosView.form index ec4b06e..70cea4f 100644 --- a/src/main/java/danielcortes/xyz/views/IngresosView.form +++ b/src/main/java/danielcortes/xyz/views/IngresosView.form @@ -29,7 +29,7 @@ - + @@ -39,31 +39,15 @@ - + - - - - - - - - - - - - - - - - - + @@ -71,9 +55,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -82,6 +114,16 @@ + + + + + + + + + + @@ -91,6 +133,16 @@ + + + + + + + + + + diff --git a/src/main/java/danielcortes/xyz/views/IngresosView.java b/src/main/java/danielcortes/xyz/views/IngresosView.java index c478082..806d069 100644 --- a/src/main/java/danielcortes/xyz/views/IngresosView.java +++ b/src/main/java/danielcortes/xyz/views/IngresosView.java @@ -44,6 +44,10 @@ public class IngresosView { private JLabel errorTipoIngreso; private JLabel errorValor; private JButton editarButton; + private JTextField nroInicialField; + private JTextField nroFinalField; + private JLabel errorNroInicial; + private JLabel errorNroFinal; private IngresosTableModel ingresosTableModel; @@ -74,10 +78,6 @@ public class IngresosView { return eliminarButton; } - public JButton getEditarButton() { - return editarButton; - } - public JTextField getTotalIngresoField() { return totalIngresoField; } @@ -90,10 +90,6 @@ public class IngresosView { return tipoCombo; } - public IngresosTableModel getIngresosTableModel() { - return ingresosTableModel; - } - public JLabel getErrorTipoIngreso() { return errorTipoIngreso; } @@ -102,6 +98,30 @@ public class IngresosView { return errorValor; } + public JButton getEditarButton() { + return editarButton; + } + + public JTextField getNroInicialField() { + return nroInicialField; + } + + public JTextField getNroFinalField() { + return nroFinalField; + } + + public JLabel getErrorNroInicial() { + return errorNroInicial; + } + + public JLabel getErrorNroFinal() { + return errorNroFinal; + } + + public IngresosTableModel getIngresosTableModel() { + return ingresosTableModel; + } + { // GUI initializer generated by IntelliJ IDEA GUI Designer // >>> IMPORTANT!! <<< @@ -128,39 +148,59 @@ public class IngresosView { panel1.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); scrollPane1.setViewportView(ingresosTable); final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.setLayout(new GridLayoutManager(3, 4, new Insets(0, 0, 0, 0), -1, -1)); panel1.add(panel2, new GridConstraints(0, 0, 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)); final JLabel label1 = new JLabel(); label1.setText("Tipo"); - panel2.add(label1, new GridConstraints(0, 0, 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("Valor"); - panel2.add(label2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - valorField = new JTextField(); - panel2.add(valorField, 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)); + panel2.add(label1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); tipoCombo = new JComboBox(); final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel(); tipoCombo.setModel(defaultComboBoxModel1); - panel2.add(tipoCombo, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + panel2.add(tipoCombo, new GridConstraints(1, 3, 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(); + label2.setText("Valor"); + panel2.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + valorField = new JTextField(); + panel2.add(valorField, new GridConstraints(1, 0, 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 label3 = new JLabel(); + label3.setText("N° Inicial"); + panel2.add(label3, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("N° Final"); + panel2.add(label4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + nroInicialField = new JTextField(); + panel2.add(nroInicialField, 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)); + nroFinalField = new JTextField(); + panel2.add(nroFinalField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); errorTipoIngreso = new JLabel(); errorTipoIngreso.setForeground(new Color(-65536)); errorTipoIngreso.setText("Label"); errorTipoIngreso.setVisible(false); - panel2.add(errorTipoIngreso, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(errorTipoIngreso, new GridConstraints(2, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); errorValor = new JLabel(); errorValor.setForeground(new Color(-65536)); errorValor.setText("Label"); errorValor.setVisible(false); - panel2.add(errorValor, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + panel2.add(errorValor, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + errorNroInicial = new JLabel(); + errorNroInicial.setForeground(new Color(-65536)); + errorNroInicial.setText("Label"); + errorNroInicial.setVisible(false); + panel2.add(errorNroInicial, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + errorNroFinal = new JLabel(); + errorNroFinal.setForeground(new Color(-65536)); + errorNroFinal.setText("Label"); + errorNroFinal.setVisible(false); + panel2.add(errorNroFinal, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); panel3.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); panel1.add(panel3, new GridConstraints(2, 0, 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)); final JPanel panel4 = new JPanel(); panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); panel3.add(panel4, new GridConstraints(0, 2, 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)); - final JLabel label3 = new JLabel(); - label3.setText("Total Ingresos"); - panel4.add(label3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("Total Ingresos"); + panel4.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); totalIngresoField = new JTextField(); totalIngresoField.setEditable(false); panel4.add(totalIngresoField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); diff --git a/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java b/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java index a1263af..e7d4aaa 100644 --- a/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java +++ b/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java @@ -33,9 +33,9 @@ public class IngresosTableModel extends AbstractTableModel { private String[] columns; private ArrayList rows; - public IngresosTableModel(){ + public IngresosTableModel() { super(); - this.columns = new String[]{"Tipo", "Valor"}; + this.columns = new String[]{"Valor", "N° Inicial", "N° Final", "Tipo"}; this.rows = new ArrayList<>(); } @@ -53,38 +53,42 @@ public class IngresosTableModel extends AbstractTableModel { public void addRow(Ingreso ingreso) { this.rows.add(ingreso); - this.fireTableRowsInserted(getRowCount()-1, getRowCount()-1); + this.fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1); } - public void removeRow(int row){ + public void removeRow(int row) { this.rows.remove(row); - this.fireTableRowsDeleted(row,row); + this.fireTableRowsDeleted(row, row); } - public void removeRows(){ + public void removeRows() { int rowCount = getRowCount(); - if(rowCount > 0){ + if (rowCount > 0) { this.rows.clear(); - this.fireTableRowsDeleted(0, rowCount-1); + this.fireTableRowsDeleted(0, rowCount - 1); } } public Object getValueAt(int row, int col) { switch (col) { case 0: - return this.rows.get(row).getTipoIngreso().getNombre(); - case 1: return this.rows.get(row).getValor(); + case 1: + return this.rows.get(row).getNroInicial(); + case 2: + return this.rows.get(row).getNroFinal(); + case 3: + return this.rows.get(row).getTipoIngreso().getNombre(); } return null; } - public Ingreso getIngreso(int row){ + public Ingreso getIngreso(int row) { return this.rows.get(row); } public void setIngreso(int editingId, Ingreso ingreso) { this.rows.set(editingId, ingreso); - this.fireTableRowsUpdated(getRowCount()-2, getRowCount()-1); + this.fireTableRowsUpdated(getRowCount() - 2, getRowCount() - 1); } }