Exemplo n.º 1
0
        protected void ExibirRelatorio(byte[] bytBuffer, TipoRelatorioEnum objTipoRelatorio)
        {
            FileStream objFileStream = null;

            try
            {
                string strTempPath = Path.GetTempPath();
                string strExtensao = ".pdf";
                string strTempFile = strTempPath + this.NomeArquivoRelatorio + DateTime.Now.ToString("dd_MM_yyyy-HH_mm_ss") + strExtensao;

                objFileStream = new FileStream(strTempFile, FileMode.Create);
                objFileStream.Write(bytBuffer, 0, bytBuffer.Length);
                objFileStream.Close();

                Process.Start(strTempFile);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                objFileStream = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gera os dados de cabeçalho e detalhes de um relatório, de forma genérica
        /// </summary>
        /// <param name="tipoRelatorio"></param>
        /// <returns></returns>
        public Relatorio GerarRelatorio(TipoRelatorioEnum tipoRelatorio, long idLoja, string ciclo)
        {
            var retorno     = new Relatorio();
            var commandText = string.Empty;

            switch (tipoRelatorio)
            {
            case TipoRelatorioEnum.ExibirTerminaisAchados:
                commandText = RelatorioSQL.ListarExibirTerminaisAchadosCabecalho;
                break;

            case TipoRelatorioEnum.ExibirTerminaisPagosSemVenda:
                commandText = RelatorioSQL.ListarExibirTerminaisPagosSemVendaCabecalho;
                break;

            default:
                break;
            }

            var parametros = new Dictionary <string, object>
            {
                { "idLoja", idLoja },
                { "ciclo", ciclo }
            };

            var linhasCabecalho = contexto.ExecutaComandoComRetorno(commandText, parametros);

            foreach (var row in linhasCabecalho)
            {
                var cabecalho = new RelatorioCabecalho
                {
                    ciclo                = row["ciclo"],
                    telefone             = row["telefone"],
                    total                = row["total"].ToDecimal(),
                    idStatus             = row["idStatus"].ToLong(),
                    nomeStatus           = row["nomeStatus"],
                    idImportacaoPlanilha = row["idImportacaoPlanilha"].ToLong()
                };

                cabecalho.Detalhes = GerarRelatorioDetalhes(tipoRelatorio, cabecalho);

                switch (tipoRelatorio)
                {
                case TipoRelatorioEnum.ExibirTerminaisAchados:
                    retorno.ExibirTerminaisAchados.Add(cabecalho);
                    break;

                case TipoRelatorioEnum.ExibirTerminaisPagosSemVenda:
                    retorno.ExibirTerminaisPagosSemVenda.Add(cabecalho);
                    break;

                default:
                    break;
                }
            }

            return(retorno);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Exibe somatoria de todos os ciclos, para gerar o relatório
        /// </summary>
        /// <param name="tipoRelatorio"></param>
        /// <returns></returns>
        public Relatorio ListarRelatorio(long?idLoja, TipoRelatorioEnum tipoRelatorio)
        {
            var retornoLista = new List <RelatorioCabecalho>();
            var commandText  = string.Empty;

            switch (tipoRelatorio)
            {
            case TipoRelatorioEnum.ExibirTerminaisAchados:
                commandText = RelatorioSQL.ListarExibirTerminaisAchadosTotal;
                break;

            case TipoRelatorioEnum.ExibirTerminaisPagosSemVenda:
                commandText = RelatorioSQL.ListarExibirTerminaisPagosSemVendaTotal;
                break;

            default:
                break;
            }

            var parametros = new Dictionary <string, object>
            {
                { "idLoja", idLoja }
            };

            var linhas = contexto.ExecutaComandoComRetorno(commandText, parametros);

            foreach (var row in linhas)
            {
                var relatorio = new RelatorioCabecalho
                {
                    idLoja     = row["idLoja"].ToLong(),
                    nomeLoja   = row["nomeLoja"],
                    ciclo      = row["ciclo"],
                    total      = row["total"].ToDecimal(),
                    nomeStatus = row["nomeStatus"],
                };

                retornoLista.Add(relatorio);
            }

            var retornoRelatorio = new Relatorio();

            switch (tipoRelatorio)
            {
            case TipoRelatorioEnum.ExibirTerminaisAchados:
                retornoRelatorio.ExibirTerminaisAchados = retornoLista;
                break;

            case TipoRelatorioEnum.ExibirTerminaisPagosSemVenda:
                retornoRelatorio.ExibirTerminaisPagosSemVenda = retornoLista;
                break;

            default:
                break;
            }

            return(retornoRelatorio);
        }
Exemplo n.º 4
0
 public Relatorio ListarRelatorio(long?idLoja, TipoRelatorioEnum tipoRelatorio)
 {
     return(_dal.ListarRelatorio(idLoja, tipoRelatorio));
 }
Exemplo n.º 5
0
        protected byte[] ConverterReportViewerParaVisualizar(ReportViewer rpvRelatorio, TipoRelatorioEnum objTipoRelatorio)
        {
            try
            {
                Warning[] warnings;
                string[]  streamids;
                string    mimeType;
                string    encoding;
                string    extension;

                if (objTipoRelatorio.Equals(TipoRelatorioEnum.PDF))
                {
                    return(rpvRelatorio.LocalReport.Render("Pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings));
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                //ExcecaoGS300(ex);
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gera os detalhes de um relatorio, de forma genérica
        /// </summary>
        /// <param name="tipoRelatorio"></param>
        /// <param name="cabecalho"></param>
        /// <returns></returns>
        private List <RelatorioDetalhe> GerarRelatorioDetalhes(TipoRelatorioEnum tipoRelatorio, RelatorioCabecalho cabecalho)
        {
            var retornoLista = new List <RelatorioDetalhe>();
            var commandText  = string.Empty;
            var numeroLinha  = 1;

            switch (tipoRelatorio)
            {
            case TipoRelatorioEnum.ExibirTerminaisAchados:
                commandText = RelatorioSQL.ListarExibirTerminaisAchadosDetalhe;
                break;

            case TipoRelatorioEnum.ExibirTerminaisPagosSemVenda:
                commandText = RelatorioSQL.ListarExibirTerminaisPagosSemVendaDetalhe;
                break;

            default:
                break;
            }

            var parametros = new Dictionary <string, object>
            {
                { "ciclo", cabecalho.ciclo },
                { "telefone", cabecalho.telefone },
                { "idStatus", cabecalho.idStatus }
            };

            #region PrimeiraLinha

            //var primeiraLinha = new RelatorioDetalhe
            //{
            //    telefone = cabecalho.telefone,
            //    numeroLinha = numeroLinha++
            //};

            //retornoLista.Add(primeiraLinha);

            #endregion

            var linhasDetalhes = contexto.ExecutaComandoComRetorno(commandText, parametros);
            foreach (var row in linhasDetalhes)
            {
                var detalhe = new RelatorioDetalhe
                {
                    id                   = row["id"].ToLong(),
                    ciclo                = row["ciclo"],
                    descricao            = row["descricao"],
                    dataEvento           = row["dataEvento"].ToDateTime(),
                    telefone             = row["telefone"],
                    valorPago            = row["valorPago"].ToDecimal(),
                    idStatus             = row["idStatus"].ToLong(),
                    nomeStatus           = row["nomeStatus"],
                    idImportacaoPlanilha = row["idImportacaoPlanilha"].ToLong(),
                    numeroLinha          = numeroLinha++
                };

                retornoLista.Add(detalhe);
            }

            #region UltimaLinha

            var ultimaLinha = new RelatorioDetalhe
            {
                telefone    = cabecalho.telefone,
                descricao   = "Total",
                valorPago   = cabecalho.total,
                numeroLinha = numeroLinha++
            };

            retornoLista.Add(ultimaLinha);

            #endregion

            return(retornoLista.OrderBy(p => p.numeroLinha).ToList());
        }