From 29d7f910d791046488272a56b8aba855f17cdd54 Mon Sep 17 00:00:00 2001 From: Daniel Cortes Date: Sat, 29 Dec 2018 01:09:56 -0300 Subject: [PATCH] Eliminando cosas, se esta eliminando el soporte de maven y se replazo por el sistema de intellij --- LICENSE | 21 - caja.iml | 29 - conf.properties | 25 - database.sqlite | Bin 32768 -> 0 bytes database/mysql.sql | 119 ---- database/sqlite.sql | 120 ---- pom.xml | 47 -- src/main/java/danielcortes/xyz/Main.java | 108 ---- .../xyz/controllers/ArqueoController.java | 324 ----------- .../xyz/controllers/EgresosController.java | 319 ----------- .../xyz/controllers/IngresosController.java | 321 ----------- .../xyz/controllers/ManagerController.java | 163 ------ .../xyz/data/ConnectionHolder.java | 31 -- .../xyz/data/MysqlConnectionHolder.java | 38 -- .../danielcortes/xyz/data/Properties.java | 52 -- .../xyz/data/SQLiteConnectionHolder.java | 45 -- .../danielcortes/xyz/models/caja/Caja.java | 48 -- .../danielcortes/xyz/models/caja/CajaDAO.java | 55 -- .../xyz/models/caja/MysqlCajaDAO.java | 152 ----- .../xyz/models/caja/SQLiteCajaDAO.java | 155 ------ .../xyz/models/documentos/Documentos.java | 66 --- .../xyz/models/documentos/DocumentosDAO.java | 66 --- .../models/documentos/MysqlDocumentosDAO.java | 206 ------- .../documentos/SQLiteDocumentosDAO.java | 205 ------- .../xyz/models/efectivo/Efectivo.java | 129 ----- .../xyz/models/efectivo/EfectivoDAO.java | 73 --- .../xyz/models/efectivo/MysqlEfectivoDAO.java | 218 -------- .../models/efectivo/SQLiteEfectivoDAO.java | 218 -------- .../xyz/models/egreso/Egreso.java | 86 --- .../xyz/models/egreso/EgresoDAO.java | 80 --- .../xyz/models/egreso/MysqlEgresoDAO.java | 241 -------- .../xyz/models/egreso/SQLiteEgresoDAO.java | 239 -------- .../xyz/models/ingreso/Ingreso.java | 85 --- .../xyz/models/ingreso/IngresoDAO.java | 79 --- .../xyz/models/ingreso/MysqlIngresoDAO.java | 218 -------- .../xyz/models/ingreso/SQLiteIngresoDAO.java | 217 -------- .../tipo_egreso/MysqlTipoEgresoDAO.java | 115 ---- .../tipo_egreso/SQLiteTipoEgresoDAO.java | 116 ---- .../xyz/models/tipo_egreso/TipoEgreso.java | 86 --- .../xyz/models/tipo_egreso/TipoEgresoDAO.java | 79 --- .../tipo_ingreso/MysqlTipoIngresoDAO.java | 114 ---- .../tipo_ingreso/SQLiteTipoIngresoDAO.java | 116 ---- .../xyz/models/tipo_ingreso/TipoIngreso.java | 87 --- .../models/tipo_ingreso/TipoIngresoDAO.java | 54 -- .../danielcortes/xyz/views/ArqueoView.form | 526 ------------------ .../danielcortes/xyz/views/ArqueoView.java | 441 --------------- .../danielcortes/xyz/views/EgresosView.form | 244 -------- .../danielcortes/xyz/views/EgresosView.java | 238 -------- .../danielcortes/xyz/views/IngresosView.form | 239 -------- .../danielcortes/xyz/views/IngresosView.java | 232 -------- .../danielcortes/xyz/views/ManagerView.form | 78 --- .../danielcortes/xyz/views/ManagerView.java | 118 ---- .../views/components/EgresosTableModel.java | 96 ---- .../views/components/IngresosTableModel.java | 94 ---- src/main/resources/META-INF/MANIFEST.MF | 3 - 55 files changed, 7674 deletions(-) delete mode 100644 LICENSE delete mode 100644 caja.iml delete mode 100644 conf.properties delete mode 100644 database.sqlite delete mode 100644 database/mysql.sql delete mode 100644 database/sqlite.sql delete mode 100644 pom.xml delete mode 100644 src/main/java/danielcortes/xyz/Main.java delete mode 100644 src/main/java/danielcortes/xyz/controllers/ArqueoController.java delete mode 100644 src/main/java/danielcortes/xyz/controllers/EgresosController.java delete mode 100644 src/main/java/danielcortes/xyz/controllers/IngresosController.java delete mode 100644 src/main/java/danielcortes/xyz/controllers/ManagerController.java delete mode 100644 src/main/java/danielcortes/xyz/data/ConnectionHolder.java delete mode 100644 src/main/java/danielcortes/xyz/data/MysqlConnectionHolder.java delete mode 100644 src/main/java/danielcortes/xyz/data/Properties.java delete mode 100644 src/main/java/danielcortes/xyz/data/SQLiteConnectionHolder.java delete mode 100644 src/main/java/danielcortes/xyz/models/caja/Caja.java delete mode 100644 src/main/java/danielcortes/xyz/models/caja/CajaDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/caja/MysqlCajaDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/caja/SQLiteCajaDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/documentos/Documentos.java delete mode 100644 src/main/java/danielcortes/xyz/models/documentos/DocumentosDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/efectivo/Efectivo.java delete mode 100644 src/main/java/danielcortes/xyz/models/efectivo/EfectivoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/egreso/Egreso.java delete mode 100644 src/main/java/danielcortes/xyz/models/egreso/EgresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java delete mode 100644 src/main/java/danielcortes/xyz/models/ingreso/IngresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java delete mode 100644 src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java delete mode 100644 src/main/java/danielcortes/xyz/views/ArqueoView.form delete mode 100644 src/main/java/danielcortes/xyz/views/ArqueoView.java delete mode 100644 src/main/java/danielcortes/xyz/views/EgresosView.form delete mode 100644 src/main/java/danielcortes/xyz/views/EgresosView.java delete mode 100644 src/main/java/danielcortes/xyz/views/IngresosView.form delete mode 100644 src/main/java/danielcortes/xyz/views/IngresosView.java delete mode 100644 src/main/java/danielcortes/xyz/views/ManagerView.form delete mode 100644 src/main/java/danielcortes/xyz/views/ManagerView.java delete mode 100644 src/main/java/danielcortes/xyz/views/components/EgresosTableModel.java delete mode 100644 src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java delete mode 100644 src/main/resources/META-INF/MANIFEST.MF diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7e34b18..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Daniel Cortés - -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. diff --git a/caja.iml b/caja.iml deleted file mode 100644 index 1343501..0000000 --- a/caja.iml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/conf.properties b/conf.properties deleted file mode 100644 index 964acc3..0000000 --- a/conf.properties +++ /dev/null @@ -1,25 +0,0 @@ -# configuracion del sistema de Caja - -# configuracion de la base de datos: - -# database_type sirve para elegir el sistema de base de datos que utilizara el sistema. -# los valores soportados son: -# - mysql -# - sqlite - -#database_type = mysql -database_type = sqlite - -# database_uri es la uri de la base de datos con la que se conectara el sistema. -# debe corresponder con el sistema de base de datos seleccionado en database_type - -#database_uri = jdbc:mysql://localhost/caja?user=root&password=lagging&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC -database_uri = jdbc:sqlite:database.sqlite - - -# look_and_feel elige el look and feel que intentara utilizar la aplicacion, si el seleccionado no funciona en el sistema operativo se hara fallback a metal. - -look_and_feel = javax.swing.plaf.metal.MetalLookAndFeel -#look_and_feel = com.sun.java.swing.plaf.motif.MotifLookAndFeel -#look_and_feel = com.sun.java.swing.plaf.gtk.GTKLookAndFeel -#look_and_feel = com.sun.java.swing.plaf.windows.WindowsLookAndFeel diff --git a/database.sqlite b/database.sqlite deleted file mode 100644 index 7139e2e3f2039fdf5c68afe845ed62f4325ddd5a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI4O>7%Q6o7YkY_ILqOlWGEDz&;1ijqi8$vU)Y1Ql$9n?{Q3;J8&eplG{0O}99^ z>F&DFUQnq-IdHDH(gPPx9FRBxLR@+&5=a~n>H(yx2yuV|5(gyS?2of+oG6D%{m~o6 znwj_B%$xb%tnE=|y!!gGWfxj?tzB2z+KJ`5vL!E078S)Zl`vVh&(@i%Y`WHl?p{^iVpk7=-nhsv zcbNx0_9SxzY~yTDv#8{m)2 zlu65+QXE_9ZkjrL*)ep_&`riAChIVexXkli%kYa+H;kNIIe1XKSq?ZrM}}`*alBq3 zpQ6wcry*<&whzM<#%Hm%VRZ&h$F$hBK)KaHl9OTCh7;-s!7v>!YCN!W?zAsR$<8l# zE!zr0KCra`x*b~cp>?6PK6vDOVmq~tV?4O^!;i9`l`GY%c=M$o%9gzjE5PyMTu#L} zmiC7@m`@ys{y6I$$Bib;v)HUBN|Lu-XARgJmL3MkXYcquLtf}NzF^srDLgwn8T-~I z?>d+re}>{=bZrlw8fK;Tuc1;#invQVt_w z(p9`1wsYw^u?5fLH4%H~FiqweuC-}c@UFLw$(8h?jeRA1;Vjm|@g>(&(xh)04eBKo z*mRcz)=uc|5igy$CAl&_E?!p?OD7yyxIDr#NyRa#Nd_}Uva5CTrYKj+W$}77aLnQI zmy~kEB?$-H^ba3p7j-501dQWVoZ@@)9Q{O~f6`y*5A<95IaDwq0VIF~kN^@u0!RP} zAOR$R1dsp{Kmw0|Kq*IrvD%D!Y+6;PYqe4~SyfA!UbQwobF4&?Rkb7~s|5HrT#A5nj-2A5Q9Qf{?kM z1Ltt|$w{f^x^Pg+bjq+}R~NgMt~B7tnG5*}KM*$xJNM&@y5~FK#%3-Y<5_?M87CY# zhNf3xAFrjAtCp>_n765SOy>aX>t6}g4Q9jfqIA!&%|CupH~g-vD}fcCN#KHc&%vgD zE>@MGL4*kjAOR$R1dsp{Kmter2_OL^fCP}h(@vmT zkcIM;B#LLX<@(Cf>GqkHrYzUnEp3%ND3Wp>)cYg#sd{^9;nc_nGAYad6Hg4wWPc9C zW0Cc8bD`O2E-W=qXMfI+ayHRoMO$ubt3zK9Qq6$4=f2r$wwtTU*?Q}>dY~R9vQRxJ z6~x*RRaNKb<{H`?&DPRtTRU)$lqFf%UjgN;TAQC!7tSnd?Y#~ui;?(H6?tCZ`~M96N}#{P&i@V+Fd+dXfCP{L z5WeD;5mJJC0EE(lNFLl*)#&{HZGrwpf2H5iujyy>_HKGc8zg`PkN^@u z0!RP}AOR$R1dsp{KmthMVG=0i_P{~?D2cgJHd)P - - 4.0.0 - - danielcortes.xyz - caja - 0.1 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - 8 - 8 - 8 - - - - - - - com.google.code.gson - gson - 2.8.5 - - - mysql - mysql-connector-java - 8.0.13 - - - org.xerial - sqlite-jdbc - 3.25.2 - - - com.github.lgooddatepicker - LGoodDatePicker - 10.3.1 - - - - diff --git a/src/main/java/danielcortes/xyz/Main.java b/src/main/java/danielcortes/xyz/Main.java deleted file mode 100644 index e73d710..0000000 --- a/src/main/java/danielcortes/xyz/Main.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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; - -import danielcortes.xyz.controllers.ManagerController; -import danielcortes.xyz.data.Properties; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; -import danielcortes.xyz.models.caja.SQLiteCajaDAO; -import danielcortes.xyz.models.documentos.DocumentosDAO; -import danielcortes.xyz.models.documentos.MysqlDocumentosDAO; -import danielcortes.xyz.models.documentos.SQLiteDocumentosDAO; -import danielcortes.xyz.models.efectivo.EfectivoDAO; -import danielcortes.xyz.models.efectivo.MysqlEfectivoDAO; -import danielcortes.xyz.models.efectivo.SQLiteEfectivoDAO; -import danielcortes.xyz.models.egreso.EgresoDAO; -import danielcortes.xyz.models.egreso.MysqlEgresoDAO; -import danielcortes.xyz.models.egreso.SQLiteEgresoDAO; -import danielcortes.xyz.models.ingreso.IngresoDAO; -import danielcortes.xyz.models.ingreso.MysqlIngresoDAO; -import danielcortes.xyz.models.ingreso.SQLiteIngresoDAO; -import danielcortes.xyz.models.tipo_egreso.MysqlTipoEgresoDAO; -import danielcortes.xyz.models.tipo_egreso.SQLiteTipoEgresoDAO; -import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO; -import danielcortes.xyz.models.tipo_ingreso.MysqlTipoIngresoDAO; -import danielcortes.xyz.models.tipo_ingreso.SQLiteTipoIngresoDAO; -import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO; -import danielcortes.xyz.views.ManagerView; - -import javax.swing.*; -import java.sql.SQLException; -import java.util.Locale; - -public class Main { - public static void main(String[] args) throws SQLException { - System.setProperty("awt.useSystemAAFontSettings", "on"); - System.setProperty("swing.aatext", "true"); - - try { - UIManager.setLookAndFeel(Properties.getInstance().getProperty("look_and_feel")); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { - e.printStackTrace(); - } - - Locale.setDefault(new Locale("es")); - - - CajaDAO cajaDAO = null; - DocumentosDAO documentosDAO = null; - EfectivoDAO efectivoDAO = null; - EgresoDAO egresoDAO = null; - IngresoDAO ingresoDAO = null; - TipoEgresoDAO tipoEgresoDAO = null; - TipoIngresoDAO tipoIngresoDAO = null; - - if(Properties.getInstance().getProperty("database_type").equals("mysql")){ - cajaDAO = new MysqlCajaDAO(); - documentosDAO = new MysqlDocumentosDAO(); - efectivoDAO = new MysqlEfectivoDAO(); - egresoDAO = new MysqlEgresoDAO(); - ingresoDAO = new MysqlIngresoDAO(); - tipoEgresoDAO = new MysqlTipoEgresoDAO(); - tipoIngresoDAO = new MysqlTipoIngresoDAO(); - }else if(Properties.getInstance().getProperty("database_type").equals("sqlite")){ - cajaDAO = new SQLiteCajaDAO(); - documentosDAO = new SQLiteDocumentosDAO(); - efectivoDAO = new SQLiteEfectivoDAO(); - egresoDAO = new SQLiteEgresoDAO(); - ingresoDAO = new SQLiteIngresoDAO(); - tipoEgresoDAO = new SQLiteTipoEgresoDAO(); - tipoIngresoDAO = new SQLiteTipoIngresoDAO(); - } - - ManagerView view = new ManagerView(); - ManagerController managerController = new ManagerController(view, cajaDAO, documentosDAO, efectivoDAO, egresoDAO, ingresoDAO, tipoEgresoDAO, tipoIngresoDAO); - - JFrame frame = new JFrame("Caja"); - frame.setContentPane(view.getContentPanel()); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - //frame.setSize(780, 450); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - } -} diff --git a/src/main/java/danielcortes/xyz/controllers/ArqueoController.java b/src/main/java/danielcortes/xyz/controllers/ArqueoController.java deleted file mode 100644 index 66db471..0000000 --- a/src/main/java/danielcortes/xyz/controllers/ArqueoController.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * 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.controllers; - -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.EfectivoDAO; -import danielcortes.xyz.models.egreso.EgresoDAO; -import danielcortes.xyz.models.ingreso.IngresoDAO; -import danielcortes.xyz.views.ArqueoView; - -import javax.swing.*; -import java.awt.*; - - -public class ArqueoController { - private ArqueoView view; - private Caja caja; - private Efectivo efectivo; - private Documentos documentos; - - private EfectivoDAO efectivoDAO; - private DocumentosDAO documentosDAO; - private IngresoDAO ingresoDAO; - private EgresoDAO egresoDAO; - - public ArqueoController(ArqueoView view, EfectivoDAO efectivoDAO, DocumentosDAO documentosDAO, IngresoDAO ingresoDAO, EgresoDAO egresoDAO) { - this.view = view; - this.efectivoDAO = efectivoDAO; - this.documentosDAO = documentosDAO; - this.ingresoDAO = ingresoDAO; - this.egresoDAO = egresoDAO; - - this.setUpViewEvents(); - } - - public void updateCaja(Caja caja) { - this.caja = caja; - fillDocumentos(); - fillEfectivo(); - fillResumen(); - } - - public void updateResumen() { - this.fillResumen(); - } - - private void fillEfectivo() { - this.efectivo = this.efectivoDAO.findByCaja(this.caja); - this.view.getVeinteMilField().setText(String.valueOf(efectivo.getVeinteMil())); - 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())); - this.view.getQuinientosField().setText(String.valueOf(efectivo.getQuinientos())); - this.view.getCienField().setText(String.valueOf(efectivo.getCien())); - this.view.getCincuentaField().setText(String.valueOf(efectivo.getCincuenta())); - this.view.getDiezField().setText(String.valueOf(efectivo.getDiez())); - } - - 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() { - this.updateResumenEfectivo(); - this.updateResumenDocumentos(); - this.updateResumenIngresos(); - this.updateResumenEgresos(); - this.updateResumenArqueo(); - } - - private void updateResumenEfectivo() { - JTextField efectivoField = this.view.getEfectivoField(); - int total = 0; - total += this.efectivo.getDiez(); - total += this.efectivo.getCincuenta(); - total += this.efectivo.getCien(); - total += this.efectivo.getQuinientos(); - total += this.efectivo.getMil(); - total += this.efectivo.getDosMil(); - total += this.efectivo.getCincoMil(); - total += this.efectivo.getDiezMil(); - total += this.efectivo.getVeinteMil(); - - efectivoField.setText(String.valueOf(total)); - } - - 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() { - int total = this.ingresoDAO.getTotalIngreso(this.caja); - this.view.getIngresosField().setText(String.valueOf(total)); - } - - private void updateResumenEgresos() { - int total = this.egresoDAO.getTotalEgreso(this.caja); - this.view.getEgresosField().setText(String.valueOf(total)); - } - - private void updateResumenArqueo() { - int totalEfectivo = Integer.parseInt(this.view.getEfectivoField().getText()); - int totalDocumentos = Integer.parseInt(this.view.getDocumentosField().getText()); - int totalIngresos = Integer.parseInt(this.view.getIngresosField().getText()); - int totalEgresos = Integer.parseInt(this.view.getEgresosField().getText()); - - int arqueo = totalDocumentos + totalEfectivo + totalEgresos; - int ajuste = arqueo - totalIngresos; - - this.view.getArqueoField().setText(String.valueOf(arqueo)); - this.view.getRendidoField().setText(String.valueOf(totalIngresos)); - 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)); - } - - } - - private void setUpViewEvents() { - this.view.getGuardarEfectivoButton().addActionListener(e -> { - this.normalizeEfectivoInput(); - this.guardarEfectivo(); - }); - this.view.getGuardarDocumentosButton().addActionListener(e -> { - this.normalizeDocumentosInput(); - this.guardarDocumentos(); - }); - } - - private void guardarEfectivo() { - String diez = this.view.getDiezField().getText(); - String cincuenta = this.view.getCincuentaField().getText(); - String cien = this.view.getCienField().getText(); - String quinientos = this.view.getQuinientosField().getText(); - String mil = this.view.getMilField().getText(); - String dosMil = this.view.getDosMilField().getText(); - String cincoMil = this.view.getCincoMilField().getText(); - String diezMil = this.view.getDiezMilField().getText(); - String veinteMil = this.view.getVeinteMilField().getText(); - - if (this.validateEfectivoInput(diez, cincuenta, cien, quinientos, mil, dosMil, cincoMil, diezMil, veinteMil)) { - this.efectivo.setDiez(Integer.valueOf(diez)); - this.efectivo.setCincuenta(Integer.valueOf(cincuenta)); - this.efectivo.setCien(Integer.valueOf(cien)); - this.efectivo.setQuinientos(Integer.valueOf(quinientos)); - this.efectivo.setMil(Integer.valueOf(mil)); - this.efectivo.setDosMil(Integer.valueOf(dosMil)); - this.efectivo.setCincoMil(Integer.valueOf(cincoMil)); - this.efectivo.setDiezMil(Integer.valueOf(diezMil)); - this.efectivo.setVeinteMil(Integer.valueOf(veinteMil)); - this.efectivoDAO.updateEfectivo(efectivo); - - this.updateResumenEfectivo(); - this.updateResumenArqueo(); - } - } - - 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(); - this.updateResumenArqueo(); - } - } - - private boolean validateEfectivoInput(String diez, String cincuenta, String cien, String quinientos, String mil, String dosMil, String cincoMil, String diezMil, String veinteMil) { - this.hiddeEfectivoErrorMessages(); - - boolean diezValidation = validateEfectivoMoneda(diez, this.view.getErrorDiez()); - boolean cincuentaValidation = validateEfectivoMoneda(cincuenta, this.view.getErrorCincuenta()); - boolean cienValidation = validateEfectivoMoneda(cien, this.view.getErrorCien()); - boolean quinientosValidation = validateEfectivoMoneda(quinientos, this.view.getErrorQuinientos()); - boolean milValidation = validateEfectivoMoneda(mil, this.view.getErrorMil()); - boolean dosMilValidation = validateEfectivoMoneda(dosMil, this.view.getErrorDosMil()); - boolean cincoMilValidation = validateEfectivoMoneda(cincoMil, this.view.getErrorCincoMil()); - boolean diezMilValidation = validateEfectivoMoneda(diezMil, this.view.getErrorDiezMil()); - boolean veinteMilValidation = validateEfectivoMoneda(veinteMil, this.view.getErrorVeinteMil()); - - 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) { - 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 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() { - this.view.getErrorDiez().setVisible(false); - this.view.getErrorCincuenta().setVisible(false); - this.view.getErrorCien().setVisible(false); - this.view.getErrorQuinientos().setVisible(false); - this.view.getErrorMil().setVisible(false); - this.view.getErrorDosMil().setVisible(false); - this.view.getErrorCincoMil().setVisible(false); - this.view.getErrorDiezMil().setVisible(false); - this.view.getErrorVeinteMil().setVisible(false); - } - - private void hiddeDocumentosErrorMessages(){ - this.view.getErrorTarjetas().setVisible(false); - this.view.getErrorCheques().setVisible(false); - } - - private void normalizeEfectivoInput() { - this.view.getDiezField().setText(this.view.getDiezField().getText().trim()); - this.view.getCincuentaField().setText(this.view.getCincuentaField().getText().trim()); - this.view.getCienField().setText(this.view.getCienField().getText().trim()); - this.view.getQuinientosField().setText(this.view.getQuinientosField().getText().trim()); - this.view.getMilField().setText(this.view.getMilField().getText().trim()); - this.view.getDosMilField().setText(this.view.getDosMilField().getText().trim()); - this.view.getCincoMilField().setText(this.view.getCincoMilField().getText().trim()); - this.view.getDiezMilField().setText(this.view.getDiezMilField().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()); - } - -} diff --git a/src/main/java/danielcortes/xyz/controllers/EgresosController.java b/src/main/java/danielcortes/xyz/controllers/EgresosController.java deleted file mode 100644 index 797c5f5..0000000 --- a/src/main/java/danielcortes/xyz/controllers/EgresosController.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * 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.controllers; - -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; - -import javax.swing.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -public class EgresosController { - private EgresosView view; - private EgresoDAO egresoDAO; - private TipoEgresoDAO tipoEgresoDAO; - private Caja caja; - - private int editingId; - private boolean editing; - private Egreso editingEgreso; - - public EgresosController(EgresosView view, EgresoDAO egresoDAO, TipoEgresoDAO tipoEgresoDAO) { - this.view = view; - this.egresoDAO = egresoDAO; - this.tipoEgresoDAO = tipoEgresoDAO; - this.setUpViewEvents(); - this.fillTipoEgresoCombo(); - this.updateButtonsEnabled(); - } - - public EgresoDAO getEgresoDAO() { - return egresoDAO; - } - - public TipoEgresoDAO getTipoEgresoDAO() { - return tipoEgresoDAO; - } - - public void updateCaja(Caja caja){ - this.caja = caja; - this.fillEgresosTable(); - this.updateTotalEgresos(); - } - - private void fillTipoEgresoCombo() { - JComboBox tipoCombo = view.getTipoCombo(); - for (TipoEgreso tipoEgreso : this.tipoEgresoDAO.findAll()) { - tipoCombo.addItem(tipoEgreso); - } - } - - private void fillEgresosTable() { - EgresosTableModel egresosTableModel = view.getEgresosTableModel(); - egresosTableModel.removeRows(); - for (Egreso egreso : this.egresoDAO.findByCaja(this.caja)) { - egresosTableModel.addRow(egreso); - } - } - - private void setUpViewEvents() { - this.view.getEgresosTable().getSelectionModel().addListSelectionListener(e -> onSelectTableRowListener()); - this.view.getGuardarButton().addActionListener(e -> guardarActionListener()); - this.view.getEliminarButton().addActionListener(e -> eliminarActionListener()); - this.view.getEditarButton().addActionListener(e -> editarActionListener()); - this.view.getDescripcionField().addActionListener(e -> guardarActionListener()); - this.view.getNroField().addActionListener(e -> guardarActionListener()); - this.view.getValorField().addActionListener(e -> guardarActionListener()); - this.view.getTipoCombo().addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - guardarActionListener(); - } - } - }); - this.view.getEgresosTable().addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent mouseEvent) { - JTable table = (JTable) mouseEvent.getSource(); - if (mouseEvent.getClickCount() == 2 && table.getSelectedRow() != -1) { - EgresosController.this.editarActionListener(); - } - } - }); - } - - private void guardarActionListener() { - this.normalizeInputs(); - - String nro = this.view.getNroField().getText(); - String descripcion = this.view.getDescripcionField().getText(); - String valor = this.view.getValorField().getText(); - TipoEgreso tipo = (TipoEgreso) this.view.getTipoCombo().getSelectedItem(); - - if(editing){ - this.editarEgreso(nro, descripcion, valor, tipo, this.caja); - }else { - this.guardarEgreso(nro, descripcion, valor, tipo, this.caja); - } - this.resetFocus(); - } - - private void eliminarActionListener() { - int selectedID = this.view.getEgresosTable().getSelectedRow(); - if (selectedID >= 0) { - Egreso egreso = this.view.getEgresosTableModel().getEgreso(selectedID); - this.view.getEgresosTableModel().removeRow(selectedID); - this.egresoDAO.deleteEgreso(egreso); - this.updateTotalEgresos(); - this.updateButtonsEnabled(); - } - } - - private void editarActionListener() { - int selectedID = this.view.getEgresosTable().getSelectedRow(); - if (selectedID >= 0) { - Egreso egreso = this.view.getEgresosTableModel().getEgreso(selectedID); - - this.editingId = selectedID; - this.editingEgreso = egreso; - this.editing = true; - - this.view.getNroField().setText(egreso.getNro()); - this.view.getDescripcionField().setText(egreso.getDescripcion()); - this.view.getValorField().setText(String.valueOf(egreso.getValor())); - this.view.getTipoCombo().setSelectedItem(egreso.getTipoEgreso()); - } - } - - private void onSelectTableRowListener() { - this.view.getEliminarButton().setEnabled(true); - this.view.getEditarButton().setEnabled(true); - } - - private void updateTotalEgresos() { - int total = this.egresoDAO.getTotalEgreso(this.caja); - this.view.getTotalEgresosField().setText(String.valueOf(total)); - } - - private void updateButtonsEnabled() { - if (this.view.getEgresosTable().getSelectedRow() >= 0) { - this.view.getEliminarButton().setEnabled(true); - this.view.getEditarButton().setEnabled(true); - } else { - this.view.getEliminarButton().setEnabled(false); - this.view.getEditarButton().setEnabled(false); - } - } - - private void guardarEgreso(String nro, String descripcion, String valor, TipoEgreso tipo, Caja caja) { - if (this.validateInput(nro, descripcion, valor, tipo, caja)) { - Egreso egreso = new Egreso(); - egreso.setValor(Integer.valueOf(valor)); - egreso.setDescripcion(descripcion); - egreso.setNro(nro); - egreso.setTipoEgreso(tipo); - egreso.setCaja(caja); - egresoDAO.insertEgreso(egreso); - this.view.getEgresosTableModel().addRow(egreso); - this.updateTotalEgresos(); - this.clearInputs(); - } - } - - private void editarEgreso(String nro, String descripcion, String valor, TipoEgreso tipo, Caja caja) { - if (this.validateInput(nro, descripcion, valor, tipo, caja)) { - this.editingEgreso.setValor(Integer.valueOf(valor)); - this.editingEgreso.setDescripcion(descripcion); - this.editingEgreso.setNro(nro); - this.editingEgreso.setTipoEgreso(tipo); - egresoDAO.updateEgreso(this.editingEgreso); - this.view.getEgresosTableModel().setEgreso(this.editingId, this.editingEgreso); - this.updateTotalEgresos(); - this.clearInputs(); - this.editing = false; - } - } - - private boolean validateInput(String nro, String descripcion, String valor, TipoEgreso tipoEgreso, Caja caja) { - this.hideErrorMessages(); - - boolean nroValidation = this.validateNro(nro); - boolean descripcionValidation = this.validateDescripcion(descripcion); - boolean valorValidation = this.validateValor(valor); - boolean tipoEgresoValidation = this.validateTipoEgreso(tipoEgreso); - boolean cajaValidation = this.validateCaja(caja); - - return nroValidation && descripcionValidation && valorValidation && tipoEgresoValidation; - } - - private boolean validateNro(String nro) { - if (nro == null) { - this.view.getErrorNumero().setText("Hubo un problema con los datos"); - this.view.getErrorNumero().setVisible(true); - return false; - } - - nro = nro.trim(); - if (nro.isEmpty()) { - this.view.getErrorNumero().setText("El campo esta vacio"); - this.view.getErrorNumero().setVisible(true); - return false; - } - return true; - - } - - private boolean validateDescripcion(String descripcion) { - if (descripcion == null) { - this.view.getErrorDescripcion().setText("Hubo un problema con los datos"); - this.view.getErrorDescripcion().setVisible(true); - return false; - } - - descripcion = descripcion.trim(); - if (descripcion.isEmpty()) { - this.view.getErrorDescripcion().setText("El campo esta vacio"); - this.view.getErrorDescripcion().setVisible(true); - return false; - } - return true; - } - - private boolean validateValor(String valor) { - if (valor == null) { - this.view.getErrorValor().setText("Hubo un problema con los datos"); - this.view.getErrorValor().setVisible(true); - return false; - } - - valor = valor.trim(); - if (valor.isEmpty()) { - this.view.getErrorValor().setText("El campo esta vacio"); - this.view.getErrorValor().setVisible(true); - return false; - } - - if (!valor.chars().allMatch(Character::isDigit)) { - this.view.getErrorValor().setText("Deben ser numeros"); - this.view.getErrorValor().setVisible(true); - return false; - } - - if (valor.length() > 10) { - this.view.getErrorValor().setText("El numero ingresado es demasiado largo"); - this.view.getErrorValor().setVisible(true); - return false; - } - - return true; - - } - - private boolean validateTipoEgreso(TipoEgreso tipoEgreso) { - if (tipoEgreso == null) { - this.view.getErrorTipoEgreso().setText("Hubo un problema con los datos"); - this.view.getErrorTipoEgreso().setVisible(true); - return false; - } - return true; - } - - private boolean validateCaja(Caja caja){ - return caja != null; - } - - private void hideErrorMessages() { - this.view.getErrorTipoEgreso().setVisible(false); - this.view.getErrorValor().setVisible(false); - this.view.getErrorDescripcion().setVisible(false); - this.view.getErrorNumero().setVisible(false); - } - - private void clearInputs() { - this.view.getTipoCombo().setSelectedIndex(0); - this.view.getNroField().setText(""); - this.view.getValorField().setText(""); - this.view.getDescripcionField().setText(""); - } - - private void normalizeInputs(){ - this.view.getValorField().setText(this.view.getValorField().getText().trim()); - this.view.getNroField().setText(this.view.getNroField().getText().trim()); - this.view.getDescripcionField().setText(this.view.getDescripcionField().getText().trim()); - - } - - private void resetFocus() { - this.view.getNroField().requestFocus(); - } -} diff --git a/src/main/java/danielcortes/xyz/controllers/IngresosController.java b/src/main/java/danielcortes/xyz/controllers/IngresosController.java deleted file mode 100644 index 181aa44..0000000 --- a/src/main/java/danielcortes/xyz/controllers/IngresosController.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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.controllers; - -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; - -import javax.swing.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -public class IngresosController { - private IngresosView view; - private IngresoDAO ingresoDAO; - private TipoIngresoDAO tipoIngresoDAO; - private Caja caja; - - private int editingId; - private Ingreso editingIngreso; - private boolean editing; - - public IngresosController(IngresosView view, IngresoDAO ingresoDAO, TipoIngresoDAO tipoIngresoDAO) { - this.view = view; - this.ingresoDAO = ingresoDAO; - this.tipoIngresoDAO = tipoIngresoDAO; - this.fillTipoIngresoCombo(); - this.setupViewEvents(); - this.updateButtonsEnabled(); - } - - public IngresoDAO getIngresoDAO() { - return ingresoDAO; - } - - public TipoIngresoDAO getTipoIngresoDAO() { - return tipoIngresoDAO; - } - - public void updateCaja(Caja caja){ - this.caja = caja; - this.fillIngresosTable(); - this.updateTotalIngresos(); - } - - private void fillTipoIngresoCombo() { - JComboBox tipoCombo = this.view.getTipoCombo(); - for (TipoIngreso tipo : this.tipoIngresoDAO.findAll()) { - tipoCombo.addItem(tipo); - } - } - - private void fillIngresosTable() { - IngresosTableModel ingresosTableModel = this.view.getIngresosTableModel(); - ingresosTableModel.removeRows(); - for (Ingreso ingreso : this.ingresoDAO.findByCaja(this.caja)) { - ingresosTableModel.addRow(ingreso); - } - } - - private void setupViewEvents() { - 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()); - - this.view.getTipoCombo().addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if(e.getKeyCode() == KeyEvent.VK_ENTER){ - guardarActionListener(); - } - } - }); - - this.view.getIngresosTable().addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent mouseEvent) { - JTable table = (JTable) mouseEvent.getSource(); - if (mouseEvent.getClickCount() == 2 && table.getSelectedRow() != -1) { - IngresosController.this.editarActionListener(); - } - } - }); - } - - 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, nroInicial, nroFinal, tipoIngreso, this.caja); - } else { - this.guardarIngreso(valor, nroInicial, nroFinal, tipoIngreso, this.caja); - } - this.resetFocus(); - } - - private void eliminarActionListener() { - int selectedId = this.view.getIngresosTable().getSelectedRow(); - if(selectedId >= 0){ - Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedId); - this.view.getIngresosTableModel().removeRow(selectedId); - this.ingresoDAO.deleteIngreso(ingreso); - this.updateTotalIngresos(); - this.updateButtonsEnabled(); - } - } - - private void editarActionListener() { - int selectedID = this.view.getIngresosTable().getSelectedRow(); - if(selectedID >= 0) { - Ingreso ingreso = this.view.getIngresosTableModel().getIngreso(selectedID); - - this.editingId = selectedID; - this.editingIngreso = ingreso; - this.editing = true; - - 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())); - } - } - - private void onSelectTableRowListener(){ - this.view.getEliminarButton().setEnabled(true); - this.view.getEditarButton().setEnabled(true); - } - - private void updateTotalIngresos(){ - int total = this.ingresoDAO.getTotalIngreso(this.caja); - this.view.getTotalIngresoField().setText(String.valueOf(total)); - } - - private void updateButtonsEnabled() { - if(this.view.getIngresosTable().getSelectedRow()>=0){ - this.view.getEliminarButton().setEnabled(true); - this.view.getEditarButton().setEnabled(true); - }else{ - this.view.getEliminarButton().setEnabled(false); - this.view.getEditarButton().setEnabled(false); - } - } - - 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); - - this.clearInputs(); - this.updateTotalIngresos(); - } - } - - 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(); - this.clearInputs(); - this.editing = false; - } - } - - 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); - - return valorValidation && tipoIngresoValidation && cajaValidation; - } - - private boolean validateCaja(Caja caja) { - return caja != null; - } - - private boolean validateValor(String valor) { - if (valor == null) { - this.view.getErrorValor().setText("Hubo un problema con los datos"); - this.view.getErrorValor().setVisible(true); - return false; - } - - valor = valor.trim(); - if (valor.isEmpty()) { - this.view.getErrorValor().setText("El campo esta vacio"); - this.view.getErrorValor().setVisible(true); - return false; - } - - if (!valor.chars().allMatch(Character::isDigit)) { - this.view.getErrorValor().setText("Deben ser numeros"); - this.view.getErrorValor().setVisible(true); - return false; - } - - if(valor.length() > 10){ - this.view.getErrorValor().setText("El numero ingresado es demasiado largo"); - this.view.getErrorValor().setVisible(true); - return false; - } - - return true; - - } - - 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"); - this.view.getErrorTipoIngreso().setVisible(true); - return false; - } - return true; - } - - 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(){ - this.view.getTipoCombo().requestFocus(); - } -} diff --git a/src/main/java/danielcortes/xyz/controllers/ManagerController.java b/src/main/java/danielcortes/xyz/controllers/ManagerController.java deleted file mode 100644 index e00feff..0000000 --- a/src/main/java/danielcortes/xyz/controllers/ManagerController.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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.controllers; - -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.documentos.MysqlDocumentosDAO; -import danielcortes.xyz.models.efectivo.Efectivo; -import danielcortes.xyz.models.efectivo.EfectivoDAO; -import danielcortes.xyz.models.efectivo.MysqlEfectivoDAO; -import danielcortes.xyz.models.egreso.EgresoDAO; -import danielcortes.xyz.models.ingreso.IngresoDAO; -import danielcortes.xyz.models.ingreso.MysqlIngresoDAO; -import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO; -import danielcortes.xyz.models.egreso.MysqlEgresoDAO; -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 javax.swing.*; -import java.awt.*; -import java.time.LocalDate; - - -public class ManagerController { - private ManagerView view; - private CajaDAO cajaDAO; - private DocumentosDAO documentosDAO; - private EfectivoDAO efectivoDAO; - private EgresoDAO egresoDAO; - private IngresoDAO ingresoDAO; - private TipoEgresoDAO tipoEgresoDAO; - private TipoIngresoDAO tipoIngresoDAO; - private IngresosController ingresosController; - private EgresosController egresosController; - private ArqueoController arqueoController; - - public ManagerController(ManagerView view, CajaDAO cajaDAO, DocumentosDAO documentosDAO, EfectivoDAO efectivoDAO, EgresoDAO egresoDAO, IngresoDAO ingresoDAO, TipoEgresoDAO tipoEgresoDAO, TipoIngresoDAO tipoIngresoDAO) { - 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(); - this.pressInitialButton(); - } - - private void setUpDate(){ - this.view.getDatePicker().setDateToToday(); - this.updateCaja(); - } - - private void setUpViewEvents() { - this.view.getEgresosButton().addActionListener(e -> { - CardLayout layout = (CardLayout) this.view.getCardPanel().getLayout(); - layout.show(this.view.getCardPanel(), "EGRESOS"); - }); - this.view.getIngresosButton().addActionListener(e -> { - CardLayout layout = (CardLayout) this.view.getCardPanel().getLayout(); - layout.show(this.view.getCardPanel(), "INGRESOS"); - }); - - this.view.getArqueoButton().addActionListener(e -> { - this.arqueoController.updateResumen(); - - CardLayout layout = (CardLayout) this.view.getCardPanel().getLayout(); - layout.show(this.view.getCardPanel(), "ARQUEO"); - }); - - this.view.getDatePicker().addDateChangeListener(e -> updateCaja()); - } - - private void updateCaja(){ - LocalDate selectedDate = this.view.getDatePicker().getDate(); - Caja caja = this.cajaDAO.findByFecha(selectedDate); - - if(caja == null){ - caja = new Caja(); - caja.setFecha(selectedDate); - this.cajaDAO.insertCaja(caja); - - Efectivo efectivo = new Efectivo(); - efectivo.setCaja(caja); - this.efectivoDAO.insertDefaultEfectivo(efectivo); - - Documentos documentos = new Documentos(); - documentos.setCaja(caja); - this.documentosDAO.insertDefaultDocumentos(documentos); - } - - this.ingresosController.updateCaja(caja); - this.egresosController.updateCaja(caja); - this.arqueoController.updateCaja(caja); - } - - private void loadCardContents() { - this.loadEgresosView(); - this.loadIngresosView(); - this.loadArqueoView(); - } - - private void loadIngresosView() { - IngresosView ingresosView = new IngresosView(); - - this.view.getCardPanel().add(ingresosView.getContentPanel(), "INGRESOS"); - - this.ingresosController = new IngresosController(ingresosView, this.ingresoDAO, this.tipoIngresoDAO); - } - - private void loadEgresosView() { - EgresosView egresosView = new EgresosView(); - - this.view.getCardPanel().add(egresosView.getContentPanel(), "EGRESOS"); - - this.egresosController = new EgresosController(egresosView, this.egresoDAO, this.tipoEgresoDAO); - } - - private void loadArqueoView() { - ArqueoView arqueoView = new ArqueoView(); - - this.view.getCardPanel().add(arqueoView.getContentPanel(), "ARQUEO"); - - this.arqueoController = new ArqueoController(arqueoView, this.efectivoDAO, this.documentosDAO, this.ingresoDAO, this.egresoDAO); - } - - private void pressInitialButton() { - this.view.getIngresosButton().doClick(); - } -} diff --git a/src/main/java/danielcortes/xyz/data/ConnectionHolder.java b/src/main/java/danielcortes/xyz/data/ConnectionHolder.java deleted file mode 100644 index 8cbdec2..0000000 --- a/src/main/java/danielcortes/xyz/data/ConnectionHolder.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.data; - -import java.sql.SQLException; - -public interface ConnectionHolder { - public java.sql.Connection getConnection() throws SQLException; -} diff --git a/src/main/java/danielcortes/xyz/data/MysqlConnectionHolder.java b/src/main/java/danielcortes/xyz/data/MysqlConnectionHolder.java deleted file mode 100644 index caccf5f..0000000 --- a/src/main/java/danielcortes/xyz/data/MysqlConnectionHolder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.data; - -import java.sql.*; - -public class MysqlConnectionHolder implements ConnectionHolder { - private String databaseURI; - public MysqlConnectionHolder(){ - this.databaseURI = Properties.getInstance().getProperty("database_uri"); - } - - public java.sql.Connection getConnection() throws SQLException{ - return DriverManager.getConnection(databaseURI); - } -} diff --git a/src/main/java/danielcortes/xyz/data/Properties.java b/src/main/java/danielcortes/xyz/data/Properties.java deleted file mode 100644 index aa0127e..0000000 --- a/src/main/java/danielcortes/xyz/data/Properties.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.data; - -import java.io.FileInputStream; -import java.io.IOException; - -public class Properties { - private static Properties ourInstance = new Properties(); - public static java.util.Properties getInstance() { - return ourInstance.props; - } - - private java.util.Properties props; - - private Properties() { - try { - this.props = new java.util.Properties(); - FileInputStream in = new FileInputStream("conf.properties"); - this.props.load(in); - in.close(); - } catch (IOException e) { - System.err.println("Couldn't load properties"); - e.printStackTrace(); - } - } - - - -} diff --git a/src/main/java/danielcortes/xyz/data/SQLiteConnectionHolder.java b/src/main/java/danielcortes/xyz/data/SQLiteConnectionHolder.java deleted file mode 100644 index d502961..0000000 --- a/src/main/java/danielcortes/xyz/data/SQLiteConnectionHolder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.data; - -import java.sql.DriverManager; -import java.sql.SQLException; - -public class SQLiteConnectionHolder implements ConnectionHolder { - private String databaseURI; - public SQLiteConnectionHolder(){ - this.databaseURI = Properties.getInstance().getProperty("database_uri"); - } - - @Override - public java.sql.Connection getConnection() throws SQLException{ - try { - Class.forName("org.sqlite.JDBC"); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - return DriverManager.getConnection(databaseURI); - } -} diff --git a/src/main/java/danielcortes/xyz/models/caja/Caja.java b/src/main/java/danielcortes/xyz/models/caja/Caja.java deleted file mode 100644 index f3b1442..0000000 --- a/src/main/java/danielcortes/xyz/models/caja/Caja.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.caja; - -import java.time.LocalDate; - -public class Caja { - private int id; - private LocalDate fecha; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public LocalDate getFecha() { - return fecha; - } - - public void setFecha(LocalDate fecha) { - this.fecha = fecha; - } -} diff --git a/src/main/java/danielcortes/xyz/models/caja/CajaDAO.java b/src/main/java/danielcortes/xyz/models/caja/CajaDAO.java deleted file mode 100644 index 796bbf5..0000000 --- a/src/main/java/danielcortes/xyz/models/caja/CajaDAO.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.caja; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -public abstract class CajaDAO { - protected ConnectionHolder connectionHolder; - - public abstract List findAll(); - public abstract Caja findById(int id); - public abstract Caja findByFecha(LocalDate fecha); - public abstract boolean insertCaja(Caja caja); - public abstract boolean updateCaja(Caja caja); - - protected List cajasFromResultSet(ResultSet rs) throws SQLException { - List cajaList = new ArrayList<>(); - while (rs.next()) { - Caja caja = new Caja(); - caja.setId(rs.getInt("id")); - caja.setFecha(LocalDate.parse(rs.getString("fecha"))); - cajaList.add(caja); - } - return cajaList; - } -} diff --git a/src/main/java/danielcortes/xyz/models/caja/MysqlCajaDAO.java b/src/main/java/danielcortes/xyz/models/caja/MysqlCajaDAO.java deleted file mode 100644 index 7e3ca82..0000000 --- a/src/main/java/danielcortes/xyz/models/caja/MysqlCajaDAO.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.caja; - -import danielcortes.xyz.data.MysqlConnectionHolder; - -import java.sql.*; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -public class MysqlCajaDAO extends CajaDAO { - - public MysqlCajaDAO() { - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List cajaList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from caja"); - ResultSet rs = ps.executeQuery(); - - cajaList = this.cajasFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return cajaList; - } - - @Override - public Caja findById(int id) { - Caja caja = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from caja where id = ?"); - - ps.setInt(1, id); - - ResultSet rs = ps.executeQuery(); - - caja = this.cajasFromResultSet(rs).get(0); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return caja; - } - - @Override - public Caja findByFecha(LocalDate fecha) { - Caja caja = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from caja where fecha = ?"); - - ps.setObject(1, fecha); - - ResultSet rs = ps.executeQuery(); - - List cajaList = this.cajasFromResultSet(rs); - - if (cajaList.size() > 0) { - caja = cajaList.get(0); - } - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return caja; - } - - @Override - public boolean insertCaja(Caja caja) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into caja (fecha) values (?)"); - ps.setObject(1, caja.getFecha()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_id()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - caja.setId(rs.getInt(1)); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateCaja(Caja caja) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("update caja set fecha = ? where id = ?"); - ps.setObject(1, caja.getFecha()); - ps.setInt(2, caja.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } -} diff --git a/src/main/java/danielcortes/xyz/models/caja/SQLiteCajaDAO.java b/src/main/java/danielcortes/xyz/models/caja/SQLiteCajaDAO.java deleted file mode 100644 index 54a43c6..0000000 --- a/src/main/java/danielcortes/xyz/models/caja/SQLiteCajaDAO.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.caja; - -import danielcortes.xyz.data.SQLiteConnectionHolder; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -public class SQLiteCajaDAO extends CajaDAO { - public SQLiteCajaDAO () { - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List cajaList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from caja"); - ResultSet rs = ps.executeQuery(); - - cajaList = this.cajasFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return cajaList; - } - - @Override - public Caja findById(int id) { - Caja caja = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from caja where id = ?"); - - ps.setInt(1, id); - - ResultSet rs = ps.executeQuery(); - - caja = this.cajasFromResultSet(rs).get(0); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return caja; - } - - @Override - public Caja findByFecha(LocalDate fecha) { - Caja caja = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from caja where fecha = ?"); - - ps.setString(1, fecha.toString()); - - ResultSet rs = ps.executeQuery(); - - List cajaList = this.cajasFromResultSet(rs); - - if(cajaList.size() > 0){ - caja = cajaList.get(0); - } - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return caja; - } - - @Override - public boolean insertCaja(Caja caja) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into caja (fecha) values (?)"); - - ps.setString(1, caja.getFecha().toString()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_rowid()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - caja.setId(rs.getInt(1)); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateCaja(Caja caja) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("update caja set fecha = ? where id = ?"); - ps.setString(1, caja.getFecha().toString()); - ps.setInt(2, caja.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } -} diff --git a/src/main/java/danielcortes/xyz/models/documentos/Documentos.java b/src/main/java/danielcortes/xyz/models/documentos/Documentos.java deleted file mode 100644 index f0bb1b7..0000000 --- a/src/main/java/danielcortes/xyz/models/documentos/Documentos.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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; - } -} diff --git a/src/main/java/danielcortes/xyz/models/documentos/DocumentosDAO.java b/src/main/java/danielcortes/xyz/models/documentos/DocumentosDAO.java deleted file mode 100644 index 2186221..0000000 --- a/src/main/java/danielcortes/xyz/models/documentos/DocumentosDAO.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.ConnectionHolder; -import danielcortes.xyz.data.MysqlConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public abstract class DocumentosDAO { - protected ConnectionHolder connectionHolder; - - public abstract List findAll(); - public abstract Documentos findById(int id); - public abstract Documentos findByCaja(Caja caja); - - public abstract boolean insertDocumentos(Documentos documentos); - public abstract boolean insertDefaultDocumentos(Documentos documentos); - public abstract boolean updateDocumentos(Documentos documentos); - public abstract boolean deleteDocumentos(Documentos documentos); - - protected List documentosFromResultSet(ResultSet rs) throws SQLException { - List 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; - } -} diff --git a/src/main/java/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java b/src/main/java/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java deleted file mode 100644 index 781bee5..0000000 --- a/src/main/java/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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.MysqlConnectionHolder; -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 extends DocumentosDAO { - - public MysqlDocumentosDAO() { - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List documentosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.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 = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from documentos where id = ?"); - ps.setInt(1, id); - - ResultSet rs = ps.executeQuery(); - - List 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 = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from documentos where caja_id = ?"); - ps.setInt(1, caja.getId()); - - ResultSet rs = ps.executeQuery(); - - List 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 = connectionHolder.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 = connectionHolder.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 = connectionHolder.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 = connectionHolder.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; - } - -} diff --git a/src/main/java/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java b/src/main/java/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java deleted file mode 100644 index 06d7dd6..0000000 --- a/src/main/java/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.SQLiteCajaDAO; - -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 SQLiteDocumentosDAO extends DocumentosDAO { - public SQLiteDocumentosDAO() { - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List documentosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.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 = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from documentos where id = ?"); - ps.setInt(1, id); - - ResultSet rs = ps.executeQuery(); - - List 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 = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from documentos where caja_id = ?"); - ps.setInt(1, caja.getId()); - - ResultSet rs = ps.executeQuery(); - - List 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 = connectionHolder.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_rowid()"); - 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 = connectionHolder.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_rowid()"); - 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 = connectionHolder.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 = connectionHolder.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; - } -} diff --git a/src/main/java/danielcortes/xyz/models/efectivo/Efectivo.java b/src/main/java/danielcortes/xyz/models/efectivo/Efectivo.java deleted file mode 100644 index 6261226..0000000 --- a/src/main/java/danielcortes/xyz/models/efectivo/Efectivo.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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.efectivo; - -import danielcortes.xyz.models.caja.Caja; - -public class Efectivo { - private int id; - private int veinteMil; - private int diezMil; - private int cincoMil; - private int dosMil; - private int mil; - private int quinientos; - private int cien; - private int cincuenta; - private int diez; - private Caja caja; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getVeinteMil() { - return veinteMil; - } - - public void setVeinteMil(int veinteMil) { - this.veinteMil = veinteMil; - } - - public int getDiezMil() { - return diezMil; - } - - public void setDiezMil(int diezMil) { - this.diezMil = diezMil; - } - - public int getCincoMil() { - return cincoMil; - } - - public void setCincoMil(int cincoMil) { - this.cincoMil = cincoMil; - } - - public int getDosMil() { - return dosMil; - } - - public void setDosMil(int dosMil) { - this.dosMil = dosMil; - } - - public int getMil() { - return mil; - } - - public void setMil(int mil) { - this.mil = mil; - } - - public int getQuinientos() { - return quinientos; - } - - public void setQuinientos(int quinientos) { - this.quinientos = quinientos; - } - - public int getCien() { - return cien; - } - - public void setCien(int cien) { - this.cien = cien; - } - - public int getCincuenta() { - return cincuenta; - } - - public void setCincuenta(int cincuenta) { - this.cincuenta = cincuenta; - } - - public int getDiez() { - return diez; - } - - public void setDiez(int diez) { - this.diez = diez; - } - - public Caja getCaja() { - return caja; - } - - public void setCaja(Caja caja) { - this.caja = caja; - } -} diff --git a/src/main/java/danielcortes/xyz/models/efectivo/EfectivoDAO.java b/src/main/java/danielcortes/xyz/models/efectivo/EfectivoDAO.java deleted file mode 100644 index ccc9ffd..0000000 --- a/src/main/java/danielcortes/xyz/models/efectivo/EfectivoDAO.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.efectivo; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.MysqlConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public abstract class EfectivoDAO { - protected ConnectionHolder connectionHolder; - - public abstract List findAll(); - public abstract Efectivo findById(int id); - public abstract Efectivo findByCaja(Caja caja); - - public abstract boolean insertEfectivo(Efectivo efectivo); - public abstract boolean insertDefaultEfectivo(Efectivo efectivo); - public abstract boolean updateEfectivo(Efectivo efectivo); - public abstract boolean deleteEfectivo(Efectivo efectivo); - - protected List efectivosFromResultSet(ResultSet rs) throws SQLException { - List efectivoList = new ArrayList<>(); - while (rs.next()) { - CajaDAO cajaDAO = new MysqlCajaDAO(); - Caja caja = cajaDAO.findById(rs.getInt("caja_id")); - - Efectivo efectivo = new Efectivo(); - efectivo.setCaja(caja); - efectivo.setId(rs.getInt("id")); - efectivo.setVeinteMil(rs.getInt("veinte_mil")); - efectivo.setDiezMil(rs.getInt("diez_mil")); - efectivo.setCincoMil(rs.getInt("cinco_mil")); - efectivo.setDosMil(rs.getInt("dos_mil")); - efectivo.setMil(rs.getInt("mil")); - efectivo.setQuinientos(rs.getInt("quinientos")); - efectivo.setCien(rs.getInt("cien")); - efectivo.setCincuenta(rs.getInt("cincuenta")); - efectivo.setDiez(rs.getInt("diez")); - - efectivoList.add(efectivo); - } - return efectivoList; - } -} diff --git a/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java b/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java deleted file mode 100644 index 312a890..0000000 --- a/src/main/java/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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.efectivo; - -import danielcortes.xyz.data.MysqlConnectionHolder; -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 MysqlEfectivoDAO extends EfectivoDAO { - public MysqlEfectivoDAO() { - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List efectivoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from efectivos"); - ResultSet rs = ps.executeQuery(); - - efectivoList = this.efectivosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return efectivoList; - } - - @Override - public Efectivo findById(int id) { - Efectivo efectivo = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from efectivos where id = ?"); - ps.setInt(1, id); - ResultSet rs = ps.executeQuery(); - - efectivo = this.efectivosFromResultSet(rs).get(0); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return efectivo; - } - - @Override - public Efectivo findByCaja(Caja caja) { - Efectivo efectivo = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from efectivos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - List efectivoList = this.efectivosFromResultSet(rs); - if (efectivoList.size() > 0) { - efectivo = efectivoList.get(0); - } - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return efectivo; - } - - @Override - public boolean insertEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into efectivos (veinte_mil, diez_mil, cinco_mil, dos_mil, mil, quinientos, cien, cincuenta, diez, caja_id) values (?,?,?,?,?,?,?,?,?,?)"); - ps.setInt(1, efectivo.getVeinteMil()); - ps.setInt(2, efectivo.getDiezMil()); - ps.setInt(3, efectivo.getCincoMil()); - ps.setInt(4, efectivo.getDosMil()); - ps.setInt(5, efectivo.getMil()); - ps.setInt(6, efectivo.getQuinientos()); - ps.setInt(7, efectivo.getCien()); - ps.setInt(8, efectivo.getCincuenta()); - ps.setInt(9, efectivo.getDiez()); - ps.setInt(10, efectivo.getCaja().getId()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_id()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - efectivo.setId(rs.getInt(1)); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean insertDefaultEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into efectivos (veinte_mil, diez_mil, cinco_mil, dos_mil, mil, quinientos, cien, cincuenta, diez, caja_id) values (0,0,0,0,0,0,0,0,0,?)"); - ps.setInt(1, efectivo.getCaja().getId()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_id()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - efectivo.setId(rs.getInt(1)); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("update efectivos set veinte_mil = ?, diez_mil = ?, cinco_mil = ?, dos_mil = ?, mil = ?, quinientos = ?, cien = ?, cincuenta = ?, diez = ?, caja_id = ? where id = ?"); - ps.setInt(1, efectivo.getVeinteMil()); - ps.setInt(2, efectivo.getDiezMil()); - ps.setInt(3, efectivo.getCincoMil()); - ps.setInt(4, efectivo.getDosMil()); - ps.setInt(5, efectivo.getMil()); - ps.setInt(6, efectivo.getQuinientos()); - ps.setInt(7, efectivo.getCien()); - ps.setInt(8, efectivo.getCincuenta()); - ps.setInt(9, efectivo.getDiez()); - ps.setInt(10, efectivo.getCaja().getId()); - ps.setInt(11, efectivo.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean deleteEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("delete from efectivos where id = ?"); - ps.setInt(1, efectivo.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - -} diff --git a/src/main/java/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java b/src/main/java/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java deleted file mode 100644 index 4cd9f29..0000000 --- a/src/main/java/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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.efectivo; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.SQLiteCajaDAO; - -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 SQLiteEfectivoDAO extends EfectivoDAO { - public SQLiteEfectivoDAO() { - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List efectivoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from efectivos"); - ResultSet rs = ps.executeQuery(); - - efectivoList = this.efectivosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return efectivoList; - } - - @Override - public Efectivo findById(int id) { - Efectivo efectivo = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from efectivos where id = ?"); - ps.setInt(1, id); - ResultSet rs = ps.executeQuery(); - - efectivo = this.efectivosFromResultSet(rs).get(0); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return efectivo; - } - - @Override - public Efectivo findByCaja(Caja caja) { - Efectivo efectivo = null; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from efectivos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - List efectivoList = this.efectivosFromResultSet(rs); - if (efectivoList.size() > 0) { - efectivo = efectivoList.get(0); - } - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - - return efectivo; - } - - @Override - public boolean insertEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into efectivos (veinte_mil, diez_mil, cinco_mil, dos_mil, mil, quinientos, cien, cincuenta, diez, caja_id) values (?,?,?,?,?,?,?,?,?,?)"); - ps.setInt(1, efectivo.getVeinteMil()); - ps.setInt(2, efectivo.getDiezMil()); - ps.setInt(3, efectivo.getCincoMil()); - ps.setInt(4, efectivo.getDosMil()); - ps.setInt(5, efectivo.getMil()); - ps.setInt(6, efectivo.getQuinientos()); - ps.setInt(7, efectivo.getCien()); - ps.setInt(8, efectivo.getCincuenta()); - ps.setInt(9, efectivo.getDiez()); - ps.setInt(10, efectivo.getCaja().getId()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_rowid()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - efectivo.setId(rs.getInt(1)); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean insertDefaultEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into efectivos (veinte_mil, diez_mil, cinco_mil, dos_mil, mil, quinientos, cien, cincuenta, diez, caja_id) values (0,0,0,0,0,0,0,0,0,?)"); - ps.setInt(1, efectivo.getCaja().getId()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_rowid()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - efectivo.setId(rs.getInt(1)); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("update efectivos set veinte_mil = ?, diez_mil = ?, cinco_mil = ?, dos_mil = ?, mil = ?, quinientos = ?, cien = ?, cincuenta = ?, diez = ?, caja_id = ? where id = ?"); - ps.setInt(1, efectivo.getVeinteMil()); - ps.setInt(2, efectivo.getDiezMil()); - ps.setInt(3, efectivo.getCincoMil()); - ps.setInt(4, efectivo.getDosMil()); - ps.setInt(5, efectivo.getMil()); - ps.setInt(6, efectivo.getQuinientos()); - ps.setInt(7, efectivo.getCien()); - ps.setInt(8, efectivo.getCincuenta()); - ps.setInt(9, efectivo.getDiez()); - ps.setInt(10, efectivo.getCaja().getId()); - ps.setInt(11, efectivo.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean deleteEfectivo(Efectivo efectivo) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("delete from efectivos where id = ?"); - ps.setInt(1, efectivo.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } -} diff --git a/src/main/java/danielcortes/xyz/models/egreso/Egreso.java b/src/main/java/danielcortes/xyz/models/egreso/Egreso.java deleted file mode 100644 index 7a7e514..0000000 --- a/src/main/java/danielcortes/xyz/models/egreso/Egreso.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.egreso; - -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.tipo_egreso.TipoEgreso; - -public class Egreso { - - private int id; - private String nro; - private String descripcion; - private int valor; - private TipoEgreso tipoEgreso; - private Caja caja; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getNro() { - return nro; - } - - public void setNro(String nro) { - this.nro = nro; - } - - public String getDescripcion() { - return descripcion; - } - - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } - - public int getValor() { - return valor; - } - - public void setValor(int valor) { - this.valor = valor; - } - - public TipoEgreso getTipoEgreso() { - return tipoEgreso; - } - - public void setTipoEgreso(TipoEgreso tipoEgreso) { - this.tipoEgreso = tipoEgreso; - } - - public Caja getCaja() { - return caja; - } - - public void setCaja(Caja caja) { - this.caja = caja; - } -} diff --git a/src/main/java/danielcortes/xyz/models/egreso/EgresoDAO.java b/src/main/java/danielcortes/xyz/models/egreso/EgresoDAO.java deleted file mode 100644 index f64ae40..0000000 --- a/src/main/java/danielcortes/xyz/models/egreso/EgresoDAO.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.egreso; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; -import danielcortes.xyz.models.egreso.Egreso; -import danielcortes.xyz.models.tipo_egreso.MysqlTipoEgresoDAO; -import danielcortes.xyz.models.tipo_egreso.TipoEgreso; -import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public abstract class EgresoDAO { - protected ConnectionHolder connectionHolder; - - public abstract List findAll(); - public abstract List findById(int id); - public abstract List findByCaja(Caja caja); - public abstract List findByNro(String nro); - public abstract List findByTipoEgreso(TipoEgreso tipoEgreso); - - public abstract boolean insertEgreso(Egreso egreso); - public abstract boolean updateEgreso(Egreso egreso); - public abstract boolean deleteEgreso(Egreso egreso); - - public abstract int getTotalEgreso(Caja caja); - - List egresosFromResultSet(ResultSet rs) throws SQLException { - ArrayList egresoList = new ArrayList<>(); - while(rs.next()){ - int tipoEgresoId = rs.getInt("tipo_egreso_id"); - TipoEgresoDAO tipoEgresoDAO = new MysqlTipoEgresoDAO(); - TipoEgreso tipoEgreso = tipoEgresoDAO.findById(tipoEgresoId).get(0); - - int cajaId = rs.getInt("caja_id"); - CajaDAO cajaDAO = new MysqlCajaDAO(); - Caja caja = cajaDAO.findById(cajaId); - - Egreso egreso = new Egreso(); - - egreso.setId(rs.getInt("id")); - egreso.setNro(rs.getString("nro")); - egreso.setDescripcion(rs.getString("descripcion")); - egreso.setValor(rs.getInt("valor")); - egreso.setTipoEgreso(tipoEgreso); - egreso.setCaja(caja); - - egresoList.add(egreso); - } - return egresoList; - } -} diff --git a/src/main/java/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java b/src/main/java/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java deleted file mode 100644 index 793a296..0000000 --- a/src/main/java/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * 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.egreso; - -import danielcortes.xyz.data.MysqlConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; -import danielcortes.xyz.models.tipo_egreso.TipoEgreso; -import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO; -import danielcortes.xyz.models.tipo_egreso.MysqlTipoEgresoDAO; - -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 MysqlEgresoDAO extends EgresoDAO { - - public MysqlEgresoDAO(){ - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos"); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findById(int id) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where id = ?"); - ps.setInt(1,id); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findByCaja(Caja caja) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - - @Override - public List findByNro(String nro) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where nro = ?"); - ps.setString(1, nro); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findByTipoEgreso(TipoEgreso tipoEgreso) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where tipo_egreso_id = ?"); - ps.setInt(1, tipoEgreso.getId()); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public boolean insertEgreso(Egreso egreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into egresos (nro, descripcion, valor, tipo_egreso_id, caja_id) values (?,?,?,?,?)"); - ps.setString(1,egreso.getNro()); - ps.setString(2,egreso.getDescripcion()); - ps.setInt(3,egreso.getValor()); - ps.setInt(4,egreso.getTipoEgreso().getId()); - ps.setInt(5, egreso.getCaja().getId()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_id()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - egreso.setId(rs.getInt(1)); - - rs.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateEgreso(Egreso egreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("update egresos set nro = ?, descripcion = ?, valor = ?, tipo_egreso_id = ?, caja_id = ? where id = ? "); - ps.setString(1,egreso.getNro()); - ps.setString(2,egreso.getDescripcion()); - ps.setInt(3,egreso.getValor()); - ps.setInt(4,egreso.getTipoEgreso().getId()); - ps.setInt(5, egreso.getCaja().getId()); - ps.setInt(6, egreso.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean deleteEgreso(Egreso egreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("delete from egresos where id = ? "); - ps.setInt(1, egreso.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public int getTotalEgreso(Caja caja) { - int total = 0; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select sum(valor) from egresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - rs.next(); - total = rs.getInt(1); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return total; - } - -} diff --git a/src/main/java/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java b/src/main/java/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java deleted file mode 100644 index 4555aee..0000000 --- a/src/main/java/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * 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.egreso; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.SQLiteCajaDAO; -import danielcortes.xyz.models.tipo_egreso.SQLiteTipoEgresoDAO; -import danielcortes.xyz.models.tipo_egreso.TipoEgreso; -import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO; - -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 SQLiteEgresoDAO extends EgresoDAO { - public SQLiteEgresoDAO(){ - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos"); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findById(int id) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where id = ?"); - ps.setInt(1,id); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findByCaja(Caja caja) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findByNro(String nro) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where nro = ?"); - ps.setString(1, nro); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public List findByTipoEgreso(TipoEgreso tipoEgreso) { - List egresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from egresos where tipo_egreso_id = ?"); - ps.setInt(1, tipoEgreso.getId()); - ResultSet rs = ps.executeQuery(); - - egresoList = this.egresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return egresoList; - } - - @Override - public boolean insertEgreso(Egreso egreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into egresos (nro, descripcion, valor, tipo_egreso_id, caja_id) values (?,?,?,?,?)"); - ps.setString(1,egreso.getNro()); - ps.setString(2,egreso.getDescripcion()); - ps.setInt(3,egreso.getValor()); - ps.setInt(4,egreso.getTipoEgreso().getId()); - ps.setInt(5, egreso.getCaja().getId()); - - updates = ps.executeUpdate(); - ps.close(); - - ps = conn.prepareStatement("select last_insert_rowid()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - egreso.setId(rs.getInt(1)); - - rs.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateEgreso(Egreso egreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("update egresos set nro = ?, descripcion = ?, valor = ?, tipo_egreso_id = ?, caja_id = ? where id = ? "); - ps.setString(1,egreso.getNro()); - ps.setString(2,egreso.getDescripcion()); - ps.setInt(3,egreso.getValor()); - ps.setInt(4,egreso.getTipoEgreso().getId()); - ps.setInt(5, egreso.getCaja().getId()); - ps.setInt(6, egreso.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean deleteEgreso(Egreso egreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("delete from egresos where id = ? "); - ps.setInt(1, egreso.getId()); - - updates = ps.executeUpdate(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public int getTotalEgreso(Caja caja) { - int total = 0; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select sum(valor) from egresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - rs.next(); - total = rs.getInt(1); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return total; - } -} diff --git a/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java b/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java deleted file mode 100644 index 1df8f89..0000000 --- a/src/main/java/danielcortes/xyz/models/ingreso/Ingreso.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.ingreso; - -import danielcortes.xyz.models.caja.Caja; -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 int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getValor() { - return valor; - } - - public void setValor(int valor) { - 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; - } - - public void setCaja(Caja caja) { - this.caja = caja; - } -} diff --git a/src/main/java/danielcortes/xyz/models/ingreso/IngresoDAO.java b/src/main/java/danielcortes/xyz/models/ingreso/IngresoDAO.java deleted file mode 100644 index 89a07cd..0000000 --- a/src/main/java/danielcortes/xyz/models/ingreso/IngresoDAO.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.ingreso; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; -import danielcortes.xyz.models.tipo_ingreso.MysqlTipoIngresoDAO; -import danielcortes.xyz.models.tipo_ingreso.TipoIngreso; -import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public abstract class IngresoDAO { - protected ConnectionHolder connectionHolder; - - public abstract List findAll(); - public abstract List findByCaja(Caja caja); - public abstract List findById(int id); - public abstract List findByTipoIngreso(TipoIngreso tipoIngreso); - - public abstract boolean insertIngreso(Ingreso ingreso); - public abstract boolean updateIngreso(Ingreso ingreso); - public abstract boolean deleteIngreso(Ingreso ingreso); - - public abstract int getTotalIngreso(Caja caja); - - List ingresosFromResultSet(ResultSet rs) throws SQLException { - ArrayList ingresosList = new ArrayList<>(); - while(rs.next()){ - int tipoIngresoId = rs.getInt("tipo_ingreso_id"); - TipoIngresoDAO tipoEgresoDAO = new MysqlTipoIngresoDAO(); - TipoIngreso tipoIngreso = tipoEgresoDAO.findById(tipoIngresoId).get(0); - - int cajaId = rs.getInt("caja_id"); - CajaDAO cajaDAO = new MysqlCajaDAO(); - Caja caja = cajaDAO.findById(cajaId); - - Ingreso ingreso = new Ingreso(); - - 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); - - ingresosList.add(ingreso); - } - return ingresosList; - } -} diff --git a/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java b/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java deleted file mode 100644 index 3752c4b..0000000 --- a/src/main/java/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * 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.ingreso; - -import danielcortes.xyz.data.MysqlConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.MysqlCajaDAO; -import danielcortes.xyz.models.tipo_ingreso.MysqlTipoIngresoDAO; -import danielcortes.xyz.models.tipo_ingreso.TipoIngreso; -import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO; - -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 MysqlIngresoDAO extends IngresoDAO { - - public MysqlIngresoDAO(){ - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from ingresos"); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public List findByCaja(Caja caja) { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from ingresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public List findById(int id) { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from ingresos where id = ?"); - ps.setInt(1, id); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public List findByTipoIngreso(TipoIngreso tipoIngreso) { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select ingresos.* from ingresos inner join tipos_ingreso on (ingresos.tipo_ingreso_id = tipos_ingreso.id) where ingresos.tipo_ingreso_id = ?"); - ps.setInt(1, tipoIngreso.getId()); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public boolean insertIngreso(Ingreso ingreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into ingresos (valor, nro_inicial, nro_final, tipo_ingreso_id, caja_id) values (?,?,?,?,?)"); - ps.setInt(1, ingreso.getValor()); - 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(); - - ps = conn.prepareStatement("select last_insert_id()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - ingreso.setId(rs.getInt(1)); - - rs.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateIngreso(Ingreso ingreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - 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.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(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean deleteIngreso(Ingreso ingreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("delete from ingresos where id = ?"); - ps.setInt(1,ingreso.getId()); - updates = ps.executeUpdate(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public int getTotalIngreso(Caja caja) { - int total = 0; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select sum(valor) from ingresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - rs.next(); - total = rs.getInt(1); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return total; - } - -} diff --git a/src/main/java/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java b/src/main/java/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java deleted file mode 100644 index 5595e8f..0000000 --- a/src/main/java/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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.ingreso; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; -import danielcortes.xyz.models.caja.Caja; -import danielcortes.xyz.models.caja.CajaDAO; -import danielcortes.xyz.models.caja.SQLiteCajaDAO; -import danielcortes.xyz.models.tipo_ingreso.SQLiteTipoIngresoDAO; -import danielcortes.xyz.models.tipo_ingreso.TipoIngreso; -import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO; - -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 SQLiteIngresoDAO extends IngresoDAO { - public SQLiteIngresoDAO(){ - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from ingresos"); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public List findByCaja(Caja caja) { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from ingresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public List findById(int id) { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from ingresos where id = ?"); - ps.setInt(1, id); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public List findByTipoIngreso(TipoIngreso tipoIngreso) { - List ingresosList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select ingresos.* from ingresos inner join tipos_ingreso on (ingresos.tipo_ingreso_id = tipos_ingreso.id) where ingresos.tipo_ingreso_id = ?"); - ps.setInt(1, tipoIngreso.getId()); - ResultSet rs = ps.executeQuery(); - - ingresosList = this.ingresosFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return ingresosList; - } - - @Override - public boolean insertIngreso(Ingreso ingreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("insert into ingresos (valor, nro_inicial, nro_final, tipo_ingreso_id, caja_id) values (?,?,?,?,?)"); - ps.setInt(1, ingreso.getValor()); - 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(); - - ps = conn.prepareStatement("select last_insert_rowid()"); - ResultSet rs = ps.executeQuery(); - rs.next(); - ingreso.setId(rs.getInt(1)); - - rs.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean updateIngreso(Ingreso ingreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - 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.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(); - - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public boolean deleteIngreso(Ingreso ingreso) { - int updates; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("delete from ingresos where id = ?"); - ps.setInt(1,ingreso.getId()); - updates = ps.executeUpdate(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - return false; - } - return updates > 0; - } - - @Override - public int getTotalIngreso(Caja caja) { - int total = 0; - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select sum(valor) from ingresos where caja_id = ?"); - ps.setInt(1, caja.getId()); - ResultSet rs = ps.executeQuery(); - - rs.next(); - total = rs.getInt(1); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return total; - } -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java b/src/main/java/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java deleted file mode 100644 index 1ceda7d..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.tipo_egreso; - -import danielcortes.xyz.data.MysqlConnectionHolder; - -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 MysqlTipoEgresoDAO extends TipoEgresoDAO { - - public MysqlTipoEgresoDAO(){ - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List tipoEgresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso"); - ResultSet rs = ps.executeQuery(); - - tipoEgresoList = this.tipoEgresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tipoEgresoList; - } - - @Override - public List findById(int id) { - List tipoEgresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso where id = ?"); - ps.setInt(1, id); - ResultSet rs = ps.executeQuery(); - - tipoEgresoList = this.tipoEgresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tipoEgresoList; - } - - @Override - public List findByNombre(String nombre) { - List tipoEgresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso where nombre = ?"); - ps.setString(1, nombre); - ResultSet rs = ps.executeQuery(); - - tipoEgresoList = this.tipoEgresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tipoEgresoList; - } - - @Override - public boolean insertTipoEgreso(TipoEgreso tipoEgreso) { - return false; - } - - @Override - public boolean updateTipoEgreso(TipoEgreso tipoEgreso) { - return false; - } - - @Override - public boolean deleteTipoEgreso(TipoEgreso tipoEgreso) { - return false; - } -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java b/src/main/java/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java deleted file mode 100644 index 738f101..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.tipo_egreso; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; - -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 SQLiteTipoEgresoDAO extends TipoEgresoDAO { - public SQLiteTipoEgresoDAO(){ - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List tipoEgresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso"); - ResultSet rs = ps.executeQuery(); - - tipoEgresoList = this.tipoEgresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tipoEgresoList; - } - - @Override - public List findById(int id) { - List tipoEgresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso where id = ?"); - ps.setInt(1, id); - ResultSet rs = ps.executeQuery(); - - tipoEgresoList = this.tipoEgresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tipoEgresoList; - } - - @Override - public List findByNombre(String nombre) { - List tipoEgresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso where nombre = ?"); - ps.setString(1, nombre); - ResultSet rs = ps.executeQuery(); - - tipoEgresoList = this.tipoEgresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tipoEgresoList; - } - - @Override - public boolean insertTipoEgreso(TipoEgreso tipoEgreso) { - return false; - } - - @Override - public boolean updateTipoEgreso(TipoEgreso tipoEgreso) { - return false; - } - - @Override - public boolean deleteTipoEgreso(TipoEgreso tipoEgreso) { - return false; - } - -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java b/src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java deleted file mode 100644 index 1bf43e1..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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. - */ - -/* - * 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.tipo_egreso; - -public class TipoEgreso { - private int id; - private String nombre; - - public TipoEgreso(int id, String nombre) { - this.id = id; - this.nombre = nombre; - } - - public TipoEgreso(String nombre) { - this.nombre = nombre; - } - - public TipoEgreso(){} - - public String getNombre() { - return nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - public String toString(){ - return this.nombre; - } -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java b/src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java deleted file mode 100644 index 00d2a07..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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. - */ - -/* - * 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.tipo_egreso; - -import danielcortes.xyz.data.ConnectionHolder; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public abstract class TipoEgresoDAO { - protected ConnectionHolder connectionHolder; - - public abstract List findAll(); - public abstract List findById(int id); - public abstract List findByNombre(String nombre); - - public abstract boolean insertTipoEgreso(TipoEgreso tipoEgreso); - public abstract boolean updateTipoEgreso(TipoEgreso tipoEgreso); - public abstract boolean deleteTipoEgreso(TipoEgreso tipoEgreso); - - List tipoEgresoFromResultSet(ResultSet rs) throws SQLException { - ArrayList tipoEgresoList = new ArrayList<>(); - while(rs.next()){ - TipoEgreso tipoEgreso = new TipoEgreso(); - tipoEgreso.setId(rs.getInt("id")); - tipoEgreso.setNombre(rs.getString("nombre")); - tipoEgresoList.add(tipoEgreso); - } - return tipoEgresoList; - } -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java b/src/main/java/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java deleted file mode 100644 index d35dcd1..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.tipo_ingreso; - -import danielcortes.xyz.data.MysqlConnectionHolder; - -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 MysqlTipoIngresoDAO extends TipoIngresoDAO { - public MysqlTipoIngresoDAO(){ - this.connectionHolder = new MysqlConnectionHolder(); - } - - @Override - public List findAll() { - List tiposIngresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso"); - ResultSet rs = ps.executeQuery(); - - tiposIngresoList = this.tiposIngresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tiposIngresoList; - } - - @Override - public List findById(int id) { - List tiposIngresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso where id = ?"); - ps.setInt(1,id); - ResultSet rs = ps.executeQuery(); - - tiposIngresoList = this.tiposIngresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tiposIngresoList; - } - - @Override - public List findByNombre(String nombre) { - List tiposIngresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso where nombre = ?"); - ps.setString(1,nombre); - ResultSet rs = ps.executeQuery(); - - tiposIngresoList = this.tiposIngresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tiposIngresoList; - } - - @Override - public boolean insertTipoIngreso(TipoIngreso tipoEgreso) { - return false; - } - - @Override - public boolean updateTipoIngreso(TipoIngreso tipoEgreso) { - return false; - } - - @Override - public boolean deleteTipoIngreso(TipoIngreso tipoEgreso) { - return false; - } -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java b/src/main/java/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java deleted file mode 100644 index 53813a1..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.tipo_ingreso; - -import danielcortes.xyz.data.ConnectionHolder; -import danielcortes.xyz.data.SQLiteConnectionHolder; - -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 SQLiteTipoIngresoDAO extends TipoIngresoDAO { - public SQLiteTipoIngresoDAO(){ - this.connectionHolder = new SQLiteConnectionHolder(); - } - - @Override - public List findAll() { - List tiposIngresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso"); - ResultSet rs = ps.executeQuery(); - - tiposIngresoList = this.tiposIngresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tiposIngresoList; - } - - @Override - public List findById(int id) { - List tiposIngresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso where id = ?"); - ps.setInt(1,id); - ResultSet rs = ps.executeQuery(); - - tiposIngresoList = this.tiposIngresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tiposIngresoList; - } - - @Override - public List findByNombre(String nombre) { - List tiposIngresoList = new ArrayList<>(); - try { - Connection conn = connectionHolder.getConnection(); - PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso where nombre = ?"); - ps.setString(1,nombre); - ResultSet rs = ps.executeQuery(); - - tiposIngresoList = this.tiposIngresoFromResultSet(rs); - - rs.close(); - ps.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - return tiposIngresoList; - } - - @Override - public boolean insertTipoIngreso(TipoIngreso tipoEgreso) { - return false; - } - - @Override - public boolean updateTipoIngreso(TipoIngreso tipoEgreso) { - return false; - } - - @Override - public boolean deleteTipoIngreso(TipoIngreso tipoEgreso) { - return false; - } - -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java b/src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java deleted file mode 100644 index f48f5e5..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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. - */ - -/* - * 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.tipo_ingreso; - -public class TipoIngreso { - private int id; - private String nombre; - - public TipoIngreso(int id, String nombre) { - this.id = id; - this.nombre = nombre; - } - - public TipoIngreso(String nombre) { - this.nombre = nombre; - } - - public TipoIngreso() { - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getNombre() { - return nombre; - } - - public void setNombre(String nombre) { - this.nombre = nombre; - } - - @Override - public String toString() { - return this.nombre; - } -} diff --git a/src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java b/src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java deleted file mode 100644 index 8aa573a..0000000 --- a/src/main/java/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.tipo_ingreso; - -import danielcortes.xyz.data.ConnectionHolder; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -public abstract class TipoIngresoDAO { - protected ConnectionHolder connectionHolder; - public abstract List findAll(); - public abstract List findById(int id); - public abstract List findByNombre(String nombre); - - public abstract boolean insertTipoIngreso(TipoIngreso tipoEgreso); - public abstract boolean updateTipoIngreso(TipoIngreso tipoEgreso); - public abstract boolean deleteTipoIngreso(TipoIngreso tipoEgreso); - - List tiposIngresoFromResultSet(ResultSet rs) throws SQLException { - ArrayList tiposIngresoList = new ArrayList<>(); - while(rs.next()){ - TipoIngreso tipoIngreso = new TipoIngreso(); - tipoIngreso.setId(rs.getInt("id")); - tipoIngreso.setNombre(rs.getString("nombre")); - tiposIngresoList.add(tipoIngreso); - } - return tiposIngresoList; - } -} diff --git a/src/main/java/danielcortes/xyz/views/ArqueoView.form b/src/main/java/danielcortes/xyz/views/ArqueoView.form deleted file mode 100644 index d6c0746..0000000 --- a/src/main/java/danielcortes/xyz/views/ArqueoView.form +++ /dev/null @@ -1,526 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/danielcortes/xyz/views/ArqueoView.java b/src/main/java/danielcortes/xyz/views/ArqueoView.java deleted file mode 100644 index 3c2bd81..0000000 --- a/src/main/java/danielcortes/xyz/views/ArqueoView.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * 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.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; -import java.awt.*; - -public class ArqueoView { - private JPanel contentPanel; - private JTextField veinteMilField; - private JTextField diezMilField; - private JTextField cincoMilField; - private JTextField dosMilField; - private JTextField milField; - private JTextField quinientosField; - private JTextField cienField; - private JTextField cincuentaField; - private JTextField diezField; - private JTextField chequesField; - private JTextField tarjetasField; - private JTextField efectivoField; - private JTextField documentosField; - private JTextField egresosField; - private JTextField ingresosField; - private JTextField arqueoField; - private JButton guardarEfectivoButton; - private JButton guardarDocumentosButton; - private JLabel errorVeinteMil; - private JLabel errorDiezMil; - private JLabel errorCincoMil; - private JLabel errorDosMil; - private JLabel errorMil; - private JLabel errorQuinientos; - private JLabel errorCien; - private JLabel errorCincuenta; - private JLabel errorDiez; - private JLabel errorCheques; - private JLabel errorTarjetas; - private JTextField ajusteField; - private JTextField rendidoField; - - public JPanel getContentPanel() { - return contentPanel; - } - - public JTextField getVeinteMilField() { - return veinteMilField; - } - - public JTextField getDiezMilField() { - return diezMilField; - } - - public JTextField getCincoMilField() { - return cincoMilField; - } - - public JTextField getDosMilField() { - return dosMilField; - } - - public JTextField getMilField() { - return milField; - } - - public JTextField getQuinientosField() { - return quinientosField; - } - - public JTextField getCienField() { - return cienField; - } - - public JTextField getCincuentaField() { - return cincuentaField; - } - - public JTextField getDiezField() { - return diezField; - } - - public JTextField getChequesField() { - return chequesField; - } - - public JTextField getTarjetasField() { - return tarjetasField; - } - - public JTextField getEfectivoField() { - return efectivoField; - } - - public JTextField getDocumentosField() { - return documentosField; - } - - public JTextField getEgresosField() { - return egresosField; - } - - public JTextField getIngresosField() { - return ingresosField; - } - - public JTextField getArqueoField() { - return arqueoField; - } - - public JTextField getRendidoField() { - return rendidoField; - } - - public JTextField getAjusteField() { - return ajusteField; - } - - public JButton getGuardarEfectivoButton() { - return guardarEfectivoButton; - } - - public JButton getGuardarDocumentosButton() { - return guardarDocumentosButton; - } - - public JLabel getErrorVeinteMil() { - return errorVeinteMil; - } - - public JLabel getErrorDiezMil() { - return errorDiezMil; - } - - public JLabel getErrorCincoMil() { - return errorCincoMil; - } - - public JLabel getErrorDosMil() { - return errorDosMil; - } - - public JLabel getErrorMil() { - return errorMil; - } - - public JLabel getErrorQuinientos() { - return errorQuinientos; - } - - public JLabel getErrorCien() { - return errorCien; - } - - public JLabel getErrorCincuenta() { - return errorCincuenta; - } - - public JLabel getErrorDiez() { - return errorDiez; - } - - public JLabel getErrorCheques() { - return errorCheques; - } - - public JLabel getErrorTarjetas() { - return errorTarjetas; - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - contentPanel = new JPanel(); - 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)); - panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Detalle Documentos", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, this.$$$getFont$$$(null, -1, -1, panel1.getFont()))); - chequesField = new JTextField(); - 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)); - final JLabel label1 = new JLabel(); - label1.setText("Tarjetas de Credito"); - 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.setText("0"); - 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.setText("Guardar"); - 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(false); - 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(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(8, 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(); - label3.setText("Efectivo"); - panel2.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)); - efectivoField = new JTextField(); - efectivoField.setEditable(false); - efectivoField.setText("0"); - panel2.add(efectivoField, 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 label4 = new JLabel(); - label4.setText("Documentos"); - panel2.add(label4, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - documentosField = new JTextField(); - documentosField.setEditable(false); - documentosField.setText("0"); - panel2.add(documentosField, 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)); - final JLabel label5 = new JLabel(); - label5.setText("Ingresos"); - panel2.add(label5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label6 = new JLabel(); - label6.setText("Egresos"); - panel2.add(label6, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - egresosField = new JTextField(); - egresosField.setEditable(false); - egresosField.setText("0"); - panel2.add(egresosField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - ingresosField = new JTextField(); - ingresosField.setEditable(false); - ingresosField.setText("0"); - 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("Rendido"); - panel2.add(label7, new GridConstraints(6, 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(6, 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(7, 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(7, 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 JLabel label9 = new JLabel(); - label9.setText("Debe Rendir"); - panel2.add(label9, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - rendidoField = new JTextField(); - Font rendidoFieldFont = this.$$$getFont$$$(null, Font.BOLD, -1, rendidoField.getFont()); - if (rendidoFieldFont != null) rendidoField.setFont(rendidoFieldFont); - rendidoField.setText("0"); - panel2.add(rendidoField, 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)); - 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, 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 label10 = new JLabel(); - label10.setText("$20000"); - panel3.add(label10, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - veinteMilField = new JTextField(); - veinteMilField.setText("0"); - panel3.add(veinteMilField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - final JLabel label11 = new JLabel(); - label11.setText("$10000"); - panel3.add(label11, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - diezMilField = new JTextField(); - diezMilField.setText("0"); - panel3.add(diezMilField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - cincoMilField = new JTextField(); - cincoMilField.setText("0"); - panel3.add(cincoMilField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - final JLabel label12 = new JLabel(); - label12.setText("$5000"); - panel3.add(label12, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label13 = new JLabel(); - label13.setText("$2000"); - panel3.add(label13, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - dosMilField = new JTextField(); - dosMilField.setText("0"); - panel3.add(dosMilField, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - milField = new JTextField(); - milField.setText("0"); - panel3.add(milField, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - final JLabel label14 = new JLabel(); - label14.setText("$1000"); - panel3.add(label14, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label15 = new JLabel(); - label15.setText("$500"); - panel3.add(label15, new GridConstraints(10, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - quinientosField = new JTextField(); - quinientosField.setText("0"); - panel3.add(quinientosField, new GridConstraints(10, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - final JLabel label16 = new JLabel(); - label16.setText("$100"); - panel3.add(label16, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - cienField = new JTextField(); - cienField.setText("0"); - panel3.add(cienField, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - final JLabel label17 = new JLabel(); - label17.setText("$50"); - panel3.add(label17, new GridConstraints(14, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - cincuentaField = new JTextField(); - cincuentaField.setText("0"); - panel3.add(cincuentaField, new GridConstraints(14, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - final JLabel label18 = new JLabel(); - label18.setText("$10"); - panel3.add(label18, new GridConstraints(16, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - diezField = new JTextField(); - diezField.setText("0"); - panel3.add(diezField, new GridConstraints(16, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - guardarEfectivoButton = new JButton(); - guardarEfectivoButton.setText("Guardar"); - panel3.add(guardarEfectivoButton, new GridConstraints(18, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); - errorVeinteMil = new JLabel(); - errorVeinteMil.setForeground(new Color(-65536)); - errorVeinteMil.setText("Error"); - errorVeinteMil.setVisible(false); - panel3.add(errorVeinteMil, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorDiezMil = new JLabel(); - errorDiezMil.setForeground(new Color(-65536)); - errorDiezMil.setText("Error"); - errorDiezMil.setVisible(false); - panel3.add(errorDiezMil, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorCincoMil = new JLabel(); - errorCincoMil.setForeground(new Color(-65536)); - errorCincoMil.setText("Error"); - errorCincoMil.setVisible(false); - panel3.add(errorCincoMil, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorDosMil = new JLabel(); - errorDosMil.setForeground(new Color(-65536)); - errorDosMil.setText("Error"); - errorDosMil.setVisible(false); - panel3.add(errorDosMil, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorMil = new JLabel(); - errorMil.setForeground(new Color(-65536)); - errorMil.setText("Error"); - errorMil.setVisible(false); - panel3.add(errorMil, new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorQuinientos = new JLabel(); - errorQuinientos.setForeground(new Color(-65536)); - errorQuinientos.setText("Error"); - errorQuinientos.setVisible(false); - panel3.add(errorQuinientos, new GridConstraints(11, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorCien = new JLabel(); - errorCien.setForeground(new Color(-65536)); - errorCien.setText("Error"); - errorCien.setVisible(false); - panel3.add(errorCien, new GridConstraints(13, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorCincuenta = new JLabel(); - errorCincuenta.setForeground(new Color(-65536)); - errorCincuenta.setText("Error"); - errorCincuenta.setVisible(false); - panel3.add(errorCincuenta, new GridConstraints(15, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorDiez = new JLabel(); - errorDiez.setForeground(new Color(-65536)); - 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)); - } - - /** - * @noinspection ALL - */ - private Font $$$getFont$$$(String fontName, int style, int size, Font currentFont) { - if (currentFont == null) return null; - String resultName; - if (fontName == null) { - resultName = currentFont.getName(); - } else { - Font testFont = new Font(fontName, Font.PLAIN, 10); - if (testFont.canDisplay('a') && testFont.canDisplay('1')) { - resultName = fontName; - } else { - resultName = currentFont.getName(); - } - } - return new Font(resultName, style >= 0 ? style : currentFont.getStyle(), size >= 0 ? size : currentFont.getSize()); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPanel; - } - -} diff --git a/src/main/java/danielcortes/xyz/views/EgresosView.form b/src/main/java/danielcortes/xyz/views/EgresosView.form deleted file mode 100644 index 56c9c05..0000000 --- a/src/main/java/danielcortes/xyz/views/EgresosView.form +++ /dev/null @@ -1,244 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/danielcortes/xyz/views/EgresosView.java b/src/main/java/danielcortes/xyz/views/EgresosView.java deleted file mode 100644 index fba1945..0000000 --- a/src/main/java/danielcortes/xyz/views/EgresosView.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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.views; - -import danielcortes.xyz.models.tipo_egreso.TipoEgreso; -import danielcortes.xyz.views.components.EgresosTableModel; - -import javax.swing.*; -import java.awt.*; - -public class EgresosView { - public JPanel contentPanel; - private JTable egresosTable; - private JButton guardarButton; - private JTextField valorField; - private JTextField descripcionField; - private JTextField nroField; - private JTextField totalEgresosField; - private JComboBox tipoCombo; - - - private JButton eliminarButton; - private JLabel errorNumero; - private JLabel errorDescripcion; - private JLabel errorValor; - private JLabel errorTipoEgreso; - private JButton editarButton; - - private EgresosTableModel egresosTableModel; - - private void createUIComponents() { - createEgresosTable(); - } - - private void createEgresosTable() { - egresosTableModel = new EgresosTableModel(); - egresosTable = new JTable(egresosTableModel); - egresosTable.setAutoCreateRowSorter(true); - egresosTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - } - - public JPanel getContentPanel() { - return contentPanel; - } - - public JButton getGuardarButton() { - return guardarButton; - } - - public JButton getEliminarButton() { - return eliminarButton; - } - - public JButton getEditarButton() { - return editarButton; - } - - public JTextField getValorField() { - return valorField; - } - - public JTextField getDescripcionField() { - return descripcionField; - } - - public JTextField getNroField() { - return nroField; - } - - public JTextField getTotalEgresosField() { - return totalEgresosField; - } - - public JComboBox getTipoCombo() { - return tipoCombo; - } - - public JTable getEgresosTable() { - return egresosTable; - } - - public EgresosTableModel getEgresosTableModel() { - return egresosTableModel; - } - - public JLabel getErrorNumero() { - return errorNumero; - } - - public JLabel getErrorDescripcion() { - return errorDescripcion; - } - - public JLabel getErrorValor() { - return errorValor; - } - - public JLabel getErrorTipoEgreso() { - return errorTipoEgreso; - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - createUIComponents(); - contentPanel = new JPanel(); - contentPanel.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); - contentPanel.add(panel1, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Egresos")); - final JScrollPane scrollPane1 = new JScrollPane(); - panel1.add(scrollPane1, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); - scrollPane1.setViewportView(egresosTable); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(3, 4, new Insets(0, 0, 0, 0), -1, -1)); - panel1.add(panel2, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label1 = new JLabel(); - label1.setText("N°"); - panel2.add(label1, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label2 = new JLabel(); - label2.setText("Descripcion"); - panel2.add(label2, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - descripcionField = new JTextField(); - panel2.add(descripcionField, new com.intellij.uiDesigner.core.GridConstraints(1, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - nroField = new JTextField(); - panel2.add(nroField, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - valorField = new JTextField(); - panel2.add(valorField, new com.intellij.uiDesigner.core.GridConstraints(1, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final JLabel label3 = new JLabel(); - label3.setText("Valor"); - panel2.add(label3, new com.intellij.uiDesigner.core.GridConstraints(0, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JLabel label4 = new JLabel(); - label4.setText("Tipo"); - panel2.add(label4, new com.intellij.uiDesigner.core.GridConstraints(0, 3, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - tipoCombo = new JComboBox(); - panel2.add(tipoCombo, new com.intellij.uiDesigner.core.GridConstraints(1, 3, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - errorNumero = new JLabel(); - errorNumero.setEnabled(true); - errorNumero.setForeground(new Color(-65536)); - errorNumero.setText("Error"); - errorNumero.setVisible(false); - panel2.add(errorNumero, new com.intellij.uiDesigner.core.GridConstraints(2, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorDescripcion = new JLabel(); - errorDescripcion.setEnabled(true); - errorDescripcion.setForeground(new Color(-65536)); - errorDescripcion.setText("Error"); - errorDescripcion.setVisible(false); - panel2.add(errorDescripcion, new com.intellij.uiDesigner.core.GridConstraints(2, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorValor = new JLabel(); - errorValor.setEnabled(true); - errorValor.setForeground(new Color(-65536)); - errorValor.setText("Error"); - errorValor.setVisible(false); - panel2.add(errorValor, new com.intellij.uiDesigner.core.GridConstraints(2, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - errorTipoEgreso = new JLabel(); - errorTipoEgreso.setEnabled(true); - errorTipoEgreso.setForeground(new Color(-65536)); - errorTipoEgreso.setText("Error"); - errorTipoEgreso.setVisible(false); - panel2.add(errorTipoEgreso, new com.intellij.uiDesigner.core.GridConstraints(2, 3, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel3 = new JPanel(); - panel3.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel1.add(panel3, new com.intellij.uiDesigner.core.GridConstraints(2, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JPanel panel4 = new JPanel(); - panel4.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel3.add(panel4, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - guardarButton = new JButton(); - guardarButton.setText("Guardar"); - guardarButton.setMnemonic('G'); - guardarButton.setDisplayedMnemonicIndex(0); - panel4.add(guardarButton, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - eliminarButton = new JButton(); - eliminarButton.setEnabled(false); - eliminarButton.setText("Eliminar"); - eliminarButton.setMnemonic('E'); - eliminarButton.setDisplayedMnemonicIndex(0); - panel4.add(eliminarButton, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - editarButton = new JButton(); - editarButton.setEnabled(false); - editarButton.setText("Editar"); - editarButton.setMnemonic('E'); - editarButton.setDisplayedMnemonicIndex(0); - panel4.add(editarButton, new com.intellij.uiDesigner.core.GridConstraints(0, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final com.intellij.uiDesigner.core.Spacer spacer1 = new com.intellij.uiDesigner.core.Spacer(); - panel3.add(spacer1, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - final JPanel panel5 = new JPanel(); - panel5.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel3.add(panel5, new com.intellij.uiDesigner.core.GridConstraints(0, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - final JLabel label5 = new JLabel(); - label5.setText("Total Egresos:"); - panel5.add(label5, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_EAST, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - totalEgresosField = new JTextField(); - totalEgresosField.setEditable(false); - panel5.add(totalEgresosField, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_WEST, com.intellij.uiDesigner.core.GridConstraints.FILL_HORIZONTAL, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_WANT_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPanel; - } -} diff --git a/src/main/java/danielcortes/xyz/views/IngresosView.form b/src/main/java/danielcortes/xyz/views/IngresosView.form deleted file mode 100644 index 70cea4f..0000000 --- a/src/main/java/danielcortes/xyz/views/IngresosView.form +++ /dev/null @@ -1,239 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/danielcortes/xyz/views/IngresosView.java b/src/main/java/danielcortes/xyz/views/IngresosView.java deleted file mode 100644 index 806d069..0000000 --- a/src/main/java/danielcortes/xyz/views/IngresosView.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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.views; - -import com.intellij.uiDesigner.core.GridConstraints; -import com.intellij.uiDesigner.core.GridLayoutManager; -import com.intellij.uiDesigner.core.Spacer; -import danielcortes.xyz.models.tipo_ingreso.TipoIngreso; -import danielcortes.xyz.views.components.IngresosTableModel; - -import javax.swing.*; -import java.awt.*; - -public class IngresosView { - private JPanel contentPanel; - private JTable ingresosTable; - private JButton guardarButton; - private JButton eliminarButton; - private JTextField totalIngresoField; - private JTextField valorField; - private JComboBox tipoCombo; - private JLabel errorTipoIngreso; - private JLabel errorValor; - private JButton editarButton; - private JTextField nroInicialField; - private JTextField nroFinalField; - private JLabel errorNroInicial; - private JLabel errorNroFinal; - - private IngresosTableModel ingresosTableModel; - - private void createUIComponents() { - this.createIngresosTable(); - } - - private void createIngresosTable() { - this.ingresosTableModel = new IngresosTableModel(); - this.ingresosTable = new JTable(ingresosTableModel); - this.ingresosTable.setAutoCreateRowSorter(true); - this.ingresosTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - } - - public JPanel getContentPanel() { - return contentPanel; - } - - public JTable getIngresosTable() { - return ingresosTable; - } - - public JButton getGuardarButton() { - return guardarButton; - } - - public JButton getEliminarButton() { - return eliminarButton; - } - - public JTextField getTotalIngresoField() { - return totalIngresoField; - } - - public JTextField getValorField() { - return valorField; - } - - public JComboBox getTipoCombo() { - return tipoCombo; - } - - public JLabel getErrorTipoIngreso() { - return errorTipoIngreso; - } - - public JLabel getErrorValor() { - 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!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - createUIComponents(); - contentPanel = new JPanel(); - contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); - final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); - contentPanel.add(panel1, 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)); - panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Ingresos")); - final JScrollPane scrollPane1 = new JScrollPane(); - 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, 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, 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, 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, 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, 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 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)); - final JPanel panel5 = new JPanel(); - panel5.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1)); - panel3.add(panel5, 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)); - guardarButton = new JButton(); - guardarButton.setText("Añadir"); - guardarButton.setMnemonic('A'); - guardarButton.setDisplayedMnemonicIndex(0); - panel5.add(guardarButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - eliminarButton = new JButton(); - eliminarButton.setText("Eliminar"); - panel5.add(eliminarButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - editarButton = new JButton(); - editarButton.setText("Editar"); - panel5.add(editarButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); - final Spacer spacer1 = new Spacer(); - panel3.add(spacer1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPanel; - } - -} diff --git a/src/main/java/danielcortes/xyz/views/ManagerView.form b/src/main/java/danielcortes/xyz/views/ManagerView.form deleted file mode 100644 index b19ef8c..0000000 --- a/src/main/java/danielcortes/xyz/views/ManagerView.form +++ /dev/null @@ -1,78 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/main/java/danielcortes/xyz/views/ManagerView.java b/src/main/java/danielcortes/xyz/views/ManagerView.java deleted file mode 100644 index a560265..0000000 --- a/src/main/java/danielcortes/xyz/views/ManagerView.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * 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.views; - -import com.github.lgooddatepicker.components.DatePicker; - -import javax.swing.*; -import java.awt.*; - -public class ManagerView { - private JToggleButton egresosButton; - private JToggleButton ingresosButton; - private JPanel contentPanel; - private JPanel cardPanel; - private JPanel controlsPanel; - private JToggleButton arqueoButton; - private DatePicker datePicker; - - public JToggleButton getEgresosButton() { - return egresosButton; - } - - public JToggleButton getIngresosButton() { - return ingresosButton; - } - - public JToggleButton getArqueoButton() { - return arqueoButton; - } - - public DatePicker getDatePicker() { - return datePicker; - } - - public JPanel getContentPanel() { - return contentPanel; - } - - public JPanel getCardPanel() { - return cardPanel; - } - - { -// GUI initializer generated by IntelliJ IDEA GUI Designer -// >>> IMPORTANT!! <<< -// DO NOT EDIT OR ADD ANY CODE HERE! - $$$setupUI$$$(); - } - - /** - * Method generated by IntelliJ IDEA GUI Designer - * >>> IMPORTANT!! <<< - * DO NOT edit this method OR call it in your code! - * - * @noinspection ALL - */ - private void $$$setupUI$$$() { - contentPanel = new JPanel(); - contentPanel.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); - cardPanel = new JPanel(); - cardPanel.setLayout(new CardLayout(0, 0)); - contentPanel.add(cardPanel, new com.intellij.uiDesigner.core.GridConstraints(1, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - controlsPanel = new JPanel(); - controlsPanel.setLayout(new com.intellij.uiDesigner.core.GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1)); - contentPanel.add(controlsPanel, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_BOTH, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - egresosButton = new JToggleButton(); - egresosButton.setText("Egresos"); - egresosButton.setMnemonic('E'); - egresosButton.setDisplayedMnemonicIndex(0); - controlsPanel.add(egresosButton, new com.intellij.uiDesigner.core.GridConstraints(0, 2, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, -1), null, 0, false)); - ingresosButton = new JToggleButton(); - ingresosButton.setText("Ingresos"); - ingresosButton.setMnemonic('I'); - ingresosButton.setDisplayedMnemonicIndex(0); - controlsPanel.add(ingresosButton, new com.intellij.uiDesigner.core.GridConstraints(0, 1, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, -1), null, 0, false)); - arqueoButton = new JToggleButton(); - arqueoButton.setText("Arqueo"); - arqueoButton.setMnemonic('A'); - arqueoButton.setDisplayedMnemonicIndex(0); - controlsPanel.add(arqueoButton, new com.intellij.uiDesigner.core.GridConstraints(0, 3, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, -1), null, 0, false)); - datePicker = new DatePicker(); - controlsPanel.add(datePicker, new com.intellij.uiDesigner.core.GridConstraints(0, 0, 1, 1, com.intellij.uiDesigner.core.GridConstraints.ANCHOR_CENTER, com.intellij.uiDesigner.core.GridConstraints.FILL_NONE, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_SHRINK | com.intellij.uiDesigner.core.GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); - ButtonGroup buttonGroup; - buttonGroup = new ButtonGroup(); - buttonGroup.add(egresosButton); - buttonGroup.add(ingresosButton); - buttonGroup.add(arqueoButton); - } - - /** - * @noinspection ALL - */ - public JComponent $$$getRootComponent$$$() { - return contentPanel; - } -} diff --git a/src/main/java/danielcortes/xyz/views/components/EgresosTableModel.java b/src/main/java/danielcortes/xyz/views/components/EgresosTableModel.java deleted file mode 100644 index 7b1403e..0000000 --- a/src/main/java/danielcortes/xyz/views/components/EgresosTableModel.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.views.components; - -import danielcortes.xyz.models.egreso.Egreso; - -import javax.swing.table.AbstractTableModel; -import java.util.ArrayList; - -public class EgresosTableModel extends AbstractTableModel { - private String[] columns; - private ArrayList rows; - - public EgresosTableModel(){ - super(); - this.columns = new String[]{"N°", "Descripcion", "Valor", "Tipo"}; - this.rows = new ArrayList<>(); - } - - public String getColumnName(int col) { - return columns[col]; - } - - public int getColumnCount() { - return columns.length; - } - - public int getRowCount() { - return rows.size(); - } - - public void addRow(Egreso egreso) { - rows.add(egreso); - this.fireTableRowsInserted(getRowCount()-1, getRowCount()-1); - - } - - public void removeRow(int row){ - this.rows.remove(row); - this.fireTableRowsDeleted(row,row); - } - - public void removeRows(){ - int rowCount = getRowCount(); - if(rowCount > 0){ - this.rows.clear(); - this.fireTableRowsDeleted(0, rowCount-1); - } - } - - public void setEgreso(int editingId, Egreso egreso) { - this.rows.set(editingId, egreso); - this.fireTableRowsUpdated(0,getRowCount()-1); - } - - public Object getValueAt(int row, int col) { - switch (col){ - case 0: - return rows.get(row).getNro(); - case 1: - return rows.get(row).getDescripcion(); - case 2: - return rows.get(row).getValor(); - case 3: - return rows.get(row).getTipoEgreso(); - } - return null; - } - - public Egreso getEgreso(int row){ - return rows.get(row); - } - -} diff --git a/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java b/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java deleted file mode 100644 index e7d4aaa..0000000 --- a/src/main/java/danielcortes/xyz/views/components/IngresosTableModel.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.views.components; - -import danielcortes.xyz.models.ingreso.Ingreso; - -import javax.swing.table.AbstractTableModel; -import java.util.ArrayList; - -public class IngresosTableModel extends AbstractTableModel { - private String[] columns; - private ArrayList rows; - - public IngresosTableModel() { - super(); - this.columns = new String[]{"Valor", "N° Inicial", "N° Final", "Tipo"}; - this.rows = new ArrayList<>(); - } - - public String getColumnName(int col) { - return this.columns[col]; - } - - public int getColumnCount() { - return this.columns.length; - } - - public int getRowCount() { - return this.rows.size(); - } - - public void addRow(Ingreso ingreso) { - this.rows.add(ingreso); - this.fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1); - } - - public void removeRow(int row) { - this.rows.remove(row); - this.fireTableRowsDeleted(row, row); - } - - public void removeRows() { - int rowCount = getRowCount(); - if (rowCount > 0) { - this.rows.clear(); - this.fireTableRowsDeleted(0, rowCount - 1); - } - } - - public Object getValueAt(int row, int col) { - switch (col) { - case 0: - 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) { - return this.rows.get(row); - } - - public void setIngreso(int editingId, Ingreso ingreso) { - this.rows.set(editingId, ingreso); - this.fireTableRowsUpdated(getRowCount() - 2, getRowCount() - 1); - } -} diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF deleted file mode 100644 index 847ee37..0000000 --- a/src/main/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: danielcortes.xyz.Main -