Exemplo n.º 1
0
  public boolean registrarCierre() {
    boolean resultado = false;
    Connection con = null;

    // SE CONSIGUE EL ITEM PARA EL CIERRE DE CAJA
    CierreCaja unCierre = this.getCierre();
    String sql =
        "INSERT INTO cierre_caja("
            + "fecha,"
            + "factura_inicial,"
            + "factura_final,"
            + "efectivo,"
            + "creditos,"
            + "totalventa,"
            + "tarjeta,"
            + "usuario,"
            + "isv15,"
            + "isv18)"
            + " VALUES (now(),?,?,?,?,?,?,?,?,?)";
    if (unCierre != null)
      try {
        con = Conexion.getPoolConexion().getConnection();
        registrarCierre = con.prepareStatement(sql);

        registrarCierre.setInt(1, unCierre.getNoFacturaInicio());
        registrarCierre.setInt(2, unCierre.getNoFacturaFinal());
        registrarCierre.setBigDecimal(3, unCierre.getEfectivo());
        registrarCierre.setBigDecimal(4, unCierre.getCredito());
        registrarCierre.setBigDecimal(5, unCierre.getTotal());
        registrarCierre.setBigDecimal(6, unCierre.getTarjeta());
        registrarCierre.setString(7, unCierre.getUsuario());
        registrarCierre.setBigDecimal(8, unCierre.getIsv15());
        registrarCierre.setBigDecimal(9, unCierre.getIsv18());

        registrarCierre.executeUpdate(); // se guarda el encabezado de la factura
        resultado = true;

      } catch (SQLException e) {
        e.printStackTrace();
        resultado = false;
      } finally {
        try {

          // if(res != null) res.close();
          if (registrarCierre != null) registrarCierre.close();
          if (con != null) con.close();

        } // fin de try
        catch (SQLException excepcionSql) {
          excepcionSql.printStackTrace();
          // conexion.desconectar();
        } // fin de catch
      } // fin de finally

    return resultado;
  }