Пример #1
0
  public ResultSet getResultSet() {

    String NomeCli = "";

    NomeCli = "'" + txtCliente.getVlrString() + "%'";

    String sSQL =
        " select vdcliente.Nomecli as nome, fnbanco.Nomebanco as banco, "
            + " sgcheque.NCHEQUE, sgcheque.predata, sgcheque.valor, "
            + " sgcheque.codbanco, sgcheque.codcli, sgscheque.NSAIDA ,sgscheque.NCHEQUE, sgscheque.TSAIDA, "
            + " sgscheque.DESCRICAO, sgscheque.DTINS as Dates, sgrcheque.NSAIDA, sgrcheque.NCHEQUE, sgrcheque.DTINS as Dater, "
            + " sgrcheque.codigor from vdcliente, fnbanco, sgcheque, sgscheque, sgrcheque where "
            + " vdcliente.CODCLI=sgcheque.CODCLI and "
            + " fnbanco.codbanco=sgcheque.codbanco and UPPER(vdcliente.Nomecli) LIKE UPPER( "
            + NomeCli
            + " ) "
            + " and sgcheque.NCHEQUE=sgscheque.NCHEQUE and sgcheque.CODBANCO=sgscheque.CODBANCO and sgscheque.TSAIDA=1 "
            + " and sgrcheque.NCHEQUE=sgscheque.NCHEQUE and sgrcheque.CODBANCO=sgscheque.CODBANCO and sgrcheque.NSAIDA=sgscheque.NSAIDA and sgscheque.dtins BETWEEN ? AND ? ORDER BY sgscheque.DTINS";

    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
      ps = con.prepareStatement(sSQL);
      ps.setDate(1, Funcoes.dateToSQLDate(txtDataini.getVlrDate()));
      ps.setDate(2, Funcoes.dateToSQLDate(txtDatafim.getVlrDate()));

      rs = ps.executeQuery();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return rs;
  }
Пример #2
0
  private BigDecimal buscaSaldoAnt() {

    BigDecimal bigRetorno = new BigDecimal("0.00");
    StringBuilder sSQL = new StringBuilder();

    sSQL.append("SELECT S.SALDOSL FROM FNSALDOLANCA S, FNCONTA C ");
    sSQL.append("WHERE C.NUMCONTA=? AND C.CODEMP=? AND C.CODFILIAL=? ");
    sSQL.append("AND S.CODEMP=C.CODEMPPN AND S.CODFILIAL=C.CODFILIALPN ");
    sSQL.append("AND S.CODPLAN=C.CODPLAN AND S.DATASL=");
    sSQL.append("(SELECT MAX(S1.DATASL) FROM FNSALDOLANCA S1 ");
    sSQL.append("WHERE S1.DATASL < ? AND S1.CODPLAN=S.CODPLAN ");
    sSQL.append("AND S1.CODEMP=S.CODEMP AND S1.CODFILIAL=S.CODFILIAL)");

    try {

      PreparedStatement ps = con.prepareStatement(sSQL.toString());
      ps.setString(1, txtCodConta.getVlrString());
      ps.setInt(2, Aplicativo.iCodEmp);
      ps.setInt(3, ListaCampos.getMasterFilial("FNCONTA"));
      ps.setDate(4, Funcoes.dateToSQLDate(txtDataini.getVlrDate()));
      ResultSet rs = ps.executeQuery();
      if (rs.next()) {
        bigRetorno = new BigDecimal(rs.getString("SaldoSL"));
      }
      rs.close();
      ps.close();

    } catch (Exception e) {
      e.printStackTrace();
      Funcoes.mensagemErro(this, "Erro ao buscar saldo anterior!\n" + e.getMessage(), true, con, e);
    }
    return bigRetorno;
  }
Пример #3
0
  private void insertFaltaJustificada(String horaini, String horafin) {

    txtCodAtend.setVlrInteger(daoatend.getAtendente(txtMatempr.getVlrInteger()));

    try {
      if (daoatend.getPrefs()[PREFS.CODMODELFJ.ordinal()] != null) {
        daoatend.insertFaltaJustificada(
            Aplicativo.iCodEmp,
            ListaCampos.getMasterFilial("ATATENDIMENTO"),
            txtDtFalta.getVlrDate(),
            txtDtFalta.getVlrDate(),
            horaini,
            horafin,
            Aplicativo.iCodEmp,
            ListaCampos.getMasterFilial("ATATENDENTE"),
            txtCodAtend.getVlrInteger(),
            Aplicativo.iCodEmp,
            ListaCampos.getMasterFilial("SGUSUARIO"),
            Aplicativo.getUsuario().getIdusu());
      }

    } catch (Exception e) {
      Funcoes.mensagemErro(
          this, "Erro inserindo lançamento automatizado de intervalo !\n" + e.getMessage());
      e.printStackTrace();
    }
  }
Пример #4
0
  public void imprimir(TYPE_PRINT bVisualizar) {

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

    PreparedStatement ps = null;
    ResultSet rs = null;
    StringBuffer sql = new StringBuffer();
    StringBuffer sCab = new StringBuffer();

    sCab.append(
        "Período de : "
            + Funcoes.dateToStrDate(txtDataini.getVlrDate())
            + "Até : "
            + Funcoes.dateToStrDate(txtDatafim.getVlrDate()));

    try {

      sql.append(
          "SELECT CL.CODVEND, VO.NOMEVEND, CL.CODCLI, CL.RAZCLI, ( SELECT MAX(DTEMITVENDA) FROM VDVENDA VD, VDCLIENTE SB ");
      sql.append("WHERE SB.CODEMPPQ=CL.CODEMP AND ");
      sql.append("SB.CODFILIALPQ=CL.CODFILIAL AND ");
      sql.append("SB.CODPESQ=CL.CODCLI AND ");
      sql.append(
          "VD.CODEMPCL=SB.CODEMP AND VD.CODFILIALCL=SB.CODFILIAL AND VD.CODCLI=SB.CODCLI) ULTIMACOMPRA ");
      sql.append("FROM VDCLIENTE CL LEFT OUTER JOIN VDVENDEDOR VO ON ");
      sql.append(
          "VO.CODEMP=CL.CODEMPVD AND VO.CODFILIAL=CL.CODFILIALVD AND VO.CODVEND=CL.CODVEND ");
      sql.append("WHERE ");
      sql.append(
          "CL.CODEMP=CL.CODEMPPQ AND CL.CODFILIAL=CL.CODFILIALPQ AND CL.CODCLI=CL.CODPESQ AND ");
      sql.append("NOT EXISTS( SELECT * FROM VDVENDA VD, VDCLIENTE SB ");
      sql.append("WHERE SB.CODEMPPQ=CL.CODEMP AND ");
      sql.append("SB.CODFILIALPQ=CL.CODFILIAL AND ");
      sql.append("SB.CODPESQ=CL.CODCLI AND ");
      sql.append(
          "VD.CODEMPCL=SB.CODEMP AND VD.CODFILIALCL=SB.CODFILIAL AND VD.CODCLI=SB.CODCLI AND ");
      sql.append("VD.DTEMITVENDA BETWEEN ? AND ? ) ");
      sql.append("AND CL.ATIVOCLI='S' ");

      if (txtCodComiss.getVlrInteger() > 0) {
        sql.append(" and cl.codempvd=? and cl.codfilialvd=? and cl.codvend=? ");
      }

      sql.append("order by cl.codvend, cl.razcli ");

      ps = con.prepareStatement(sql.toString());

      int param = 1;

      ps.setDate(param++, Funcoes.dateToSQLDate(txtDataini.getVlrDate()));
      ps.setDate(param++, Funcoes.dateToSQLDate(txtDatafim.getVlrDate()));

      if (txtCodComiss.getVlrInteger() > 0) {
        ps.setInt(param++, lcComiss.getCodEmp());
        ps.setInt(param++, lcComiss.getCodFilial());
        ps.setInt(param++, txtCodComiss.getVlrInteger());
      }

      rs = ps.executeQuery();

      imprimiGrafico(bVisualizar, rs, sCab.toString());

      con.commit();

    } catch (Exception e) {
      e.printStackTrace();
      Funcoes.mensagemInforma(this, "Erro ao buscar dados do relatório!");
    }
  }
Пример #5
0
  public void imprimir(TYPE_PRINT bVisualizar) {

    PreparedStatement ps = null;
    ResultSet rs = null;
    StringBuilder sCab = new StringBuilder();
    StringBuilder sql = new StringBuilder();
    Blob fotoemp = FPrinterJob.getLogo(con);

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

    sCab.append("Período de " + txtDataini.getVlrString() + " a " + txtDatafim.getVlrString());

    if (txtCodAtend.getVlrInteger().intValue() > 0) {
      sCab.append(txtCodAtend.getVlrInteger().toString() + " - " + txtNomeAtend.getVlrString());
    }
    if (!"".equals(txtCodUsu.getVlrString())) {
      sCab.append(" - Usuário: " + txtCodUsu.getVlrString());
    }

    sql.append(
        "select e.nomeatend, a.idusuins, a.codatend, a.dataatendo, a.dtins , a.horaatendofin, a.hins, cast ( ( ( ( case when a.hins-a.horaatendofin>0 then ");
    sql.append("		a.hins-a.horaatendofin else 0 end) / 60 / 60 ) + ( ");
    sql.append("(a.dtins-a.dataatendo) * 24) / 24 ) as decimal(15,2) ) numdias , ");
    sql.append("cast ( ( (case when a.hins-a.horaatendofin>0 then ");
    sql.append("a.hins-a.horaatendofin else 0 end) / 60 / 60 ) + ( ");
    sql.append("(a.dtins-a.dataatendo) * 24) as decimal(15,2) ) qtdhorasint , ");
    sql.append(
        "cast( ( a.horaatendofin- a.horaatendo) / 60 / 60 as decimal(15,2) ) qtdhoras , ea.descespec, ea.codespec ");
    sql.append(
        "from atatendimento a, atatendente e, atespecatend ea where a.codemp=? and a.codfilial=? and a.dataatendo between ? and ? ");
    sql.append("and e.codemp=a.codempae  and e.codfilial=a.codfilialae");
    if (txtCodAtend.getVlrInteger() > 0) {
      sql.append(" and  a.codatend=? ");
    }
    sql.append(" and e.codatend=a.codatend ");
    if (!"".equals(txtCodUsu.getVlrString())) {
      sql.append(" and a.idusuins=? ");
    }
    sql.append(
        " and ea.codemp=a.codempea and ea.codfilial=a.codfilialea and ea.codespec=a.codespec ");
    sql.append("order by ");
    sql.append(cbOrdem.getVlrString());

    try {

      ps = con.prepareStatement(sql.toString());
      int param = 1;

      ps.setInt(param++, Aplicativo.iCodEmp);
      ps.setInt(param++, ListaCampos.getMasterFilial("ATATENDIMENTO"));
      ps.setDate(param++, Funcoes.dateToSQLDate(txtDataini.getVlrDate()));
      ps.setDate(param++, Funcoes.dateToSQLDate(txtDatafim.getVlrDate()));
      if (txtCodAtend.getVlrInteger() > 0) {
        ps.setInt(param++, txtCodAtend.getVlrInteger());
      }
      if (!"".equals(txtCodUsu.getVlrString())) {
        ps.setString(param++, txtCodUsu.getVlrString().toUpperCase());
      }
      rs = ps.executeQuery();

    } catch (Exception err) {
      Funcoes.mensagemErro(
          this, "Erro consulta Relatório de premiação!\n" + err.getMessage(), true, con, err);
      err.printStackTrace();
    }

    imprimiGrafico(bVisualizar, rs, sCab.toString(), fotoemp);
  }
Пример #6
0
  public void imprimir(TYPE_PRINT bVisualizar) {

    if (temAcessoConta()) {

      String sCodConta = txtCodConta.getVlrString();
      ResultSet rs = null;

      if (txtDatafim.getVlrDate().before(txtDataini.getVlrDate())) {
        Funcoes.mensagemInforma(this, "Data final maior que a data inicial!");
        return;
      } else if (txtCodConta.getVlrString().equals("")) {
        Funcoes.mensagemInforma(this, "Número da conta é requerido!");
        return;
      }

      StringBuilder sSQL = new StringBuilder();

      sSQL.append(
          "SELECT S.DATASL,L.HISTBLANCA,L.DOCLANCA,SL.VLRSUBLANCA,S.SALDOSL FROM FNSALDOLANCA S,");
      sSQL.append("FNLANCA L,FNCONTA C, FNSUBLANCA SL WHERE L.FLAG IN ");
      sSQL.append(
          AplicativoPD.carregaFiltro(con, org.freedom.library.swing.frame.Aplicativo.iCodEmp));
      sSQL.append(" AND C.CODEMP=? AND C.CODFILIAL=? AND C.NUMCONTA=? ");
      sSQL.append("AND L.CODEMP=? AND L.CODFILIAL=? AND L.CODLANCA=SL.CODLANCA ");
      sSQL.append(
          "AND S.CODPLAN=SL.CODPLAN AND S.CODEMP=SL.CODEMPPN AND S.CODFILIAL=SL.CODFILIALPN ");
      sSQL.append("AND SL.DATASUBLANCA BETWEEN ? AND ? AND S.DATASL=SL.DATASUBLANCA ");
      sSQL.append(
          "AND SL.CODPLAN=C.CODPLAN AND SL.CODEMPPN=C.CODEMPPN AND SL.CODFILIALPN=C.CODFILIALPN ");
      sSQL.append("AND SL.CODEMP=? AND SL.CODFILIAL=? ORDER BY S.DATASL,L.CODLANCA");

      try {

        PreparedStatement ps = con.prepareStatement(sSQL.toString());

        ps.setInt(1, Aplicativo.iCodEmp);
        ps.setInt(2, ListaCampos.getMasterFilial("FNCONTA"));
        ps.setString(3, sCodConta);
        ps.setInt(4, Aplicativo.iCodEmp);
        ps.setInt(5, ListaCampos.getMasterFilial("FNLANCA"));
        ps.setDate(6, Funcoes.dateToSQLDate(txtDataini.getVlrDate()));
        ps.setDate(7, Funcoes.dateToSQLDate(txtDatafim.getVlrDate()));
        ps.setInt(8, Aplicativo.iCodEmp);
        ps.setInt(9, ListaCampos.getMasterFilial("FNSUBLANCA"));

        rs = ps.executeQuery();

      } catch (Exception e) {

        e.printStackTrace();
        Funcoes.mensagemErro(this, "Erro ao buscar dados " + e.getMessage());
      }

      if ("T".equals(rgTipoRel.getVlrString())) {

        imprimiTexto(rs, bVisualizar, "");
      } else {
        imprimiGrafico(
            rs,
            bVisualizar,
            "Conta: " + txtCodConta.getVlrString() + " - " + txtDescConta.getVlrString());
      }
    } else {
      Funcoes.mensagemInforma(this, "Você não possui acesso a essa conta!");
    }
  }
Пример #7
0
  public void bloquear() {

    int iCodVenda = 0;
    String sTipoVenda = null;
    String sStatus = null;
    String sBloqVenda = null;
    String sSQL = null;
    String sSQL2 = null;
    String sTexto = null;
    Date dtIni = null;
    Date dtFim = null;
    PreparedStatement ps = null;
    PreparedStatement ps2 = null;
    ResultSet rs2 = null;

    try {
      iCodVenda = txtCodVenda.getVlrInteger().intValue();
      sTipoVenda = txtTipoVenda.getVlrString();
      sStatus = txtStatusVenda.getVlrString();
      sBloqVenda = cbBloquear.getVlrString();
      dtIni = txtDataIni.getVlrDate();
      dtFim = txtDataFim.getVlrDate();

      if ((iCodVenda == 0)
          && ((txtDataIni.getVlrString().trim().equals("")
              || txtDataFim.getVlrString().trim().equals("")))) {
        Funcoes.mensagemInforma(this, "Selecione uma venda ou período!");
        txtCodVenda.requestFocus();
        return;
      } else {
        if (sBloqVenda.equals("N")) sTexto = "desbloquear";
        else sTexto = "bloquear";
        if (iCodVenda != 0) {
          txtDataIni.setVlrString("");
          txtDataFim.setVlrString("");
          if (sStatus.substring(0, 1).equals("C")) {
            Funcoes.mensagemInforma(this, "Venda cancelada!");
            txtCodVenda.requestFocus();
            return;
          }
        } else {
          if (dtIni.compareTo(dtFim) > 0) {
            Funcoes.mensagemInforma(this, "Período inválido!");
            txtDataIni.requestFocus();
            return;
          }
        }
      }
      if (Funcoes.mensagemConfirma(this, "Deseja realmente " + sTexto + "?")
          == JOptionPane.YES_OPTION) {
        sSQL = "EXECUTE PROCEDURE VDBLOQVENDASP(?,?,?,?,?)";
        if (iCodVenda != 0) {
          ps = con.prepareStatement(sSQL);
          ps.setInt(1, Aplicativo.iCodEmp);
          ps.setInt(2, ListaCampos.getMasterFilial("VDVENDA"));
          ps.setString(3, sTipoVenda);
          ps.setInt(4, iCodVenda);
          ps.setString(5, sBloqVenda);
          ps.executeUpdate();
          ps.close();
          con.commit();
          lcVenda.carregaDados();
        } else {
          sSQL2 =
              "SELECT TIPOVENDA, CODVENDA "
                  + "FROM VDVENDA V WHERE CODEMP=? AND CODFILIAL=? AND "
                  + "DTEMITVENDA BETWEEN ? AND ? AND BLOQVENDA!=?";
          ps2 = con.prepareStatement(sSQL2);
          ps2.setInt(1, Aplicativo.iCodEmp);
          ps2.setInt(2, ListaCampos.getMasterFilial("VDVENDA"));
          ps2.setDate(3, Funcoes.dateToSQLDate(dtIni));
          ps2.setDate(4, Funcoes.dateToSQLDate(dtFim));
          ps2.setString(5, sBloqVenda);

          rs2 = ps2.executeQuery();
          while (rs2.next()) {
            ps = con.prepareStatement(sSQL);
            ps.setInt(1, Aplicativo.iCodEmp);
            ps.setInt(2, ListaCampos.getMasterFilial("VDVENDA"));
            ps.setString(3, rs2.getString("TIPOVENDA"));
            ps.setInt(4, rs2.getInt("CODVENDA"));
            ps.setString(5, sBloqVenda);
            ps.executeUpdate();
            ps.close();
          }
          rs2.close();
          ps2.close();
          con.commit();
        }
      }
    } catch (SQLException err) {
      Funcoes.mensagemErro(
          this, "Erro bloqueando ou desbloqueando venda!\n" + err.getMessage(), true, con, err);
    } finally {
      iCodVenda = 0;
      sTipoVenda = null;
      sStatus = null;
      sBloqVenda = null;
      sSQL = null;
      sSQL2 = null;
      sTexto = null;
      ps = null;
      rs2 = null;
      ps2 = null;
    }
  }
Пример #8
0
  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();
    }
  }
Пример #9
0
  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;
    boolean bFimDia = false;
    String sSQL = "";

    BigDecimal bTotalDiaVal = new BigDecimal("0");
    BigDecimal bTotalDiaDesc = new BigDecimal("0");
    BigDecimal bTotalDiaLiq = new BigDecimal("0");

    BigDecimal bTotalVal = new BigDecimal("0");
    BigDecimal bTotalDesc = new BigDecimal("0");
    BigDecimal bTotalLiq = new BigDecimal("0");

    imp.montaCab();
    String sDataini = "";
    String sDatafim = "";
    String sDtemitvenda = "";

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

    imp.setTitulo("Resumo Diário de Vendas");
    if (rgFormato.getVlrString().equals("D")) {
      sSQL =
          "SELECT V.DTEMITVENDA,V.CODTIPOMOV,V.CODVENDA,V.DOCVENDA,V.SERIE,"
              + "V.STATUSVENDA,V.DOCVENDA,"
              + "V.DTEMITVENDA,V.VLRPRODVENDA,V.VLRLIQVENDA,"
              + "V.CODPLANOPAG,P.DESCPLANOPAG,"
              + "V.VLRCOMISVENDA,V.VLRDESCITVENDA,"
              + "V.CODCLI,C.RAZCLI,V.STATUSVENDA"
              + " FROM VDVENDA V,VDCLIENTE C,FNPLANOPAG P, EQTIPOMOV TM "
              + "WHERE TM.CODTIPOMOV=V.CODTIPOMOV"
              + " AND TM.CODEMP=V.CODEMPTM"
              + " AND TM.CODFILIAL=V.CODFILIALTM"
              + " AND C.CODCLI=V.CODCLI"
              + " AND C.CODEMP=V.CODEMPCL AND C.CODFILIAL=V.CODFILIALCL"
              + " AND V.DTEMITVENDA BETWEEN ? AND ? AND "
              + "P.CODPLANOPAG=V.CODPLANOPAG AND V.FLAG IN "
              + AplicativoPD.carregaFiltro(con, org.freedom.library.swing.frame.Aplicativo.iCodEmp)
              + " AND V.CODEMP=? AND V.CODFILIAL=?"
              + " AND TM.TIPOMOV IN ('VD','PV','VT','SE')"
              + " AND NOT SUBSTR(V.STATUSVENDA,1,1)='C' ORDER BY V.DTEMITVENDA,V.DOCVENDA";
    } else if (rgFormato.getVlrString().equals("R")) {
      sSQL =
          "SELECT V.DTEMITVENDA,SUM(V.VLRLIQVENDA) FROM VDVENDA V,"
              + " EQTIPOMOV TM WHERE V.DTEMITVENDA BETWEEN ? AND ? AND V.FLAG IN "
              + AplicativoPD.carregaFiltro(con, org.freedom.library.swing.frame.Aplicativo.iCodEmp)
              + " AND TM.CODEMP=V.CODEMPTM"
              + " AND TM.CODFILIAL=V.CODFILIALTM"
              + " AND TM.CODTIPOMOV=V.CODTIPOMOV"
              + " AND TM.TIPOMOV IN ('VD','PV','VT','SE')"
              + " AND V.CODEMP=? AND V.CODFILIAL=? GROUP BY V.DTEMITVENDA";
      System.out.println(sSQL);
    }

    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
      ps = con.prepareStatement(sSQL);
      ps.setDate(1, Funcoes.dateToSQLDate(txtDataini.getVlrDate()));
      ps.setDate(2, Funcoes.dateToSQLDate(txtDatafim.getVlrDate()));
      ps.setInt(3, Aplicativo.iCodEmp);
      ps.setInt(4, ListaCampos.getMasterFilial("VDVENDA"));
      rs = ps.executeQuery();
      imp.limpaPags();

      if (rgFormato.getVlrString().equals("D")) {

        while (rs.next()) {

          if ((!StringFunctions.sqlDateToStrDate(rs.getDate("dtemitvenda")).equals(sDtemitvenda))
              & (bFimDia)) {
            imp.impCab(136, false);
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|");
            imp.say(
                imp.pRow() + 0,
                61,
                "Totais do Dia-> "
                    + sDtemitvenda
                    + " |"
                    + Funcoes.strDecimalToStrCurrency(10, 2, "" + bTotalDiaVal)
                    + Funcoes.strDecimalToStrCurrency(10, 2, "" + bTotalDiaDesc)
                    + Funcoes.strDecimalToStrCurrency(11, 2, "" + bTotalDiaLiq));
            imp.say(imp.pRow(), 136, "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
            bTotalDiaVal = new BigDecimal("0");
            bTotalDiaDesc = new BigDecimal("0");
            bTotalDiaLiq = new BigDecimal("0");
            bFimDia = false;
          }

          if (imp.pRow() >= (linPag - 1)) {
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
            imp.incPags();
            imp.eject();
          }

          if (imp.pRow() == 0) {
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "+" + StringFunctions.replicate("-", 134) + "+");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|   Emitido em :" + Funcoes.dateToStrDate(new Date()));
            imp.say(imp.pRow() + 0, 120, "Pagina : " + (imp.getNumPags()));
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|");
            imp.say(
                imp.pRow() + 0,
                5,
                "RESUMO DIARIO DE VENDAS   -   PERIODO DE :" + sDataini + " Até: " + sDatafim);
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|");
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "| Dt. Emissao");
            imp.say(imp.pRow() + 0, 17, "NF./Ped.");
            imp.say(imp.pRow() + 0, 31, "Cliente");
            imp.say(imp.pRow() + 0, 88, "|    Valor   Desconto " + "   Liquido F.Pagto.");
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
          }

          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, "|");
          if (!StringFunctions.sqlDateToStrDate(rs.getDate("dtemitvenda")).equals(sDtemitvenda)) {
            imp.say(imp.pRow() + 0, 3, StringFunctions.sqlDateToStrDate(rs.getDate("dtemitvenda")));
          }

          imp.say(
              imp.pRow() + 0,
              17,
              rs.getString("StatusVenda").substring(0, 1).equals("P")
                  ? "P-" + Funcoes.copy(rs.getString("codvenda"), 0, 6)
                  : "V-" + Funcoes.copy(rs.getString("docvenda"), 0, 6));

          imp.say(
              imp.pRow() + 0,
              31,
              Funcoes.copy(rs.getString("codcli"), 0, 7)
                  + "-"
                  + Funcoes.copy(rs.getString("razcli"), 0, 49)
                  + "|"
                  + Funcoes.strDecimalToStrCurrency(10, 2, rs.getString("vlrprodvenda"))
                  + Funcoes.strDecimalToStrCurrency(10, 2, rs.getString("vlrdescitvenda"))
                  + Funcoes.strDecimalToStrCurrency(11, 2, rs.getString("vlrliqvenda"))
                  + " "
                  + Funcoes.copy(rs.getString("descplanopag"), 0, 15)
                  + "|");

          if (rs.getString("VlrProdVenda") != null) {
            bTotalDiaVal = bTotalDiaVal.add(new BigDecimal(rs.getString("VlrProdVenda")));
            bTotalVal = bTotalVal.add(new BigDecimal(rs.getString("VlrProdVenda")));
          }

          if (rs.getString("VlrDescitvenda") != null) {
            bTotalDiaDesc = bTotalDiaDesc.add(new BigDecimal(rs.getString("VlrDescitVenda")));
            bTotalDesc = bTotalDesc.add(new BigDecimal(rs.getString("VlrDescitVenda")));
          }

          if (rs.getString("VlrLiqVenda") != null) {
            bTotalDiaLiq = bTotalDiaLiq.add(new BigDecimal(rs.getString("VlrLiqVenda")));
            bTotalLiq = bTotalLiq.add(new BigDecimal(rs.getString("VlrLiqVenda")));
          }

          bFimDia = true;
          sDtemitvenda = StringFunctions.sqlDateToStrDate(rs.getDate("Dtemitvenda"));
        }

        if (bFimDia) {
          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
          imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
          imp.say(imp.pRow() + 0, 0, "|");
          imp.say(
              imp.pRow() + 0,
              61,
              "Totais do Dia-> "
                  + sDtemitvenda
                  + " |"
                  + Funcoes.strDecimalToStrCurrency(10, 2, "" + bTotalDiaVal)
                  + Funcoes.strDecimalToStrCurrency(10, 2, "" + bTotalDiaDesc)
                  + Funcoes.strDecimalToStrCurrency(11, 2, "" + bTotalDiaLiq));
          imp.say(imp.pRow(), 136, "|");
        }

        imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
        imp.say(imp.pRow(), 0, "|" + StringFunctions.replicate("-", 134) + "|");
        imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
        imp.say(imp.pRow() + 0, 0, "|");
        imp.say(
            imp.pRow() + 0,
            72,
            "Totais Geral    |"
                + Funcoes.strDecimalToStrCurrency(10, 2, "" + bTotalVal)
                + Funcoes.strDecimalToStrCurrency(10, 2, "" + bTotalDesc)
                + Funcoes.strDecimalToStrCurrency(11, 2, "" + bTotalLiq));
        imp.say(imp.pRow(), 136, "|");

        imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
        imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");

      } else if (rgFormato.getVlrString().equals("R")) {
        iLinha = 1;
        iCol = 0;
        while (rs.next()) {
          if (imp.pRow() >= (linPag - 1)) {
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|" + StringFunctions.replicate("-", 134) + "|");
            imp.incPags();
            imp.eject();
          }
          if (imp.pRow() == 0) {
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "+" + StringFunctions.replicate("-", 134) + "+");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|   Emitido em :" + Funcoes.dateToStrDate(new Date()));
            imp.say(imp.pRow() + 0, 120, "Pagina : " + (imp.getNumPags()));
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|");
            imp.say(
                imp.pRow() + 0,
                5,
                "RESUMO DE TOTAL DE VENDAS - PERIODO DE :" + sDataini + " Até: " + sDatafim);
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "|" + StringFunctions.replicate("-", 134) + "|");
            imp.say(imp.pRow() + 1, 0, "" + imp.comprimido());
            imp.say(imp.pRow() + 0, 0, "|  Data");
            imp.say(imp.pRow() + 0, 14, "        Valor");
            imp.say(imp.pRow() + 0, 35, "|  Data");
            imp.say(imp.pRow() + 0, 49, "        Valor");
            imp.say(imp.pRow() + 0, 70, "|  Data");
            imp.say(imp.pRow() + 0, 84, "        Valor");
            imp.say(imp.pRow() + 0, 105, "|  Data");
            imp.say(imp.pRow() + 0, 119, "       Valor");
            imp.say(imp.pRow() + 0, 136, "|");
            imp.say(imp.pRow() + 1, 0, "|" + StringFunctions.replicate("-", 134) + "|");
          }

          imp.say(
              imp.pRow() + iLinha, iCol, "|  " + StringFunctions.sqlDateToStrDate(rs.getDate(1)));
          imp.say(
              imp.pRow() + 0,
              iCol + 14,
              " " + Funcoes.strDecimalToStrCurrency(15, 2, "" + rs.getString(2)));
          if (iCol == 0) {
            iLinha = 0;
            iCol = 35;
          } else if (iCol == 35) iCol = 70;
          else if (iCol == 70) iCol = 105;
          else {
            imp.say(imp.pRow() + 0, 136, "|");
            iCol = 0;
            iLinha = 1;
          }

          if (rs.getString(2) != null) {
            bTotalDiaLiq = bTotalDiaLiq.add(new BigDecimal(rs.getString(2)));
            bTotalLiq = bTotalLiq.add(new BigDecimal(rs.getString(2)));
          }
        }
      }
      if ((iCol < 105) && (iLinha == 0)) {
        imp.say(imp.pRow() + 0, 136, "|");
      }
      imp.say(imp.pRow() + 1, 0, "+" + StringFunctions.replicate("-", 134) + "+");
      imp.say(imp.pRow() + 1, 0, "|");
      imp.say(
          imp.pRow() + 0,
          88,
          "| Total Geral do Período   | " + Funcoes.strDecimalToStrCurrency(11, 2, "" + bTotalLiq));
      imp.say(imp.pRow(), 136, "|");
      imp.say(imp.pRow() + 1, 0, "+" + StringFunctions.replicate("-", 134) + "+");

      imp.eject();

      imp.fechaGravacao();

      // rs.close();
      // ps.close();
      con.commit();
      // dl.dispose();
    } catch (SQLException err) {
      Funcoes.mensagemErro(
          this, "Erro consulta tabela de vendas!" + err.getMessage(), true, con, err);
    }

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