diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1fcb152
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+out
diff --git a/.idea/artifacts/caja_jar.xml b/.idea/artifacts/caja_jar.xml
new file mode 100644
index 0000000..c6568d6
--- /dev/null
+++ b/.idea/artifacts/caja_jar.xml
@@ -0,0 +1,14 @@
+
+
+ $PROJECT_DIR$/out/artifacts/caja_jar
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..5fe4380
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/MIT_License.xml b/.idea/copyright/MIT_License.xml
new file mode 100644
index 0000000..0e326f2
--- /dev/null
+++ b/.idea/copyright/MIT_License.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..9784701
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml
new file mode 100644
index 0000000..30bcf4f
--- /dev/null
+++ b/.idea/dataSources.local.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+ #@
+ `
+
+
+ master_key
+ root
+ *:@
+
+
+
+ "
+
+
+ master_key
+ false
+ *:@
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..7f27263
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,28 @@
+
+
+
+
+ mariadb
+ true
+ org.mariadb.jdbc.Driver
+ jdbc:mariadb://localhost:3306/caja
+
+
+
+
+
+
+
+
+
+
+ sqlite.xerial
+ true
+ org.sqlite.JDBC
+ jdbc:sqlite:$PROJECT_DIR$/database.sqlite
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources/6e2ee496-6ca2-4cc4-a2b0-4f122e6bfd50.xml b/.idea/dataSources/6e2ee496-6ca2-4cc4-a2b0-4f122e6bfd50.xml
new file mode 100644
index 0000000..f1eea48
--- /dev/null
+++ b/.idea/dataSources/6e2ee496-6ca2-4cc4-a2b0-4f122e6bfd50.xml
@@ -0,0 +1,273 @@
+
+
+
+
+ 3.25.1
+
+
+ 1
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ integer|0s
+
+
+ 2
+ date|0s
+ 1
+
+
+ id
+ 1
+
+
+ 1
+ integer|0s
+
+
+ 2
+ integer|0s
+ 1
+
+
+ 3
+ integer|0s
+ 1
+
+
+ 4
+ integer|0s
+ 1
+
+
+ id
+ 1
+
+
+ caja_id
+ caja
+ id
+ restrict
+ cascade
+
+
+ 1
+ integer|0s
+
+
+ 2
+ integer|0s
+ 1
+
+
+ 3
+ integer|0s
+ 1
+
+
+ 4
+ integer|0s
+ 1
+
+
+ 5
+ integer|0s
+ 1
+
+
+ 6
+ integer|0s
+ 1
+
+
+ 7
+ integer|0s
+ 1
+
+
+ 8
+ integer|0s
+ 1
+
+
+ 9
+ integer|0s
+ 1
+
+
+ 10
+ integer|0s
+ 1
+
+
+ 11
+ integer|0s
+ 1
+
+
+ id
+ 1
+
+
+ caja_id
+ caja
+ id
+ restrict
+ cascade
+
+
+ 1
+ integer|0s
+
+
+ 2
+ text|0s
+ 1
+
+
+ 3
+ text|0s
+ 1
+
+
+ 4
+ integer|0s
+ 1
+
+
+ 5
+ integer|0s
+ 1
+
+
+ 6
+ integer|0s
+ 1
+
+
+ id
+ 1
+
+
+ tipo_egreso_id
+ tipos_egreso
+ id
+ restrict
+ cascade
+
+
+ caja_id
+ caja
+ id
+ restrict
+ cascade
+
+
+ 1
+ integer|0s
+
+
+ 2
+ integer|0s
+ 1
+
+
+ 3
+ text|0s
+ 1
+
+
+ 4
+ text|0s
+ 1
+
+
+ 5
+ integer unsigned|0s
+ 1
+
+
+ 6
+ integer unsigned|0s
+ 1
+
+
+ id
+ 1
+
+
+ tipo_ingreso_id
+ tipos_ingreso
+ id
+ restrict
+ cascade
+
+
+ caja_id
+ caja
+ id
+ restrict
+ cascade
+
+
+ 1
+ text|0s
+
+
+ 2
+ text|0s
+
+
+ 3
+ text|0s
+
+
+ 4
+ int|0s
+
+
+ 5
+ text|0s
+
+
+ 1
+ integer|0s
+
+
+ 2
+ text|0s
+ 1
+
+
+ id
+ 1
+
+
+ 1
+ integer|0s
+
+
+ 2
+ text|0s
+ 1
+
+
+ id
+ 1
+
+
+
\ No newline at end of file
diff --git a/.idea/dataSources/6e2ee496-6ca2-4cc4-a2b0-4f122e6bfd50/storage_v2/_src_/schema/main.uQUzAA.meta b/.idea/dataSources/6e2ee496-6ca2-4cc4-a2b0-4f122e6bfd50/storage_v2/_src_/schema/main.uQUzAA.meta
new file mode 100644
index 0000000..8dab49c
--- /dev/null
+++ b/.idea/dataSources/6e2ee496-6ca2-4cc4-a2b0-4f122e6bfd50/storage_v2/_src_/schema/main.uQUzAA.meta
@@ -0,0 +1,2 @@
+#n:main
+! [0, 0, null, null, -2147483648, -2147483648]
diff --git a/.idea/dataSources/ddc47f43-aee6-477e-9abc-9a07c78c8f9d.xml b/.idea/dataSources/ddc47f43-aee6-477e-9abc-9a07c78c8f9d.xml
new file mode 100644
index 0000000..56d1349
--- /dev/null
+++ b/.idea/dataSources/ddc47f43-aee6-477e-9abc-9a07c78c8f9d.xml
@@ -0,0 +1,1274 @@
+
+
+
+
+ 10.1.37
+ MARIADB
+ InnoDB
+ exact
+
+
+ 1
+ 1
+ utf8mb4_unicode_ci
+
+
+ utf8_general_ci
+
+
+ utf8mb4_unicode_ci
+
+
+ utf8_general_ci
+
+
+ armscii8
+ 0
+
+
+ armscii8
+ 1
+
+
+ ascii
+ 0
+
+
+ ascii
+ 1
+
+
+ big5
+ 0
+
+
+ big5
+ 1
+
+
+ binary
+ 1
+
+
+ cp1250
+ 0
+
+
+ cp1250
+ 0
+
+
+ cp1250
+ 0
+
+
+ cp1250
+ 1
+
+
+ cp1250
+ 0
+
+
+ cp1251
+ 0
+
+
+ cp1251
+ 0
+
+
+ cp1251
+ 1
+
+
+ cp1251
+ 0
+
+
+ cp1251
+ 0
+
+
+ cp1256
+ 0
+
+
+ cp1256
+ 1
+
+
+ cp1257
+ 0
+
+
+ cp1257
+ 1
+
+
+ cp1257
+ 0
+
+
+ cp850
+ 0
+
+
+ cp850
+ 1
+
+
+ cp852
+ 0
+
+
+ cp852
+ 1
+
+
+ cp866
+ 0
+
+
+ cp866
+ 1
+
+
+ cp932
+ 0
+
+
+ cp932
+ 1
+
+
+ dec8
+ 0
+
+
+ dec8
+ 1
+
+
+ eucjpms
+ 0
+
+
+ eucjpms
+ 1
+
+
+ euckr
+ 0
+
+
+ euckr
+ 1
+
+
+ gb2312
+ 0
+
+
+ gb2312
+ 1
+
+
+ gbk
+ 0
+
+
+ gbk
+ 1
+
+
+ geostd8
+ 0
+
+
+ geostd8
+ 1
+
+
+ greek
+ 0
+
+
+ greek
+ 1
+
+
+ hebrew
+ 0
+
+
+ hebrew
+ 1
+
+
+ hp8
+ 0
+
+
+ hp8
+ 1
+
+
+ keybcs2
+ 0
+
+
+ keybcs2
+ 1
+
+
+ koi8r
+ 0
+
+
+ koi8r
+ 1
+
+
+ koi8u
+ 0
+
+
+ koi8u
+ 1
+
+
+ latin1
+ 0
+
+
+ latin1
+ 0
+
+
+ latin1
+ 0
+
+
+ latin1
+ 0
+
+
+ latin1
+ 0
+
+
+ latin1
+ 0
+
+
+ latin1
+ 0
+
+
+ latin1
+ 1
+
+
+ latin2
+ 0
+
+
+ latin2
+ 0
+
+
+ latin2
+ 0
+
+
+ latin2
+ 1
+
+
+ latin2
+ 0
+
+
+ latin5
+ 0
+
+
+ latin5
+ 1
+
+
+ latin7
+ 0
+
+
+ latin7
+ 0
+
+
+ latin7
+ 1
+
+
+ latin7
+ 0
+
+
+ macce
+ 0
+
+
+ macce
+ 1
+
+
+ macroman
+ 0
+
+
+ macroman
+ 1
+
+
+ sjis
+ 0
+
+
+ sjis
+ 1
+
+
+ swe7
+ 0
+
+
+ swe7
+ 1
+
+
+ tis620
+ 0
+
+
+ tis620
+ 1
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 1
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ucs2
+ 0
+
+
+ ujis
+ 0
+
+
+ ujis
+ 1
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 1
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16
+ 0
+
+
+ utf16le
+ 0
+
+
+ utf16le
+ 1
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 1
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf32
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 1
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 1
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+ utf8mb4
+ 0
+
+
+
+
+
+
+
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ date|0s
+ 1
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ int(10)|0s
+ 1
+ normal
+
+
+ 3
+ int(10)|0s
+ 1
+ normal
+
+
+ 4
+ int(10) unsigned|0s
+ 1
+ normal
+
+
+ caja_id
+ btree
+
+
+ 1
+ id
+ 1
+
+
+ caja_id
+ caja
+ caja
+ id
+ cascade
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ int(10)|0s
+ 1
+ normal
+
+
+ 3
+ int(10)|0s
+ 1
+ normal
+
+
+ 4
+ int(10)|0s
+ 1
+ normal
+
+
+ 5
+ int(10)|0s
+ 1
+ normal
+
+
+ 6
+ int(10)|0s
+ 1
+ normal
+
+
+ 7
+ int(10)|0s
+ 1
+ normal
+
+
+ 8
+ int(10)|0s
+ 1
+ normal
+
+
+ 9
+ int(10)|0s
+ 1
+ normal
+
+
+ 10
+ int(10)|0s
+ 1
+ normal
+
+
+ 11
+ int(10) unsigned|0s
+ 1
+ normal
+
+
+ caja_id
+ btree
+
+
+ 1
+ id
+ 1
+
+
+ caja_id
+ caja
+ caja
+ id
+ cascade
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ varchar(191)|0s
+ 1
+ normal
+
+
+ 3
+ varchar(191)|0s
+ 1
+ normal
+
+
+ 4
+ int(10)|0s
+ 1
+ normal
+
+
+ 5
+ int(10) unsigned|0s
+ 1
+ normal
+
+
+ 6
+ int(10) unsigned|0s
+ 1
+ normal
+
+
+ tipo_egreso_id
+ btree
+
+
+ caja_id
+ btree
+
+
+ 1
+ id
+ 1
+
+
+ tipo_egreso_id
+ caja
+ tipos_egreso
+ id
+ cascade
+
+
+ caja_id
+ caja
+ caja
+ id
+ cascade
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ int(10)|0s
+ 1
+ normal
+
+
+ 3
+ varchar(191)|0s
+ 1
+ normal
+
+
+ 4
+ varchar(191)|0s
+ 1
+ normal
+
+
+ 5
+ int(10) unsigned|0s
+ 1
+ normal
+
+
+ 6
+ int(10) unsigned|0s
+ 1
+ normal
+
+
+ tipo_ingreso_id
+ btree
+
+
+ caja_id
+ btree
+
+
+ 1
+ id
+ 1
+
+
+ tipo_ingreso_id
+ caja
+ tipos_ingreso
+ id
+ cascade
+
+
+ caja_id
+ caja
+ caja
+ id
+ cascade
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ varchar(191)|0s
+ 1
+ normal
+
+
+ 1
+ id
+ 1
+
+
+ 1
+ int(10) unsigned|0s
+ 1
+ 1
+ normal
+
+
+ 2
+ varchar(191)|0s
+ 1
+ normal
+
+
+ 1
+ id
+ 1
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..15a15b2
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..cdcdeae
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_github_lgooddatepicker_LGoodDatePicker_10_3_1.xml b/.idea/libraries/Maven__com_github_lgooddatepicker_LGoodDatePicker_10_3_1.xml
new file mode 100644
index 0000000..a347379
--- /dev/null
+++ b/.idea/libraries/Maven__com_github_lgooddatepicker_LGoodDatePicker_10_3_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
new file mode 100644
index 0000000..2888f96
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml b/.idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml
new file mode 100644
index 0000000..233670d
--- /dev/null
+++ b/.idea/libraries/Maven__com_google_protobuf_protobuf_java_3_6_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_13.xml b/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_13.xml
new file mode 100644
index 0000000..fc36ef0
--- /dev/null
+++ b/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_xerial_sqlite_jdbc_3_25_2.xml b/.idea/libraries/Maven__org_xerial_sqlite_jdbc_3_25_2.xml
new file mode 100644
index 0000000..f794335
--- /dev/null
+++ b/.idea/libraries/Maven__org_xerial_sqlite_jdbc_3_25_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..90047c1
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..131a464
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/src_files.xml b/.idea/scopes/src_files.xml
new file mode 100644
index 0000000..60b9e5e
--- /dev/null
+++ b/.idea/scopes/src_files.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
new file mode 100644
index 0000000..9a78b55
--- /dev/null
+++ b/.idea/sqldialects.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..cf5a3b1
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,135 @@
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..f71c2eb
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,1030 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getValueAt
+ getColumn
+ select
+ addRow
+ set
+ print
+ "
+ fec
+ System
+ [2018] [Daniel Cortes]
+ id
+ index
+ tipo_id
+ getEliminarB
+ onSelec
+ timezone
+ efect
+ from efectivo
+ caj
+ remove
+ error
+ arqueo
+ System.out.prin
+ varchar(191)
+ int(10) unsigned primary key auto_increment
+ unsigned
+ DAO
+ mysql
+
+
+ 2018 Daniel Cortes
+ '
+ tipo_egreso_id
+ from efectivos
+ text
+ integer primary key
+
+
+ $PROJECT_DIR$/src
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1544977370170
+
+
+ 1544977370170
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1545280618093
+
+
+
+ 1545280618093
+
+
+ 1545283447719
+
+
+
+ 1545283447719
+
+
+ 1545321626516
+
+
+
+ 1545321626516
+
+
+ 1545358591232
+
+
+
+ 1545358591232
+
+
+ 1545361072926
+
+
+
+ 1545361072926
+
+
+ 1545420806001
+
+
+
+ 1545420806001
+
+
+ 1545694977931
+
+
+
+ 1545694977931
+
+
+ 1545699519326
+
+
+
+ 1545699519326
+
+
+ 1545700181648
+
+
+
+ 1545700181649
+
+
+ 1545933642274
+
+
+
+ 1545933642275
+
+
+ 1545944134525
+
+
+
+ 1545944134525
+
+
+ 1545961761749
+
+
+
+ 1545961761749
+
+
+ 1545972598937
+
+
+
+ 1545972598937
+
+
+ 1545972906204
+
+
+
+ 1545972906204
+
+
+ 1545974148415
+
+
+
+ 1545974148415
+
+
+ 1545982355969
+
+
+
+ 1545982355969
+
+
+ 1546024676996
+
+
+
+ 1546024676996
+
+
+ 1546032195766
+
+
+
+ 1546032195766
+
+
+ 1546042331362
+
+
+
+ 1546042331363
+
+
+ 1546045462880
+
+
+
+ 1546045462880
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ JAVA
+ danielcortes.xyz
+
+ danielcortes.xyz.views.components.EgresosTableModel
+ danielcortes.xyz.controllers.IngresosController
+ danielcortes.xyz.models.documentos.DocumentosDAO
+ danielcortes.xyz.models.caja.MysqlCajaDAO
+ danielcortes.xyz.models.caja.Caja
+ danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO
+ danielcortes.xyz.models.efectivo.EfectivoDAO
+ danielcortes.xyz.data.Properties
+ danielcortes.xyz.models.tipo_egreso.TipoEgreso
+ danielcortes.xyz.models.ingreso.MysqlIngresoDAO
+ danielcortes.xyz.models.efectivo.MysqlEfectivoDAO
+ danielcortes.xyz.views.IngresosView
+ danielcortes.xyz.models.caja.SQLiteCajaDAO
+ danielcortes.xyz.models.ingreso.IngresoDAO
+ danielcortes.xyz.models.documentos.Documentos
+ danielcortes.xyz.controllers.ManagerController
+ danielcortes.xyz.models.efectivo.Efectivo
+ danielcortes.xyz.controllers.ArqueoController
+ danielcortes.xyz.models.documentos.SQLiteDocumentosDAO
+ danielcortes.xyz.models.egreso.MysqlEgresoDAO
+ danielcortes.xyz.data.MysqlConnectionHolder
+ danielcortes.xyz.models.egreso.SQLiteEgresoDAO
+ danielcortes.xyz.data.SQLiteConnectionHolder
+ danielcortes.xyz.Main
+ danielcortes.xyz.models.tipo_ingreso.SQLiteTipoIngresoDAO
+ danielcortes.xyz.models.tipo_egreso.MysqlTipoEgresoDAO
+ danielcortes.xyz.models.egreso.Egreso
+ danielcortes.xyz.models.ingreso.Ingreso
+ danielcortes.xyz.models.egreso.EgresoDAO
+ danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO
+ danielcortes.xyz.controllers.EgresosController
+ danielcortes.xyz.views.ArqueoView
+ danielcortes.xyz.models.caja.CajaDAO
+ danielcortes.xyz.models.ingreso.SQLiteIngresoDAO
+ danielcortes.xyz.models.tipo_egreso.SQLiteTipoEgresoDAO
+ danielcortes.xyz.views.EgresosView
+ danielcortes.xyz.views.ManagerView
+ danielcortes.xyz.models.tipo_ingreso.TipoIngreso
+ danielcortes.xyz.data.ConnectionHolder
+ danielcortes.xyz.models.documentos.MysqlDocumentosDAO
+ danielcortes.xyz.views.components.IngresosTableModel
+ danielcortes.xyz.models.tipo_ingreso.MysqlTipoIngresoDAO
+ danielcortes.xyz.models.efectivo.SQLiteEfectivoDAO
+
+
+
+
+
+
+ All
+ private
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ caja:jar
+
+
+
+
+
+
+
+
+
+
+
+
+ MIT License
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 11
+
+
+
+
+
+
+
+
+
+
+
+ caja
+
+
+
+
+
+
+
+
+
+
+
+
+ Maven: org.xerial:sqlite-jdbc:3.25.2
+
+
+
+
+
+
+
+
+
+
+
+ src files
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/caja.iml b/caja.iml
new file mode 100644
index 0000000..f4cdada
--- /dev/null
+++ b/caja.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/conf.properties b/conf.properties
new file mode 100644
index 0000000..964acc3
--- /dev/null
+++ b/conf.properties
@@ -0,0 +1,25 @@
+# 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
new file mode 100644
index 0000000..e2c169d
Binary files /dev/null and b/database.sqlite differ
diff --git a/database/mysql.sql b/database/mysql.sql
new file mode 100644
index 0000000..8363e76
--- /dev/null
+++ b/database/mysql.sql
@@ -0,0 +1,119 @@
+/*
+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.
+*/
+
+drop table if exists egresos;
+drop table if exists tipos_egreso;
+drop table if exists ingresos;
+drop table if exists tipos_ingreso;
+drop table if exists efectivos;
+drop table if exists documentos;
+drop table if exists caja;
+
+create table caja
+(
+ id int(10) unsigned primary key auto_increment,
+ fecha date not null
+);
+
+create table tipos_egreso
+(
+ id int(10) unsigned primary key auto_increment,
+ nombre varchar(191) not null
+);
+
+create table egresos
+(
+ id int(10) unsigned primary key auto_increment,
+ nro varchar(191) not null,
+ descripcion varchar(191) not null,
+ valor int(10) not null,
+ tipo_egreso_id int(10) unsigned not null,
+ caja_id int(10) unsigned not null,
+ foreign key fk_egresos_tipo_egreso (tipo_egreso_id) references tipos_egreso (id) on update cascade on delete restrict,
+ foreign key fk_egresos_caja (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+create table tipos_ingreso
+(
+ id int(10) unsigned primary key auto_increment,
+ nombre varchar(191) not null
+);
+
+create table ingresos
+(
+ id int(10) unsigned primary key auto_increment,
+ valor int(10) not null,
+ nro_inicial varchar(191) not null,
+ nro_final varchar(191) not null,
+ tipo_ingreso_id int(10) unsigned not null,
+ caja_id int(10) unsigned not null,
+ foreign key fk_tipo_ingreso (tipo_ingreso_id) references tipos_ingreso (id) on update cascade on delete restrict,
+ foreign key fk_ingresos_caja (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+create table efectivos
+(
+ id int(10) unsigned primary key auto_increment,
+ veinte_mil int(10) not null,
+ diez_mil int(10) not null,
+ cinco_mil int(10) not null,
+ dos_mil int(10) not null,
+ mil int(10) not null,
+ quinientos int(10) not null,
+ cien int(10) not null,
+ cincuenta int(10) not null,
+ diez int(10) not null,
+ caja_id int(10) unsigned not null,
+ foreign key fk_efectivos_caja (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+create table documentos
+(
+ id int(10) unsigned primary key auto_increment,
+ cheques int(10) not null,
+ tarjetas int(10) not null,
+ caja_id int(10) unsigned not null,
+ foreign key fk_documentos_caja (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+
+insert into tipos_egreso (nombre)
+values ('Factura Materia Prima'),
+ ('Factura Gastos Generales'),
+ ('Gasto Menor Materia Prima'),
+ ('Gasto General Sin Respaldo'),
+ ('Gasto General Con Boleta'),
+ ('Guia Materia Prima'),
+ ('Anticipo Arriendo'),
+ ('Anticipo Personal'),
+ ('Pago Partime'),
+ ('Retiros Gerencia'),
+ ('Otro');
+
+insert into tipos_ingreso (nombre)
+values ('Boletas Fiscales'),
+ ('Boletas Manuales'),
+ ('Facturas'),
+ ('Guias')
+
diff --git a/database/sqlite.sql b/database/sqlite.sql
new file mode 100644
index 0000000..2f09574
--- /dev/null
+++ b/database/sqlite.sql
@@ -0,0 +1,120 @@
+/*
+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.
+*/
+pragma foreign_keys = ON;
+
+drop table if exists egresos;
+drop table if exists tipos_egreso;
+drop table if exists ingresos;
+drop table if exists tipos_ingreso;
+drop table if exists efectivos;
+drop table if exists documentos;
+drop table if exists caja;
+
+create table caja
+(
+ id integer primary key,
+ fecha date not null
+);
+
+create table tipos_egreso
+(
+ id integer primary key,
+ nombre text not null
+);
+
+create table egresos
+(
+ id integer primary key,
+ nro text not null,
+ descripcion text not null,
+ valor integer not null,
+ tipo_egreso_id integer not null,
+ caja_id integer not null,
+ foreign key (tipo_egreso_id) references tipos_egreso (id) on update cascade on delete restrict,
+ foreign key (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+create table tipos_ingreso
+(
+ id integer primary key,
+ nombre text not null
+);
+
+create table ingresos
+(
+ id integer primary key,
+ valor integer not null,
+ nro_inicial text not null,
+ nro_final text not null,
+ tipo_ingreso_id integer unsigned not null,
+ caja_id integer unsigned not null,
+ foreign key (tipo_ingreso_id) references tipos_ingreso (id) on update cascade on delete restrict,
+ foreign key (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+create table efectivos
+(
+ id integer primary key,
+ veinte_mil integer not null,
+ diez_mil integer not null,
+ cinco_mil integer not null,
+ dos_mil integer not null,
+ mil integer not null,
+ quinientos integer not null,
+ cien integer not null,
+ cincuenta integer not null,
+ diez integer not null,
+ caja_id integer not null,
+ foreign key (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+create table documentos
+(
+ id integer primary key,
+ cheques integer not null,
+ tarjetas integer not null,
+ caja_id integer not null,
+ foreign key (caja_id) references caja (id) on update cascade on delete restrict
+);
+
+
+insert into tipos_egreso (nombre)
+values ('Factura Materia Prima'),
+ ('Factura Gastos Generales'),
+ ('Gasto Menor Materia Prima'),
+ ('Gasto General Sin Respaldo'),
+ ('Gasto General Con Boleta'),
+ ('Guia Materia Prima'),
+ ('Anticipo Arriendo'),
+ ('Anticipo Personal'),
+ ('Pago Partime'),
+ ('Retiros Gerencia'),
+ ('Otro');
+
+insert into tipos_ingreso (nombre)
+values ('Boletas Fiscales'),
+ ('Boletas Manuales'),
+ ('Facturas'),
+ ('Guias')
+
diff --git a/lib/LGoodDatePicker-10.3.1-javadoc.jar b/lib/LGoodDatePicker-10.3.1-javadoc.jar
new file mode 100644
index 0000000..caa74c1
Binary files /dev/null and b/lib/LGoodDatePicker-10.3.1-javadoc.jar differ
diff --git a/lib/LGoodDatePicker-10.3.1-sources.jar b/lib/LGoodDatePicker-10.3.1-sources.jar
new file mode 100644
index 0000000..94e41c6
Binary files /dev/null and b/lib/LGoodDatePicker-10.3.1-sources.jar differ
diff --git a/lib/LGoodDatePicker-10.3.1.jar b/lib/LGoodDatePicker-10.3.1.jar
new file mode 100644
index 0000000..79bb360
Binary files /dev/null and b/lib/LGoodDatePicker-10.3.1.jar differ
diff --git a/lib/gson-2.8.5-javadoc.jar b/lib/gson-2.8.5-javadoc.jar
new file mode 100644
index 0000000..e74a1d2
Binary files /dev/null and b/lib/gson-2.8.5-javadoc.jar differ
diff --git a/lib/gson-2.8.5-sources.jar b/lib/gson-2.8.5-sources.jar
new file mode 100644
index 0000000..a64f4e7
Binary files /dev/null and b/lib/gson-2.8.5-sources.jar differ
diff --git a/lib/gson-2.8.5.jar b/lib/gson-2.8.5.jar
new file mode 100644
index 0000000..0d5baf3
Binary files /dev/null and b/lib/gson-2.8.5.jar differ
diff --git a/lib/mysql-connector-java-8.0.13-sources.jar b/lib/mysql-connector-java-8.0.13-sources.jar
new file mode 100644
index 0000000..aed2eda
Binary files /dev/null and b/lib/mysql-connector-java-8.0.13-sources.jar differ
diff --git a/lib/mysql-connector-java-8.0.13.jar b/lib/mysql-connector-java-8.0.13.jar
new file mode 100644
index 0000000..a4efaf5
Binary files /dev/null and b/lib/mysql-connector-java-8.0.13.jar differ
diff --git a/lib/protobuf-java-3.6.1-javadoc.jar b/lib/protobuf-java-3.6.1-javadoc.jar
new file mode 100644
index 0000000..a2893ca
Binary files /dev/null and b/lib/protobuf-java-3.6.1-javadoc.jar differ
diff --git a/lib/protobuf-java-3.6.1-sources.jar b/lib/protobuf-java-3.6.1-sources.jar
new file mode 100644
index 0000000..c106429
Binary files /dev/null and b/lib/protobuf-java-3.6.1-sources.jar differ
diff --git a/lib/protobuf-java-3.6.1.jar b/lib/protobuf-java-3.6.1.jar
new file mode 100644
index 0000000..8a18789
Binary files /dev/null and b/lib/protobuf-java-3.6.1.jar differ
diff --git a/lib/sqlite-jdbc-3.25.2-javadoc.jar b/lib/sqlite-jdbc-3.25.2-javadoc.jar
new file mode 100644
index 0000000..d8926cb
Binary files /dev/null and b/lib/sqlite-jdbc-3.25.2-javadoc.jar differ
diff --git a/lib/sqlite-jdbc-3.25.2-sources.jar b/lib/sqlite-jdbc-3.25.2-sources.jar
new file mode 100644
index 0000000..405340a
Binary files /dev/null and b/lib/sqlite-jdbc-3.25.2-sources.jar differ
diff --git a/lib/sqlite-jdbc-3.25.2.jar b/lib/sqlite-jdbc-3.25.2.jar
new file mode 100644
index 0000000..abec989
Binary files /dev/null and b/lib/sqlite-jdbc-3.25.2.jar differ
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..847ee37
--- /dev/null
+++ b/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: danielcortes.xyz.Main
+
diff --git a/src/danielcortes/xyz/Main.java b/src/danielcortes/xyz/Main.java
new file mode 100644
index 0000000..e73d710
--- /dev/null
+++ b/src/danielcortes/xyz/Main.java
@@ -0,0 +1,108 @@
+/*
+ * 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/danielcortes/xyz/controllers/ArqueoController.java b/src/danielcortes/xyz/controllers/ArqueoController.java
new file mode 100644
index 0000000..66db471
--- /dev/null
+++ b/src/danielcortes/xyz/controllers/ArqueoController.java
@@ -0,0 +1,324 @@
+/*
+ * 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/danielcortes/xyz/controllers/EgresosController.java b/src/danielcortes/xyz/controllers/EgresosController.java
new file mode 100644
index 0000000..797c5f5
--- /dev/null
+++ b/src/danielcortes/xyz/controllers/EgresosController.java
@@ -0,0 +1,319 @@
+/*
+ * 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/danielcortes/xyz/controllers/IngresosController.java b/src/danielcortes/xyz/controllers/IngresosController.java
new file mode 100644
index 0000000..181aa44
--- /dev/null
+++ b/src/danielcortes/xyz/controllers/IngresosController.java
@@ -0,0 +1,321 @@
+/*
+ * 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/danielcortes/xyz/controllers/ManagerController.java b/src/danielcortes/xyz/controllers/ManagerController.java
new file mode 100644
index 0000000..e00feff
--- /dev/null
+++ b/src/danielcortes/xyz/controllers/ManagerController.java
@@ -0,0 +1,163 @@
+/*
+ * 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/danielcortes/xyz/data/ConnectionHolder.java b/src/danielcortes/xyz/data/ConnectionHolder.java
new file mode 100644
index 0000000..8cbdec2
--- /dev/null
+++ b/src/danielcortes/xyz/data/ConnectionHolder.java
@@ -0,0 +1,31 @@
+/*
+ * 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/danielcortes/xyz/data/MysqlConnectionHolder.java b/src/danielcortes/xyz/data/MysqlConnectionHolder.java
new file mode 100644
index 0000000..caccf5f
--- /dev/null
+++ b/src/danielcortes/xyz/data/MysqlConnectionHolder.java
@@ -0,0 +1,38 @@
+/*
+ * 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/danielcortes/xyz/data/Properties.java b/src/danielcortes/xyz/data/Properties.java
new file mode 100644
index 0000000..aa0127e
--- /dev/null
+++ b/src/danielcortes/xyz/data/Properties.java
@@ -0,0 +1,52 @@
+/*
+ * 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/danielcortes/xyz/data/SQLiteConnectionHolder.java b/src/danielcortes/xyz/data/SQLiteConnectionHolder.java
new file mode 100644
index 0000000..d502961
--- /dev/null
+++ b/src/danielcortes/xyz/data/SQLiteConnectionHolder.java
@@ -0,0 +1,45 @@
+/*
+ * 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/danielcortes/xyz/models/caja/Caja.java b/src/danielcortes/xyz/models/caja/Caja.java
new file mode 100644
index 0000000..f3b1442
--- /dev/null
+++ b/src/danielcortes/xyz/models/caja/Caja.java
@@ -0,0 +1,48 @@
+/*
+ * 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/danielcortes/xyz/models/caja/CajaDAO.java b/src/danielcortes/xyz/models/caja/CajaDAO.java
new file mode 100644
index 0000000..796bbf5
--- /dev/null
+++ b/src/danielcortes/xyz/models/caja/CajaDAO.java
@@ -0,0 +1,55 @@
+/*
+ * 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/danielcortes/xyz/models/caja/MysqlCajaDAO.java b/src/danielcortes/xyz/models/caja/MysqlCajaDAO.java
new file mode 100644
index 0000000..7e3ca82
--- /dev/null
+++ b/src/danielcortes/xyz/models/caja/MysqlCajaDAO.java
@@ -0,0 +1,152 @@
+/*
+ * 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/danielcortes/xyz/models/caja/SQLiteCajaDAO.java b/src/danielcortes/xyz/models/caja/SQLiteCajaDAO.java
new file mode 100644
index 0000000..54a43c6
--- /dev/null
+++ b/src/danielcortes/xyz/models/caja/SQLiteCajaDAO.java
@@ -0,0 +1,155 @@
+/*
+ * 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/danielcortes/xyz/models/documentos/Documentos.java b/src/danielcortes/xyz/models/documentos/Documentos.java
new file mode 100644
index 0000000..f0bb1b7
--- /dev/null
+++ b/src/danielcortes/xyz/models/documentos/Documentos.java
@@ -0,0 +1,66 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.documentos;
+
+import danielcortes.xyz.models.caja.Caja;
+
+public class Documentos {
+ private int id;
+ private int cheques;
+ private int tarjetas;
+ private Caja caja;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getCheques() {
+ return cheques;
+ }
+
+ public void setCheques(int cheques) {
+ this.cheques = cheques;
+ }
+
+ public int getTarjetas() {
+ return tarjetas;
+ }
+
+ public void setTarjetas(int tarjetas) {
+ this.tarjetas = tarjetas;
+ }
+
+ public Caja getCaja() {
+ return caja;
+ }
+
+ public void setCaja(Caja caja) {
+ this.caja = caja;
+ }
+}
diff --git a/src/danielcortes/xyz/models/documentos/DocumentosDAO.java b/src/danielcortes/xyz/models/documentos/DocumentosDAO.java
new file mode 100644
index 0000000..2186221
--- /dev/null
+++ b/src/danielcortes/xyz/models/documentos/DocumentosDAO.java
@@ -0,0 +1,66 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2018 Daniel Cortes
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package danielcortes.xyz.models.documentos;
+
+import danielcortes.xyz.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/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java b/src/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java
new file mode 100644
index 0000000..781bee5
--- /dev/null
+++ b/src/danielcortes/xyz/models/documentos/MysqlDocumentosDAO.java
@@ -0,0 +1,206 @@
+/*
+ * 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/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java b/src/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java
new file mode 100644
index 0000000..06d7dd6
--- /dev/null
+++ b/src/danielcortes/xyz/models/documentos/SQLiteDocumentosDAO.java
@@ -0,0 +1,205 @@
+/*
+ * 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/danielcortes/xyz/models/efectivo/Efectivo.java b/src/danielcortes/xyz/models/efectivo/Efectivo.java
new file mode 100644
index 0000000..6261226
--- /dev/null
+++ b/src/danielcortes/xyz/models/efectivo/Efectivo.java
@@ -0,0 +1,129 @@
+/*
+ * 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/danielcortes/xyz/models/efectivo/EfectivoDAO.java b/src/danielcortes/xyz/models/efectivo/EfectivoDAO.java
new file mode 100644
index 0000000..ccc9ffd
--- /dev/null
+++ b/src/danielcortes/xyz/models/efectivo/EfectivoDAO.java
@@ -0,0 +1,73 @@
+/*
+ * 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/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java b/src/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java
new file mode 100644
index 0000000..312a890
--- /dev/null
+++ b/src/danielcortes/xyz/models/efectivo/MysqlEfectivoDAO.java
@@ -0,0 +1,218 @@
+/*
+ * 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/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java b/src/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java
new file mode 100644
index 0000000..4cd9f29
--- /dev/null
+++ b/src/danielcortes/xyz/models/efectivo/SQLiteEfectivoDAO.java
@@ -0,0 +1,218 @@
+/*
+ * 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/danielcortes/xyz/models/egreso/Egreso.java b/src/danielcortes/xyz/models/egreso/Egreso.java
new file mode 100644
index 0000000..7a7e514
--- /dev/null
+++ b/src/danielcortes/xyz/models/egreso/Egreso.java
@@ -0,0 +1,86 @@
+/*
+ * 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/danielcortes/xyz/models/egreso/EgresoDAO.java b/src/danielcortes/xyz/models/egreso/EgresoDAO.java
new file mode 100644
index 0000000..f64ae40
--- /dev/null
+++ b/src/danielcortes/xyz/models/egreso/EgresoDAO.java
@@ -0,0 +1,80 @@
+/*
+ * 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/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java b/src/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java
new file mode 100644
index 0000000..793a296
--- /dev/null
+++ b/src/danielcortes/xyz/models/egreso/MysqlEgresoDAO.java
@@ -0,0 +1,241 @@
+/*
+ * 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/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java b/src/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java
new file mode 100644
index 0000000..4555aee
--- /dev/null
+++ b/src/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java
@@ -0,0 +1,239 @@
+/*
+ * 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/danielcortes/xyz/models/ingreso/Ingreso.java b/src/danielcortes/xyz/models/ingreso/Ingreso.java
new file mode 100644
index 0000000..1df8f89
--- /dev/null
+++ b/src/danielcortes/xyz/models/ingreso/Ingreso.java
@@ -0,0 +1,85 @@
+/*
+ * 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/danielcortes/xyz/models/ingreso/IngresoDAO.java b/src/danielcortes/xyz/models/ingreso/IngresoDAO.java
new file mode 100644
index 0000000..89a07cd
--- /dev/null
+++ b/src/danielcortes/xyz/models/ingreso/IngresoDAO.java
@@ -0,0 +1,79 @@
+/*
+ * 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/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java b/src/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java
new file mode 100644
index 0000000..3752c4b
--- /dev/null
+++ b/src/danielcortes/xyz/models/ingreso/MysqlIngresoDAO.java
@@ -0,0 +1,218 @@
+/*
+ * 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/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java b/src/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java
new file mode 100644
index 0000000..5595e8f
--- /dev/null
+++ b/src/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java
@@ -0,0 +1,217 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java b/src/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java
new file mode 100644
index 0000000..1ceda7d
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_egreso/MysqlTipoEgresoDAO.java
@@ -0,0 +1,115 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java b/src/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java
new file mode 100644
index 0000000..738f101
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_egreso/SQLiteTipoEgresoDAO.java
@@ -0,0 +1,116 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java b/src/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java
new file mode 100644
index 0000000..1bf43e1
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_egreso/TipoEgreso.java
@@ -0,0 +1,86 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java b/src/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java
new file mode 100644
index 0000000..00d2a07
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_egreso/TipoEgresoDAO.java
@@ -0,0 +1,79 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java b/src/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java
new file mode 100644
index 0000000..d35dcd1
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_ingreso/MysqlTipoIngresoDAO.java
@@ -0,0 +1,114 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java b/src/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java
new file mode 100644
index 0000000..53813a1
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_ingreso/SQLiteTipoIngresoDAO.java
@@ -0,0 +1,116 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java b/src/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java
new file mode 100644
index 0000000..f48f5e5
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_ingreso/TipoIngreso.java
@@ -0,0 +1,87 @@
+/*
+ * 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/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java b/src/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java
new file mode 100644
index 0000000..8aa573a
--- /dev/null
+++ b/src/danielcortes/xyz/models/tipo_ingreso/TipoIngresoDAO.java
@@ -0,0 +1,54 @@
+/*
+ * 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/danielcortes/xyz/views/ArqueoView.form b/src/danielcortes/xyz/views/ArqueoView.form
new file mode 100644
index 0000000..d6c0746
--- /dev/null
+++ b/src/danielcortes/xyz/views/ArqueoView.form
@@ -0,0 +1,526 @@
+
+
diff --git a/src/danielcortes/xyz/views/ArqueoView.java b/src/danielcortes/xyz/views/ArqueoView.java
new file mode 100644
index 0000000..934f015
--- /dev/null
+++ b/src/danielcortes/xyz/views/ArqueoView.java
@@ -0,0 +1,440 @@
+/*
+ * 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/danielcortes/xyz/views/EgresosView.form b/src/danielcortes/xyz/views/EgresosView.form
new file mode 100644
index 0000000..56c9c05
--- /dev/null
+++ b/src/danielcortes/xyz/views/EgresosView.form
@@ -0,0 +1,244 @@
+
+
diff --git a/src/danielcortes/xyz/views/EgresosView.java b/src/danielcortes/xyz/views/EgresosView.java
new file mode 100644
index 0000000..a21aa4f
--- /dev/null
+++ b/src/danielcortes/xyz/views/EgresosView.java
@@ -0,0 +1,241 @@
+/*
+ * 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_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 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(), "Egresos"));
+ 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(egresosTable);
+ 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("N°");
+ panel2.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ final JLabel label2 = new JLabel();
+ label2.setText("Descripcion");
+ panel2.add(label2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+ descripcionField = new JTextField();
+ panel2.add(descripcionField, 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));
+ nroField = new JTextField();
+ panel2.add(nroField, 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));
+ valorField = new JTextField();
+ panel2.add(valorField, 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));
+ final JLabel label3 = new JLabel();
+ label3.setText("Valor");
+ panel2.add(label3, new GridConstraints(0, 2, 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("Tipo");
+ panel2.add(label4, 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();
+ panel2.add(tipoCombo, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, 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 GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, 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 GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, 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 GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, 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 GridConstraints(2, 3, 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, 3, new Insets(0, 0, 0, 0), -1, -1));
+ panel3.add(panel4, 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("Guardar");
+ guardarButton.setMnemonic('G');
+ guardarButton.setDisplayedMnemonicIndex(0);
+ panel4.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.setEnabled(false);
+ eliminarButton.setText("Eliminar");
+ eliminarButton.setMnemonic('E');
+ eliminarButton.setDisplayedMnemonicIndex(0);
+ panel4.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.setEnabled(false);
+ editarButton.setText("Editar");
+ editarButton.setMnemonic('E');
+ editarButton.setDisplayedMnemonicIndex(0);
+ panel4.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_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
+ final JPanel panel5 = new JPanel();
+ panel5.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
+ panel3.add(panel5, 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 Egresos:");
+ panel5.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));
+ totalEgresosField = new JTextField();
+ totalEgresosField.setEditable(false);
+ panel5.add(totalEgresosField, 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));
+ }
+
+ /**
+ * @noinspection ALL
+ */
+ public JComponent $$$getRootComponent$$$() {
+ return contentPanel;
+ }
+}
diff --git a/src/danielcortes/xyz/views/IngresosView.form b/src/danielcortes/xyz/views/IngresosView.form
new file mode 100644
index 0000000..70cea4f
--- /dev/null
+++ b/src/danielcortes/xyz/views/IngresosView.form
@@ -0,0 +1,239 @@
+
+
diff --git a/src/danielcortes/xyz/views/IngresosView.java b/src/danielcortes/xyz/views/IngresosView.java
new file mode 100644
index 0000000..2cef4d8
--- /dev/null
+++ b/src/danielcortes/xyz/views/IngresosView.java
@@ -0,0 +1,231 @@
+/*
+ * 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/danielcortes/xyz/views/ManagerView.form b/src/danielcortes/xyz/views/ManagerView.form
new file mode 100644
index 0000000..b19ef8c
--- /dev/null
+++ b/src/danielcortes/xyz/views/ManagerView.form
@@ -0,0 +1,78 @@
+
+
diff --git a/src/danielcortes/xyz/views/ManagerView.java b/src/danielcortes/xyz/views/ManagerView.java
new file mode 100644
index 0000000..084518f
--- /dev/null
+++ b/src/danielcortes/xyz/views/ManagerView.java
@@ -0,0 +1,120 @@
+/*
+ * 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 com.intellij.uiDesigner.core.GridConstraints;
+import com.intellij.uiDesigner.core.GridLayoutManager;
+
+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 GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
+ cardPanel = new JPanel();
+ cardPanel.setLayout(new CardLayout(0, 0));
+ contentPanel.add(cardPanel, new GridConstraints(1, 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));
+ controlsPanel = new JPanel();
+ controlsPanel.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1));
+ contentPanel.add(controlsPanel, 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));
+ egresosButton = new JToggleButton();
+ egresosButton.setText("Egresos");
+ egresosButton.setMnemonic('E');
+ egresosButton.setDisplayedMnemonicIndex(0);
+ controlsPanel.add(egresosButton, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | 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 GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | 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 GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, new Dimension(200, -1), null, 0, false));
+ datePicker = new DatePicker();
+ controlsPanel.add(datePicker, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | 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/danielcortes/xyz/views/components/EgresosTableModel.java b/src/danielcortes/xyz/views/components/EgresosTableModel.java
new file mode 100644
index 0000000..7b1403e
--- /dev/null
+++ b/src/danielcortes/xyz/views/components/EgresosTableModel.java
@@ -0,0 +1,96 @@
+/*
+ * 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/danielcortes/xyz/views/components/IngresosTableModel.java b/src/danielcortes/xyz/views/components/IngresosTableModel.java
new file mode 100644
index 0000000..e7d4aaa
--- /dev/null
+++ b/src/danielcortes/xyz/views/components/IngresosTableModel.java
@@ -0,0 +1,94 @@
+/*
+ * 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);
+ }
+}