Corregido problemas .w.

This commit is contained in:
Daniel Cortes
2018-12-28 21:12:10 -03:00
parent fe187e4892
commit e555ab9106
13 changed files with 102 additions and 47 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_9">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">

8
conf
View File

@@ -7,14 +7,14 @@
# - mysql
# - sqlite
database_type = mysql
#database_type = 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:/opt/caja/database.db
#database_uri = jdbc:mysql://localhost/caja?user=root&password=lagging&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
database_uri = jdbc:sqlite:/home/ryuuji/src/caja/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.

Binary file not shown.

View File

@@ -15,8 +15,8 @@
<version>3.8.0</version>
<configuration>
<release>8</release>
<source>9</source>
<target>9</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>

View File

@@ -28,6 +28,25 @@ 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.*;
@@ -48,9 +67,34 @@ public class Main {
Locale.setDefault(new Locale("es"));
CajaDAO cajaDAO = new MysqlCajaDAO();
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);
ManagerController managerController = new ManagerController(view, cajaDAO, documentosDAO, efectivoDAO, egresoDAO, ingresoDAO, tipoEgresoDAO, tipoIngresoDAO);
JFrame frame = new JFrame("Caja");
frame.setContentPane(view.getContentPanel());

View File

@@ -39,6 +39,7 @@ 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;
@@ -53,13 +54,25 @@ 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) {
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();
@@ -100,15 +113,13 @@ public class ManagerController {
caja.setFecha(selectedDate);
this.cajaDAO.insertCaja(caja);
EfectivoDAO efectivoDAO = new MysqlEfectivoDAO();
Efectivo efectivo = new Efectivo();
efectivo.setCaja(caja);
efectivoDAO.insertDefaultEfectivo(efectivo);
this.efectivoDAO.insertDefaultEfectivo(efectivo);
DocumentosDAO documentosDAO = new MysqlDocumentosDAO();
Documentos documentos = new Documentos();
documentos.setCaja(caja);
documentosDAO.insertDefaultDocumentos(documentos);
this.documentosDAO.insertDefaultDocumentos(documentos);
}
this.ingresosController.updateCaja(caja);
@@ -124,34 +135,26 @@ public class ManagerController {
private void loadIngresosView() {
IngresosView ingresosView = new IngresosView();
IngresoDAO ingresoDAO = new MysqlIngresoDAO();
TipoIngresoDAO tipoIngresoDAO = new MysqlTipoIngresoDAO();
this.view.getCardPanel().add(ingresosView.getContentPanel(), "INGRESOS");
this.ingresosController = new IngresosController(ingresosView, ingresoDAO, tipoIngresoDAO);
this.ingresosController = new IngresosController(ingresosView, this.ingresoDAO, this.tipoIngresoDAO);
}
private void loadEgresosView() {
EgresosView egresosView = new EgresosView();
EgresoDAO egresoDAO = new MysqlEgresoDAO();
TipoEgresoDAO tipoEgresoDAO = new MysqlTipoEgresoDAO();
this.view.getCardPanel().add(egresosView.getContentPanel(), "EGRESOS");
this.egresosController = new EgresosController(egresosView, egresoDAO, tipoEgresoDAO);
this.egresosController = new EgresosController(egresosView, this.egresoDAO, this.tipoEgresoDAO);
}
private void loadArqueoView() {
ArqueoView arqueoView = new ArqueoView();
EfectivoDAO efectivoDAO = new MysqlEfectivoDAO();
DocumentosDAO documentosDAO = new MysqlDocumentosDAO();
EgresoDAO egresoDAO = new MysqlEgresoDAO();
IngresoDAO ingresoDAO = new MysqlIngresoDAO();
this.view.getCardPanel().add(arqueoView.getContentPanel(), "ARQUEO");
this.arqueoController = new ArqueoController(arqueoView, efectivoDAO, documentosDAO, ingresoDAO, egresoDAO);
this.arqueoController = new ArqueoController(arqueoView, this.efectivoDAO, this.documentosDAO, this.ingresoDAO, this.egresoDAO);
}
private void pressInitialButton() {

View File

@@ -35,6 +35,11 @@ public class SQLiteConnectionHolder implements ConnectionHolder {
@Override
public java.sql.Connection getConnection() throws SQLException{
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return DriverManager.getConnection(databaseURI);
}
}

View File

@@ -30,7 +30,10 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@@ -89,7 +92,7 @@ public class SQLiteCajaDAO implements CajaDAO {
Connection conn = connectionHolder.getConnection();
PreparedStatement ps = conn.prepareStatement("select * from caja where fecha = ?");
ps.setObject(1, fecha);
ps.setString(1, fecha.toString());
ResultSet rs = ps.executeQuery();
@@ -114,7 +117,8 @@ public class SQLiteCajaDAO implements CajaDAO {
try {
Connection conn = connectionHolder.getConnection();
PreparedStatement ps = conn.prepareStatement("insert into caja (fecha) values (?)");
ps.setObject(1, caja.getFecha());
ps.setString(1, caja.getFecha().toString());
updates = ps.executeUpdate();
ps.close();
@@ -140,7 +144,7 @@ public class SQLiteCajaDAO implements CajaDAO {
try {
Connection conn = connectionHolder.getConnection();
PreparedStatement ps = conn.prepareStatement("update caja set fecha = ? where id = ?");
ps.setObject(1, caja.getFecha());
ps.setString(1, caja.getFecha().toString());
ps.setInt(2, caja.getId());
updates = ps.executeUpdate();
@@ -160,7 +164,7 @@ public class SQLiteCajaDAO implements CajaDAO {
while (rs.next()) {
Caja caja = new Caja();
caja.setId(rs.getInt("id"));
caja.setFecha(rs.getObject("fecha", LocalDate.class));
caja.setFecha(LocalDate.parse(rs.getString("fecha")));
cajaList.add(caja);
}
return cajaList;

View File

@@ -25,10 +25,10 @@
package danielcortes.xyz.models.documentos;
import danielcortes.xyz.data.ConnectionHolder;
import danielcortes.xyz.data.MysqlConnectionHolder;
import danielcortes.xyz.data.SQLiteConnectionHolder;
import danielcortes.xyz.models.caja.Caja;
import danielcortes.xyz.models.caja.CajaDAO;
import danielcortes.xyz.models.caja.MysqlCajaDAO;
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -41,7 +41,7 @@ public class SQLiteDocumentosDAO implements DocumentosDAO{
private ConnectionHolder connectionHolder;
public SQLiteDocumentosDAO() {
this.connectionHolder = new MysqlConnectionHolder();
this.connectionHolder = new SQLiteConnectionHolder();
}
@Override
@@ -208,7 +208,7 @@ public class SQLiteDocumentosDAO implements DocumentosDAO{
private List<Documentos> documentosFromResultSet(ResultSet rs) throws SQLException {
List<Documentos> documentosList = new ArrayList<>();
while (rs.next()) {
CajaDAO cajaDAO = new MysqlCajaDAO();
CajaDAO cajaDAO = new SQLiteCajaDAO();
Caja caja = cajaDAO.findById(rs.getInt("caja_id"));
Documentos documentos = new Documentos();

View File

@@ -25,11 +25,10 @@
package danielcortes.xyz.models.efectivo;
import danielcortes.xyz.data.ConnectionHolder;
import danielcortes.xyz.data.MysqlConnectionHolder;
import danielcortes.xyz.data.SQLiteConnectionHolder;
import danielcortes.xyz.models.caja.Caja;
import danielcortes.xyz.models.caja.CajaDAO;
import danielcortes.xyz.models.caja.MysqlCajaDAO;
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -222,7 +221,7 @@ public class SQLiteEfectivoDAO implements EfectivoDAO{
private List<Efectivo> efectivosFromResultSet(ResultSet rs) throws SQLException {
List<Efectivo> efectivoList = new ArrayList<>();
while (rs.next()) {
CajaDAO cajaDAO = new MysqlCajaDAO();
CajaDAO cajaDAO = new SQLiteCajaDAO();
Caja caja = cajaDAO.findById(rs.getInt("caja_id"));
Efectivo efectivo = new Efectivo();

View File

@@ -28,8 +28,8 @@ 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.MysqlCajaDAO;
import danielcortes.xyz.models.tipo_egreso.MysqlTipoEgresoDAO;
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;
@@ -244,11 +244,11 @@ public class SQLiteEgresoDAO implements EgresoDAO{
ArrayList<Egreso> egresoList = new ArrayList<>();
while(rs.next()){
int tipoEgresoId = rs.getInt("tipo_egreso_id");
TipoEgresoDAO tipoEgresoDAO = new MysqlTipoEgresoDAO();
TipoEgresoDAO tipoEgresoDAO = new SQLiteTipoEgresoDAO();
TipoEgreso tipoEgreso = tipoEgresoDAO.findById(tipoEgresoId).get(0);
int cajaId = rs.getInt("caja_id");
CajaDAO cajaDAO = new MysqlCajaDAO();
CajaDAO cajaDAO = new SQLiteCajaDAO();
Caja caja = cajaDAO.findById(cajaId);
Egreso egreso = new Egreso();

View File

@@ -28,8 +28,8 @@ 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.MysqlCajaDAO;
import danielcortes.xyz.models.tipo_ingreso.MysqlTipoIngresoDAO;
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;
@@ -221,11 +221,11 @@ public class SQLiteIngresoDAO implements IngresoDAO{
ArrayList<Ingreso> ingresosList = new ArrayList<>();
while(rs.next()){
int tipoIngresoId = rs.getInt("tipo_ingreso_id");
TipoIngresoDAO tipoEgresoDAO = new MysqlTipoIngresoDAO();
TipoIngresoDAO tipoEgresoDAO = new SQLiteTipoIngresoDAO();
TipoIngreso tipoIngreso = tipoEgresoDAO.findById(tipoIngresoId).get(0);
int cajaId = rs.getInt("caja_id");
CajaDAO cajaDAO = new MysqlCajaDAO();
CajaDAO cajaDAO = new SQLiteCajaDAO();
Caja caja = cajaDAO.findById(cajaId);
Ingreso ingreso = new Ingreso();

View File

@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: danielcortes.xyz.Main
Manifest-Version: 1.0
Main-Class: danielcortes.xyz.Main