Пример #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
  public Object[] loadReceber(
      Integer codemprc,
      Integer codfilialrc,
      Integer codempcl,
      Integer codfilialcl,
      Integer codcli,
      Integer codemppd,
      Integer codfilialpd,
      Integer codprod,
      Date dtini,
      Date dtfim)
      throws Exception {

    Object[] result = new Object[RESULT_RECEBER.values().length];
    try {
      StringBuilder sql = new StringBuilder();
      sql.append("select sum(ir.vlrapagitrec) total_aberto ");
      sql.append(
          ", sum(case when ir.dtvencitrec<cast('now' as date) then ir.vlrapagitrec else 0 end) total_atraso ");
      sql.append(", avg(case when ir.dtvencitrec<coalesce(ir.dtliqitrec,cast('now' as date)) ");
      sql.append(
          "then coalesce(ir.dtliqitrec,cast('now' as date)) - ir.dtvencitrec else 0 end) atraso_medio ");
      // sql.append( ", min(datarec), max(datarec) " );
      sql.append("from fnreceber rc, fnitreceber ir ");
      sql.append(
          "where rc.codemp=ir.codemp and rc.codfilial=ir.codfilial and rc.codrec=ir.codrec and ");
      sql.append(
          "ir.codemp=? and ir.codfilial=? and rc.codempcl=? and rc.codfilialcl=? and codcli=? ");
      sql.append("and ir.dtvencitrec between ? and ? ");
      PreparedStatement ps = getConn().prepareStatement(sql.toString());
      int param = 1;
      ps.setInt(param++, codemprc);
      ps.setInt(param++, codfilialrc);
      ps.setInt(param++, codempcl);
      ps.setInt(param++, codfilialcl);
      ps.setInt(param++, codcli);
      ps.setDate(param++, Funcoes.dateToSQLDate(dtini));
      ps.setDate(param++, Funcoes.dateToSQLDate(dtfim));
      ResultSet rs = ps.executeQuery();
      if (rs.next()) {
        // result[RESULT_RECEBER.TOTAL_VENDAS.ordinal()] = rs.getBigDecimal(
        // RESULT_RECEBER.TOTAL_VENDAS.name() );
        result[RESULT_RECEBER.TOTAL_ABERTO.ordinal()] =
            rs.getBigDecimal(RESULT_RECEBER.TOTAL_ABERTO.name());
        result[RESULT_RECEBER.TOTAL_ATRASO.ordinal()] =
            rs.getBigDecimal(RESULT_RECEBER.TOTAL_ATRASO.name());
        result[RESULT_RECEBER.ATRASO_MEDIO.ordinal()] =
            rs.getBigDecimal(RESULT_RECEBER.ATRASO_MEDIO.name());
      }
      rs.close();
      ps.close();
      getConn().commit();
    } catch (SQLException e) {
      getConn().rollback();
      throw new Exception(e.getMessage());
    }
    return result;
  }
Пример #3
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;
  }
Пример #4
0
 public Object[] loadUltimaVenda(
     Integer codempvd,
     Integer codfilialvd,
     Integer codempcl,
     Integer codfilialcl,
     Integer codcli,
     Date dtini,
     Date dtfim)
     throws Exception {
   Object[] result = new Object[RESULT_ULTVENDA.values().length];
   try {
     StringBuilder sql = new StringBuilder();
     sql.append("select first 1 v.dtemitvenda, v.vlrliqvenda, v.codvenda ");
     sql.append("from vdvenda v, vdcliente c ");
     sql.append(
         "where v.codemp=? and v.codfilial=? and v.tipovenda='V' and v.dtemitvenda between ? and ? ");
     sql.append("and c.codemp=v.codempcl and c.codfilial=v.codfilialcl and c.codcli=v.codcli ");
     sql.append("and c.codemp=? and c.codfilial=? and c.codcli=? ");
     sql.append("order by v.dtemitvenda desc, v.docvenda desc");
     PreparedStatement ps = getConn().prepareStatement(sql.toString());
     int param = 1;
     ps.setInt(param++, codempvd);
     ps.setInt(param++, codfilialvd);
     ps.setDate(param++, Funcoes.dateToSQLDate(dtini));
     ps.setDate(param++, Funcoes.dateToSQLDate(dtfim));
     ps.setInt(param++, codempcl);
     ps.setInt(param++, codfilialcl);
     ps.setInt(param++, codcli);
     ResultSet rs = ps.executeQuery();
     if (rs.next()) {
       result[RESULT_ULTVENDA.DTEMITVENDA.ordinal()] =
           rs.getDate(RESULT_ULTVENDA.DTEMITVENDA.name());
       result[RESULT_ULTVENDA.VLRLIQVENDA.ordinal()] =
           rs.getBigDecimal(RESULT_ULTVENDA.VLRLIQVENDA.name());
     }
   } catch (SQLException e) {
     getConn().rollback();
     throw new Exception(e.getMessage());
   }
   return result;
 }
Пример #5
0
  private boolean dbAbrirCaixa() {

    boolean abriuCaixa = false;

    if (!ecf.leituraX()) {
      Funcoes.mensagemErro(this, ecf.getMessageLog());
      return abriuCaixa;
    }
    if (!ecf.suprimento(txtValor.getVlrBigDecimal())) {
      Funcoes.mensagemErro(this, ecf.getMessageLog());
      return abriuCaixa;
    }

    try {

      PreparedStatement ps = con.prepareStatement("EXECUTE PROCEDURE PVABRECAIXASP(?,?,?,?,?,?,?)");

      ps.setInt(1, AplicativoPDV.iCodCaixa);
      ps.setInt(2, Aplicativo.iCodFilial);
      ps.setInt(3, Aplicativo.iCodEmp);
      ps.setBigDecimal(4, txtValor.getVlrBigDecimal());
      ps.setDate(5, Funcoes.dateToSQLDate(new Date()));
      ps.setInt(6, Aplicativo.iCodFilialPad);
      ps.setString(7, Aplicativo.getUsuario().getIdusu());
      ps.execute();

      ps.close();

      con.commit();

      abriuCaixa = true;

    } catch (SQLException e) {
      Funcoes.mensagemErro(this, "Erro ao abrir o caixa!\n" + e.getMessage(), true, con, e);
      e.printStackTrace();
    }

    ecf.abrirGaveta();

    return abriuCaixa;
  }
Пример #6
0
 public Vector<Vector<Object>> loadProdVendas(
     Integer codempvd,
     Integer codfilialvd,
     Integer codempcl,
     Integer codfilialcl,
     Integer codcli,
     Integer codemppd,
     Integer codfilialpd,
     Integer codprod,
     Date dtini,
     Date dtfim)
     throws Exception {
   Vector<Vector<Object>> result = new Vector<Vector<Object>>();
   try {
     StringBuilder sql = new StringBuilder();
     /*
     			STATUSVENDA, STATUSPGTO, CODVENDA, DOCVENDA, DTEMITVENDA, CODPROD, DESCPROD, QTDITVENDA, PRECOITVENDA, PERCDESCITVENDA
     , VLRDESCITVENDA, VLRLIQITVENDA, TIPOVENDA;*/
     sql.append("select pd.codprod, pd.descprod, max(vd.dtemitvenda) dtemitvenda ");
     sql.append("from vdvenda vd ");
     sql.append("inner join vditvenda iv ");
     sql.append(
         "on iv.codemp=vd.codemp and iv.codfilial=vd.codfilial and iv.tipovenda=vd.tipovenda and iv.codvenda=vd.codvenda ");
     sql.append("inner join eqproduto pd ");
     sql.append(
         "on pd.codemp=iv.codemppd and pd.codfilial=iv.codfilialpd and pd.codprod=iv.codprod ");
     sql.append("where vd.codemp=? and vd.codfilial=? and vd.dtemitvenda between ? and ? ");
     sql.append("and vd.tipovenda='V' and vd.codempcl=? and vd.codfilialcl=? and vd.codcli=? ");
     sql.append("and substring(vd.statusvenda from 1 for 1) not in ('C','N') ");
     sql.append("and pd.codemp=? and pd.codfilial=? ");
     if (codprod > 0) {
       sql.append("and pd.codprod=? ");
     }
     sql.append("group by 1, 2 ");
     sql.append("order by 3 desc, 2 ");
     PreparedStatement ps = getConn().prepareStatement(sql.toString());
     int iparam = 1;
     ps.setInt(iparam++, codempvd);
     ps.setInt(iparam++, codfilialvd);
     ps.setDate(iparam++, Funcoes.dateToSQLDate(dtini));
     ps.setDate(iparam++, Funcoes.dateToSQLDate(dtfim));
     ps.setInt(iparam++, codempcl);
     ps.setInt(iparam++, codfilialcl);
     ps.setInt(iparam++, codcli);
     ps.setInt(iparam++, codemppd);
     ps.setInt(iparam++, codfilialpd);
     if (codprod.intValue() > 0) {
       ps.setInt(iparam++, codprod);
     }
     ResultSet rs = ps.executeQuery();
     while (rs.next()) {
       Integer codprodvd = rs.getInt("CODPROD");
       Date dtemitvenda = rs.getDate("DTEMITVENDA");
       Vector<Object> row =
           loadProdItemVenda(
               codempvd,
               codfilialvd,
               dtemitvenda,
               codempcl,
               codfilialcl,
               codcli,
               codemppd,
               codfilialpd,
               codprodvd);
       result.addElement(row);
     }
     rs.close();
     ps.close();
     getConn().commit();
   } catch (SQLException e) {
     getConn().rollback();
     throw new Exception(e.getMessage());
   }
   return result;
 }
Пример #7
0
 public Vector<Object> loadProdItemVenda(
     Integer codempvd,
     Integer codfilialvd,
     Date dtemitvenda,
     Integer codempcl,
     Integer codfilialcl,
     Integer codcli,
     Integer codemppd,
     Integer codfilialpd,
     Integer codprod)
     throws Exception {
   Vector<Object> row = new Vector<Object>();
   try {
     StringBuilder sql = new StringBuilder();
     /*
     			STATUSVENDA, STATUSPGTO, CODVENDA, DOCVENDA, DTEMITVENDA, CODPROD, DESCPROD, QTDITVENDA, PRECOITVENDA, PERCDESCITVENDA
     , VLRDESCITVENDA, VLRLIQITVENDA, TIPOVENDA;*/
     sql.append("select first 1 vd.statusvenda, vd.codvenda, vd.docvenda, vd.dtemitvenda");
     sql.append(", pd.codprod, pd.descprod, iv.qtditvenda, iv.precoitvenda, iv.percdescitvenda ");
     sql.append(
         ", iv.vlrdescitvenda, iv.vlrliqitvenda, vd.tipovenda, vd.codplanopag, pg.descplanopag ");
     sql.append(", vo.codvend, vo.nomevend, ax.codalmox, ax.descalmox ");
     sql.append("from vdvenda vd ");
     sql.append("inner join vditvenda iv ");
     sql.append(
         "on iv.codemp=vd.codemp and iv.codfilial=vd.codfilial and iv.tipovenda=vd.tipovenda and iv.codvenda=vd.codvenda ");
     sql.append("and iv.codemppd=? and iv.codfilialpd=? and iv.codprod=? ");
     sql.append("inner join eqproduto pd ");
     sql.append(
         "on pd.codemp=iv.codemppd and pd.codfilial=iv.codfilialpd and pd.codprod=iv.codprod ");
     sql.append("inner join fnplanopag pg ");
     sql.append(
         "on pg.codemp=vd.codemppg and pg.codfilial=vd.codfilialpg and pg.codplanopag=vd.codplanopag ");
     sql.append("inner join vdvendedor vo ");
     sql.append(
         "on vo.codemp=vd.codempvd and vo.codfilial=vd.codfilialvd and vo.codvend=vd.codvend ");
     sql.append("inner join eqalmox ax ");
     sql.append(
         "on ax.codemp=pd.codempax and ax.codfilial=pd.codfilialax and ax.codalmox=pd.codalmox ");
     sql.append("where vd.codemp=? and vd.codfilial=? and vd.tipovenda='V' and dtemitvenda=? ");
     sql.append("and substring(vd.statusvenda from 1 for 1) not in ('C','N') ");
     sql.append("and vd.codempcl=? and vd.codfilialcl=? and vd.codcli=? ");
     sql.append("order by vd.dtemitvenda desc");
     PreparedStatement ps = getConn().prepareStatement(sql.toString());
     int iparam = 1;
     ps.setInt(iparam++, codemppd);
     ps.setInt(iparam++, codfilialpd);
     ps.setInt(iparam++, codprod);
     ps.setInt(iparam++, codempvd);
     ps.setInt(iparam++, codfilialvd);
     ps.setDate(iparam++, Funcoes.dateToSQLDate(dtemitvenda));
     ps.setInt(iparam++, codempcl);
     ps.setInt(iparam++, codfilialcl);
     ps.setInt(iparam++, codcli);
     ResultSet rs = ps.executeQuery();
     if (rs.next()) {
       String tipovenda = rs.getString("TIPOVENDA");
       Integer codvenda = rs.getInt("CODVENDA");
       String statusvenda = rs.getString("STATUSVENDA");
       java.sql.Date emaberto = null;
       Integer pago = null;
       Integer atraso = null;
       Object[] result_receber2 = loadReceber2(codempvd, codfilialvd, tipovenda, codvenda);
       if (result_receber2 != null) {
         pago = (Integer) result_receber2[RESULT_RECEBER2.PAGO.ordinal()];
         emaberto = (java.sql.Date) result_receber2[RESULT_RECEBER2.EMABERTO.ordinal()];
         atraso = (Integer) result_receber2[RESULT_RECEBER2.ATRASO.ordinal()];
       }
       imgColuna = getImgStatus(statusvenda);
       imgVencimento = getImgVencimento(statusvenda, emaberto, pago, atraso);
       row.addElement(imgColuna);
       row.addElement(imgVencimento);
       row.addElement(codvenda);
       row.addElement(rs.getString("DOCVENDA"));
       row.addElement(Funcoes.dateToStrDate(rs.getDate("DTEMITVENDA")));
       row.addElement(rs.getInt("CODPROD"));
       row.addElement(rs.getString("DESCPROD"));
       row.addElement(Funcoes.bdToStr(rs.getBigDecimal("QTDITVENDA")));
       row.addElement(Funcoes.bdToStr(rs.getBigDecimal("PRECOITVENDA")));
       row.addElement(Funcoes.bdToStr(rs.getBigDecimal("PERCDESCITVENDA")));
       row.addElement(Funcoes.bdToStr(rs.getBigDecimal("VLRDESCITVENDA")));
       row.addElement(Funcoes.bdToStr(rs.getBigDecimal("VLRLIQITVENDA")));
       row.addElement(tipovenda);
       row.addElement(rs.getInt("CODPLANOPAG"));
       row.addElement(rs.getString("DESCPLANOPAG"));
       row.addElement(rs.getInt("CODVEND"));
       row.addElement(rs.getString("NOMEVEND"));
       row.addElement(rs.getInt("CODALMOX"));
       row.addElement(rs.getString("DESCALMOX"));
     }
     rs.close();
     ps.close();
   } catch (SQLException e) {
     getConn().rollback();
     throw new Exception(e.getMessage());
   }
   return row;
 }
Пример #8
0
  public Vector<Vector<Object>> loadVendas(
      Integer codempvd,
      Integer codfilialvd,
      Integer codempcl,
      Integer codfilialcl,
      Integer codcli,
      Integer codemppd,
      Integer codfilialpd,
      Integer codprod,
      Date dtini,
      Date dtfim)
      throws Exception {
    Vector<Vector<Object>> result = new Vector<Vector<Object>>();
    try {
      StringBuilder sql = new StringBuilder();
      sql.append("select v.codvenda, v.docvenda, v.dtemitvenda, v.statusvenda, v.codplanopag");
      sql.append(
          ", p.descplanopag, v.codvend, vd.nomevend, coalesce(v.vlrprodvenda,0) vlrprodvenda, coalesce(v.vlrdescvenda,0) vlrdescvenda");
      sql.append(
          ", coalesce(v.vlradicvenda,0) vlradicvenda , coalesce(v.vlrfretevenda,0) vlrfretevenda, coalesce(v.vlrliqvenda,0) vlrliqvenda, v.tipovenda");
      sql.append(
          " , coalesce((select vf.tipofretevd from vdfretevd vf where vf.codemp = v.codemp and vf.codfilial = v.codfilial and vf.tipovenda = v.tipovenda and vf.codvenda = v.codvenda), 'N')  as tipofrete ");
      sql.append("from vdvenda v, fnplanopag p, vdvendedor vd, eqtipomov tm ");
      sql.append(
          "where v.codemp=? and v.codfilial=? and v.tipovenda='V' and v.dtemitvenda between ? and ?");
      // sql.append( "and substring( v.statusvenda from 1 for 1) not in ('D','C') ");
      sql.append(
          "and p.codemp=v.codemppg and p.codfilial=v.codfilialpg and p.codplanopag=v.codplanopag ");
      sql.append(
          "and vd.codemp=v.codempvd and vd.codfilial=v.codfilialvd and vd.codvend=v.codvend");
      if (codcli.intValue() > 0) {
        sql.append(" and v.codempcl=? and v.codfilialcl=? AND codcli=? ");
      }
      if (codprod > 0) {
        sql.append(" and exists (");
        sql.append(" select codvenda from vditvenda iv where ");
        sql.append(
            " iv.codemp=v.codemp and iv.codfilial=v.codfilial and iv.codvenda=v.codvenda and iv.tipovenda=v.tipovenda ");
        sql.append(" and iv.codemppd=? and iv.codfilialpd=? and iv.codprod=? ) ");
      }
      sql.append(
          " and tm.codemp=v.codemptm and tm.codfilial=v.codfilialtm and tm.codtipomov=v.codtipomov ");
      sql.append(" and tm.somavdtipomov='S' ");
      sql.append(" order by v.dtemitvenda desc, v.docvenda desc");
      PreparedStatement ps = getConn().prepareStatement(sql.toString());
      int iparam = 1;
      ps.setInt(iparam++, codempvd);
      ps.setInt(iparam++, codfilialvd);
      ps.setDate(iparam++, Funcoes.dateToSQLDate(dtini));
      ps.setDate(iparam++, Funcoes.dateToSQLDate(dtfim));
      if (codcli.intValue() > 0) {
        ps.setInt(iparam++, codempcl);
        ps.setInt(iparam++, codfilialcl);
        ps.setInt(iparam++, codcli);
      }
      if (codprod.intValue() > 0) {
        ps.setInt(iparam++, codemppd);
        ps.setInt(iparam++, codfilialpd);
        ps.setInt(iparam++, codprod);
      }
      ResultSet rs = ps.executeQuery();

      while (rs.next()) {
        Vector<Object> row = new Vector<Object>();
        String tipovenda = rs.getString("TIPOVENDA");
        Integer codvenda = rs.getInt("CODVENDA");
        String statusvenda = rs.getString("STATUSVENDA");
        java.sql.Date emaberto = null;
        Integer pago = null;
        Integer atraso = null;
        StringDireita stratraso = new StringDireita("");
        Object[] result_receber2 = loadReceber2(codempvd, codfilialvd, tipovenda, codvenda);
        if (result_receber2 != null) {
          pago = (Integer) result_receber2[RESULT_RECEBER2.PAGO.ordinal()];
          emaberto = (java.sql.Date) result_receber2[RESULT_RECEBER2.EMABERTO.ordinal()];
          atraso = (Integer) result_receber2[RESULT_RECEBER2.ATRASO.ordinal()];
          if ((atraso != null) && (atraso.intValue() != 0)) {
            stratraso = new StringDireita(atraso.toString());
          }
        }
        imgColuna = getImgStatus(statusvenda);
        imgVencimento = getImgVencimento(statusvenda, emaberto, pago, atraso);
        row.addElement(imgColuna);
        row.addElement(imgVencimento);
        row.addElement(stratraso);
        row.addElement(codvenda);
        row.addElement(rs.getString("DOCVENDA"));
        row.addElement(Funcoes.dateToStrDate(rs.getDate("DTEMITVENDA")));
        row.addElement(rs.getString("DESCPLANOPAG"));
        row.addElement(rs.getString("NOMEVEND"));
        row.addElement(Funcoes.bdToStr(rs.getBigDecimal("VLRPRODVENDA")));
        row.addElement(Funcoes.bdToStr(rs.getBigDecimal("VLRDESCVENDA")));
        row.addElement(Funcoes.bdToStr(rs.getBigDecimal("VLRADICVENDA")));
        row.addElement(getTipoFrete(rs.getString("TIPOFRETE")));
        row.addElement(Funcoes.bdToStr(rs.getBigDecimal("VLRLIQVENDA")));
        row.addElement(tipovenda);
        result.addElement(row);
      }
      rs.close();
      ps.close();
      getConn().commit();
    } catch (SQLException e) {
      getConn().rollback();
      throw new Exception(e.getMessage());
    }
    return result;
  }
Пример #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;
    }

    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!");
    }
  }
Пример #10
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);
  }
Пример #11
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!");
    }
  }
Пример #12
0
  private void criarInventario() {

    try {

      // para evitar de dar o commit no meio do loop e o rollback de erro não adiantar.
      final boolean commit = con.getConnection().getAutoCommit();
      con.setAutoCommit(false);

      int tamanhoTabela = tabProdutos.getNumLinhas();

      status.setString("Realizando inventarios ...");
      status.setMaximum(tamanhoTabela);

      StringBuilder sql = new StringBuilder();
      sql.append("INSERT INTO EQINVPROD ");
      sql.append("(CODEMP, CODFILIAL, CODINVPROD, ");
      sql.append("CODEMPPD, CODFILIALPD, CODPROD, ");
      sql.append("CODEMPTM, CODFILIALTM, CODTIPOMOV, ");
      sql.append("DATAINVP, QTDINVP, SLDATUALINVP, SLDDIGINVP, PRECOINVP, ");
      sql.append("CODEMPAX, CODFILIALAX, CODALMOX) ");
      sql.append("VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ");

      final Integer tipoMovimentoInventario = getTipoMovimentoInventario();
      final Date hoje = Funcoes.dateToSQLDate(Calendar.getInstance().getTime());
      Integer codprod = null;
      BigDecimal saldoAtual = null;
      BigDecimal novoSaldo = null;
      BigDecimal quantidade = null;
      BigDecimal custo = null;

      Integer codInventario = null;
      Integer codAlmoarifado = null;

      PreparedStatement ps = null;

      for (int i = 0; i < tamanhoTabela; i++) {

        codprod = (Integer) tabProdutos.getValor(i, 0);
        saldoAtual = getSaldoAtual(codprod);
        novoSaldo = (BigDecimal) tabProdutos.getValor(i, 3);
        quantidade = novoSaldo.subtract(saldoAtual);
        custo = (BigDecimal) tabProdutos.getValor(i, 2);

        codInventario = getCodInventario();
        codAlmoarifado = getAlmoxarifado(codprod);

        ps = con.prepareStatement(sql.toString());
        ps.setInt(1, Aplicativo.iCodEmp);
        ps.setInt(2, ListaCampos.getMasterFilial("EQINVPROD"));
        ps.setInt(3, codInventario);
        ps.setInt(4, Aplicativo.iCodEmp);
        ps.setInt(5, ListaCampos.getMasterFilial("EQPRODUTO"));
        ps.setInt(6, codprod); // código do produto.
        ps.setInt(7, Aplicativo.iCodEmp);
        ps.setInt(8, ListaCampos.getMasterFilial("EQTIPOMOV"));
        ps.setInt(9, tipoMovimentoInventario); // código do tipo de movimento de inventário.
        ps.setDate(10, hoje);
        ps.setBigDecimal(11, quantidade);
        ps.setBigDecimal(12, saldoAtual);
        ps.setBigDecimal(13, novoSaldo);
        ps.setBigDecimal(14, custo);
        ps.setInt(15, Aplicativo.iCodEmp);
        ps.setInt(16, ListaCampos.getMasterFilial("EQALMOX"));
        ps.setInt(17, codAlmoarifado);
        ps.execute();

        status.setValue(i + 1);
      }

      status.setString("Concluido !");
      btInventario.setEnabled(false);

      con.setAutoCommit(commit);

      con.commit();

    } catch (Exception e) {
      e.printStackTrace();
      Funcoes.mensagemErro(this, "Erro ao realizar inventáros!\n" + e.getMessage(), true, con, e);
      try {
        con.rollback();
        rgModo.setVlrInteger(IMPORTAR);
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
    }
  }
Пример #13
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;
    }
  }
Пример #14
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();
    }
  }