se ejecuto limpieza del codigo, reformateo del codigo y optimizacion de los imports por parte del IDE
This commit is contained in:
@@ -24,11 +24,8 @@
|
||||
|
||||
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;
|
||||
@@ -45,8 +42,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public List<Efectivo> findAll() {
|
||||
List<Efectivo> efectivoList = new ArrayList<>();
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
PreparedStatement ps = conn.prepareStatement("select * from efectivos");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
@@ -54,7 +50,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -65,8 +60,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public Efectivo findById(int id) {
|
||||
Efectivo efectivo = null;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
PreparedStatement ps = conn.prepareStatement("select * from efectivos where id = ?");
|
||||
ps.setInt(1, id);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -75,7 +69,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -86,8 +79,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public Efectivo findByCaja(Caja caja) {
|
||||
Efectivo efectivo = null;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
PreparedStatement ps = conn.prepareStatement("select * from efectivos where caja_id = ?");
|
||||
ps.setInt(1, caja.getId());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -99,7 +91,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -110,8 +101,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public boolean insertEfectivo(Efectivo efectivo) {
|
||||
int updates;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
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());
|
||||
@@ -134,7 +124,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
@@ -145,8 +134,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public boolean insertDefaultEfectivo(Efectivo efectivo) {
|
||||
int updates;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
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());
|
||||
|
||||
@@ -160,7 +148,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
@@ -171,8 +158,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public boolean updateEfectivo(Efectivo efectivo) {
|
||||
int updates;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
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());
|
||||
@@ -189,7 +175,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
updates = ps.executeUpdate();
|
||||
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
@@ -200,15 +185,13 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public boolean deleteEfectivo(Efectivo efectivo) {
|
||||
int updates;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
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;
|
||||
@@ -219,8 +202,7 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
@Override
|
||||
public int getTotalEfectivo(Caja caja) {
|
||||
int total = 0;
|
||||
try {
|
||||
Connection conn = connectionHolder.getConnection();
|
||||
try (Connection conn = connectionHolder.getConnection()) {
|
||||
PreparedStatement ps = conn.prepareStatement("select veinte_mil + diez_mil + cinco_mil + dos_mil + mil + quinientos + cien + cincuenta + diez from efectivos where caja_id = ?");
|
||||
ps.setInt(1, caja.getId());
|
||||
|
||||
@@ -230,7 +212,6 @@ public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user