Se creo una fila en la tabla de cajas en la que se almacena el fondo de esta, la cual sera mostrada en la vista de calcular fondo, donde sera actualizada segun diga el usuario

This commit is contained in:
Daniel Cortes
2019-02-20 14:06:58 -03:00
parent 08da94aba4
commit e7eb6513dd
14 changed files with 101 additions and 78 deletions

View File

@@ -121,16 +121,16 @@ public class SQLiteCajaDAO extends CajaDAO {
public boolean insertCaja(Caja caja) {
int updates;
try (Connection conn = connectionHolder.getConnection()) {
String query = "insert into caja (fecha) values (?)";
String query = "insert into caja (fecha, fondo) values (?, ?)";
PreparedStatement ps = conn.prepareStatement(query);
ps.setString(1, caja.getFecha().toString());
ps.setInt(2, caja.getFondo());
updates = ps.executeUpdate();
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, caja.getFecha(), updates});
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}, {2} | updates: {3}", new Object[]{query, caja.getFecha(), caja.getFondo(), updates});
ps.close();
query = "select last_insert_rowid()";
ps = conn.prepareStatement("select last_insert_rowid()");
ResultSet rs = ps.executeQuery();
@@ -153,13 +153,14 @@ public class SQLiteCajaDAO extends CajaDAO {
public boolean updateCaja(Caja caja) {
int updates;
try (Connection conn = connectionHolder.getConnection()) {
String query = "update caja set fecha = ? where id = ?";
String query = "update caja set fecha = ?, fondo = ? where id = ?";
PreparedStatement ps = conn.prepareStatement(query);
ps.setString(1, caja.getFecha().toString());
ps.setInt(2, caja.getId());
ps.setInt(2, caja.getFondo());
ps.setInt(3, caja.getId());
updates = ps.executeUpdate();
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2} | updates: {3}]", new Object[]{query, caja.getFecha(), caja.getId(), updates});
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}, {2}, {3} | updates: {4}", new Object[]{query, caja.getFecha(), caja.getFondo(), caja.getId(), updates});
ps.close();