Exemple #1
0
  private void imprimirTexto(final TYPE_PRINT bVisualizar, final ResultSet rs) {

    String sLinhaFina = StringFunctions.replicate("-", 125);
    ImprimeOS imp = new ImprimeOS("", con);
    int linPag = imp.verifLinPag() - 1;
    imp.montaCab();

    try {

      imp.limpaPags();
      imp.montaCab();
      imp.setTitulo("Relatório de UF");

      while (rs.next()) {

        if (imp.pRow() == linPag) {
          imp.pulaLinha(1, imp.comprimido());
          imp.say(0, "+" + sLinhaFina + "+");
          imp.eject();
          imp.incPags();
        }

        if (imp.pRow() == 0) {
          imp.impCab(126, false);
          imp.say(0, imp.normal());
          imp.say(2, "Cód.UF");
          imp.say(10, "|");
          imp.say(14, "Sigla.UF");
          imp.say(24, "|");
          imp.say(28, "Nome.UF");
          imp.say(60, "|");
          imp.say(64, "Região.UF");
          imp.say(75, "|");
          imp.say(79, "Cód País");
          imp.say(89, "|");
          imp.say(93, "Nome País");
          imp.say(126, "|");
          imp.pulaLinha(1, imp.normal());
          imp.say(0, StringFunctions.replicate("-", 125));
        }

        imp.pulaLinha(1, imp.normal());
        imp.say(2, rs.getString("CodUf").trim());
        imp.say(10, "|");
        imp.say(14, rs.getString("SiglaUf").trim());
        imp.say(24, "|");
        imp.say(28, rs.getString("NomeUf").trim());
        imp.say(60, "|");
        imp.say(64, rs.getString("RegiaoUf").trim());
        imp.say(75, "|");
        imp.say(79, rs.getString("CodPais").trim());
        imp.say(89, "|");
        imp.say(93, rs.getString("NomePais").trim());
        imp.say(126, "|");

        if (imp.pRow() >= linPag) {
          imp.incPags();
          imp.eject();
        }
      }

      imp.pulaLinha(1, imp.normal());
      imp.say(0, StringFunctions.replicate("=", 125));
      imp.pulaLinha(1, imp.normal());

      imp.eject();
      imp.fechaGravacao();

      if (bVisualizar == TYPE_PRINT.VIEW) {
        imp.preview(this);
      } else {
        imp.print();
      }

    } catch (SQLException err) {
      err.printStackTrace();
      Funcoes.mensagemErro(this, "Erro consulta UF!\n" + err.getMessage(), true, con, err);
    }
  }
Exemple #2
0
  public void imprimiTexto(ResultSet rs, TYPE_PRINT bVisualizar, String sCab) {

    BigDecimal bTotal = new BigDecimal("0");
    BigDecimal bSaldo = new BigDecimal("0");
    BigDecimal bSaldoLinha = new BigDecimal("0");
    BigDecimal bVlrDeb = new BigDecimal("0");
    BigDecimal bVlrCred = new BigDecimal("0");
    BigDecimal bVlrTotDeb = new BigDecimal("0");
    BigDecimal bVlrTotCred = new BigDecimal("0");
    BigDecimal bAnt = buscaSaldoAnt();
    ImprimeOS imp = new ImprimeOS("", con);
    String linhafina = StringFunctions.replicate("-", 133);
    String sDataLanca = "";
    String sConta = "";
    String sCodConta = txtCodConta.getVlrString();

    boolean bPrim = true;
    int linPag = imp.verifLinPag() - 1;

    try {

      imp.limpaPags();
      imp.setTitulo("Extrato Bancário");
      imp.addSubTitulo("EXTRATO BANCÁRIO");
      sConta = "CONTA: " + sCodConta + " - " + txtDescConta.getVlrString();
      imp.addSubTitulo(sConta);

      while (rs.next()) {

        if (!bPrim) {

          if (!(sDataLanca.equals(rs.getString("DataSL")))) {
            bTotal = new BigDecimal(rs.getString("SaldoSL"));
          }
        } else {
          bTotal = new BigDecimal(rs.getString("SaldoSL"));
        }

        if (imp.pRow() == linPag) {
          imp.eject();
          imp.incPags();
        }
        if (imp.pRow() == 0) {

          imp.montaCab();
          imp.impCab(136, true);

          imp.say(0, imp.comprimido());
          imp.say(0, "|" + linhafina + "|");
          imp.pulaLinha(1, imp.comprimido());
          imp.say(0, "| Data");
          imp.say(14, "| Historico");
          imp.say(69, "| Doc");
          imp.say(82, "| Débito");
          imp.say(100, "| Crédito");
          imp.say(118, "| Saldo");
          imp.say(135, "|");
          imp.pulaLinha(1, imp.comprimido());
          imp.say(0, "|" + linhafina + "|");

          if (bPrim) {

            imp.pulaLinha(1, imp.comprimido());
            imp.say(0, "|");
            imp.say(
                103,
                "Saldo Anterior: "
                    + Funcoes.strDecimalToStrCurrency(15, Aplicativo.casasDecFin, bAnt.toString()));
            imp.say(135, "|");
            imp.pulaLinha(1, imp.comprimido());
            imp.say(0, "|" + linhafina + "|");
            bSaldoLinha = new BigDecimal(bAnt.toString());
          }
        }
        bPrim = false;
        bSaldo = new BigDecimal(rs.getBigDecimal("SaldoSL").toString());
        bAnt = bSaldo;
        sDataLanca = rs.getString("DataSL");
        bSaldoLinha = bSaldoLinha.add(rs.getBigDecimal("VlrSubLanca"));

        if (rs.getFloat("VlrSubLanca") < 0) {
          bVlrDeb = new BigDecimal(rs.getBigDecimal("VlrSubLanca").toString()).abs();
          bVlrCred = new BigDecimal("0.00");
          bVlrTotDeb = bVlrTotDeb.add(new BigDecimal(bVlrDeb.toString()));
        } else {
          bVlrCred = new BigDecimal(rs.getBigDecimal("VlrSubLanca").toString());
          bVlrDeb = new BigDecimal("0.00");
          bVlrTotCred = bVlrTotCred.add(new BigDecimal(bVlrCred.toString()));
        }

        imp.pulaLinha(1, imp.comprimido());
        imp.say(0, "| " + StringFunctions.sqlDateToStrDate(rs.getDate("DataSL")));
        imp.say(14, "| " + Funcoes.copy(rs.getString("HistBLanca"), 0, 50));
        imp.say(69, "| " + Funcoes.alinhaDir(rs.getString("DocLanca"), 10));
        imp.say(82, "|");
        if (bVlrDeb.floatValue() != 0) {
          imp.say(
              imp.pRow() + 0,
              84,
              Funcoes.strDecimalToStrCurrency(15, Aplicativo.casasDecFin, bVlrDeb.toString()));
        }
        imp.say(100, "|");
        if (bVlrCred.floatValue() != 0) {
          imp.say(
              0,
              102,
              Funcoes.strDecimalToStrCurrency(15, Aplicativo.casasDecFin, bVlrCred.toString()));
        }
        imp.say(
            118,
            "|"
                + Funcoes.strDecimalToStrCurrency(
                    15, Aplicativo.casasDecFin, bSaldoLinha.toString()));
        imp.say(135, "|");
      }
      imp.pulaLinha(1, imp.comprimido());
      imp.say(0, "|" + linhafina + "|");
      imp.pulaLinha(1, imp.comprimido());
      imp.say(0, "|");
      imp.say(82, "|");
      imp.say(
          84, Funcoes.strDecimalToStrCurrency(15, Aplicativo.casasDecFin, bVlrTotDeb.toString()));
      imp.say(100, "|");
      imp.say(
          102, Funcoes.strDecimalToStrCurrency(15, Aplicativo.casasDecFin, bVlrTotCred.toString()));
      imp.say(118, "|");
      imp.say(119, Funcoes.strDecimalToStrCurrency(15, Aplicativo.casasDecFin, bTotal.toString()));
      imp.say(135, "|");
      imp.pulaLinha(1, imp.comprimido());
      imp.say(0, "+" + linhafina + "+");

      imp.eject();
      imp.fechaGravacao();

      rs.close();
      con.commit();

    } catch (Exception e) {

      e.printStackTrace();
    }
    if (bVisualizar == TYPE_PRINT.VIEW) {
      imp.preview(this);
    } else {
      imp.print();
    }
  }