Exemple #1
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();
    }
  }
  public void imprimir(TYPE_PRINT bVisualizar) {

    if (txtDatafim.getVlrDate().before(txtDataini.getVlrDate())) {
      Funcoes.mensagemInforma(this, "Data final maior que a data inicial!");
      return;
    }

    ImprimeOS imp = new ImprimeOS("", con);
    int linPag = imp.verifLinPag() - 1;
    int numcheque = 0;
    boolean pass = false;

    String sPag = "";

    String sDataini = "";
    String sDatafim = "";

    sDataini = txtDataini.getVlrString();
    sDatafim = txtDatafim.getVlrString();

    ResultSet rs = getResultSet();

    try {

      imp.limpaPags();

      while (rs.next()) {

        if (numcheque != rs.getInt("NCHEQUE")) {
          pass = true;
          numcheque = rs.getInt("NCHEQUE");
        } else pass = false;

        if (imp.pRow() >= (linPag - 1)) {
          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 89) + "|");
          imp.incPags();
          imp.eject();
        }
        if (imp.pRow() == 0) {
          imp.montaCab();
          imp.setTitulo("Relatório de saida x retorno" + sPag);
          imp.addSubTitulo(
              "RELATÓRIO DE SAIDA X RETORNO "
                  + sPag
                  + "   -   PERIODO DE :"
                  + sDataini
                  + " ATE: "
                  + sDatafim);
          imp.impCab(91, true);
          imp.say(imp.pRow() + 0, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 88) + "|");
        }

        if (pass == true) {

          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, StringFunctions.replicate("=", 90));
          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());

          imp.say(imp.pRow() + 0, 0, " Cliente:");
          imp.say(imp.pRow() + 0, 2, rs.getString("NOMECLI"));

          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());

          imp.say(imp.pRow() + 0, 2, "Num.Cheque:");
          imp.say(imp.pRow() + 0, 2, rs.getString("NCHEQUE"));
          imp.say(imp.pRow() + 0, 3, "Valor:");
          imp.say(imp.pRow() + 0, 2, rs.getString("VALOR"));
          imp.say(imp.pRow() + 0, 3, "Banco:");
          imp.say(imp.pRow() + 0, 2, rs.getString("banco"));

          imp.say(imp.pRow() + 2, 0, "" + imp.comprimido());

          imp.say(imp.pRow() + 0, 2, "Data/Saída");
          imp.say(imp.pRow() + 0, 3, "Descrição");
          imp.say(imp.pRow() + 0, 42, "Data/Retorno");
          imp.say(imp.pRow() + 0, 5, "Cód.Retorno");
          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, StringFunctions.replicate("-", 90));
        }

        imp.say(imp.pRow() + 1, 0, "" + imp.normal());
        imp.say(imp.pRow() + 0, 2, Funcoes.dateToStrDate(rs.getDate("Dates")));
        imp.say(imp.pRow() + 0, 3, rs.getString("DESCRICAO"));
        imp.say(imp.pRow() + 0, 5, Funcoes.dateToStrDate(rs.getDate("Dater")));
        imp.say(imp.pRow() + 0, 11, rs.getString("Codigor"));

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

      imp.say(imp.pRow() + 1, 0, "" + imp.normal());
      imp.say(imp.pRow() + 0, 0, StringFunctions.replicate("=", 90));

      imp.eject();

      imp.fechaGravacao();

      con.commit();

    } catch (SQLException err) {
      Funcoes.mensagemErro(this, "Erro consulta tabela de Cheques!" + err.getMessage());
    }

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