コード例 #1
0
        protected void grdExtratoPrevidenciario_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string[] Args = e.CommandArgument.ToString().Split(',');


            switch (e.CommandName)
            {
            case "Visualizar":
                if (InicializaRelatorio(Args[0], Args[1], Args[2]))
                {
                    //ReportCrystal.VisualizaRelatorio();
                    //ReportCrystal.Visible = true;
                    ArquivoDownload adExtratoPdf = new ArquivoDownload();
                    adExtratoPdf.nome_arquivo    = nome_anexo_extrato + Args[2].Replace("/", "_") + ".pdf";
                    adExtratoPdf.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + Args[0] + "_" + Args[1] + "_" + adExtratoPdf.nome_arquivo;
                    adExtratoPdf.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;
                    ReportCrystal.ExportarRelatorioPdf(adExtratoPdf.caminho_arquivo);

                    Session[ValidaCaracteres(adExtratoPdf.nome_arquivo)] = adExtratoPdf;
                    string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adExtratoPdf.nome_arquivo);
                    AdicionarAcesso(fullUrl);
                    AbrirNovaAba(UpdatePanel, fullUrl, adExtratoPdf.nome_arquivo);
                }
                break;

            case "Email":

                //if (InicializaDadosEMail(Args[0], Args[1], Args[2], Args[3], Args[4], Args[5], Args[6]))
                //{
                //    EnviaEmailCredito(txtEMail.Text);
                //}
                break;
            }
        }
コード例 #2
0
        public void GeraRelatorio(Relatorio rels)
        {
            DataTable dt = rel.ListarDinamico(rels);

            if (dt.Rows.Count > 2) //Revisar este ponto pois a proc não poderia gerar linhas
            {
                lblRegistros.Text    = "A remessa contém " + dt.Rows.Count.ToString() + " linhas";
                lblRegistros.Visible = true;
                //Dictionary<string, DataTable> dtRelatorio = new Dictionary<string, DataTable>();
                //var nomeArquivo = Convert.ToString(DateTime.Today.Year) + "_" + Convert.ToString(DateTime.Today.Month) + "_" + Convert.ToString(DateTime.Today.Day) + "_" + rels.relatorio + "." + rels.relatorio_extensao;
                foreach (DataRow row in dt.Rows)
                {
                    row[0] = BasePage.ValidaCaracteres(row[0].ToString());
                }
                ;
                ArquivoDownload txtSERASA = new ArquivoDownload();
                txtSERASA.dados        = dt;
                txtSERASA.nome_arquivo = Convert.ToString(DateTime.Today.Year) + "_" +
                                         Convert.ToString(DateTime.Today.Month) + "_" +
                                         Convert.ToString(DateTime.Today.Day) + "_" +
                                         rels.relatorio + "." +
                                         rels.relatorio_extensao;
                Session[txtSERASA.nome_arquivo] = txtSERASA;
                BasePage.AbrirNovaAba(upExcel, "WebFile.aspx?dwFile=" + txtSERASA.nome_arquivo, txtSERASA.nome_arquivo);
            }
            else
            {
                objPage.MostraMensagemTelaUpdatePanel(upExcel, "Atenção!! \\n\\nNão foram encontrados dados para exportar.\\n\\nVerifique planilha e importe novamente.");
            }
        }
コード例 #3
0
        private bool InicializaDadosEMail(string CodEmpresa, string CodMatricula, string NumIdntfRptant, string NumSubMatric, string DatIni, string DatFim, string DatPagamento)
        {
            txtEMail.Text = txtEMail.Text.Trim();

            if (String.IsNullOrEmpty(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail obrigatório");
                return(false);
            }
            else if (!Util.ValidaEmail(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail inválido");
                return(false);
            }

            CreditoReembolsoBLL CredReeBLL = new CreditoReembolsoBLL();
            int iRepresentante             = 0;

            int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);
            epDados = CredReeBLL.Consultar(int.Parse(CodEmpresa), int.Parse(CodMatricula), iRepresentante, NumSubMatric, DateTime.Parse(DatIni), DateTime.Parse(DatFim));

            if (String.IsNullOrEmpty(epDados.empresa) && String.IsNullOrEmpty(epDados.registro))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nDados não localizados para a matrícula " + CodMatricula);
                return(false);
            }

            ArquivoDownload newAd = new ArquivoDownload();

            newAd.nome_arquivo = nome_anexo + DatPagamento.Replace("/", "_") + ".pdf";
            newAd.dados        = ReportCrystal.ExportarRelatorioPdf();
            lstAdPdf.Add(newAd);

            return(true);
        }
コード例 #4
0
        public void GeraRelatorio(DataTable dt, ArquivoDownload XlsBaseDados, ArquivoDownload TxtDistribuido)
        {
            if (dt.Rows.Count > 0)
            {
                ArquivoDownload XlsDistribuicao = new ArquivoDownload();
                XlsDistribuicao.dados        = dt;
                XlsDistribuicao.nome_arquivo = Convert.ToString(DateTime.Today.Year) + "_" + Convert.ToString(DateTime.Today.Month) + "_" + Convert.ToString(DateTime.Today.Day) + "_DISTRIBUICAO_BOLETAS.xls";
                string fullUrl = "";

                Session[XlsDistribuicao.nome_arquivo] = XlsDistribuicao;
                fullUrl = "WebFile.aspx?dwFile=" + XlsDistribuicao.nome_arquivo;
                AdicionarAcesso(fullUrl);
                AbrirNovaAba(this, fullUrl, XlsDistribuicao.nome_arquivo);

                Session[XlsBaseDados.nome_arquivo] = XlsBaseDados;
                fullUrl = "WebFile.aspx?dwFile=" + XlsBaseDados.nome_arquivo;
                AdicionarAcesso(fullUrl);
                AbrirNovaAba(this, fullUrl, XlsBaseDados.nome_arquivo);

                Session[TxtDistribuido.nome_arquivo] = TxtDistribuido;
                fullUrl = "WebFile.aspx?dwFile=" + TxtDistribuido.nome_arquivo;
                AdicionarAcesso(fullUrl);
                AbrirNovaAba(this, fullUrl, TxtDistribuido.nome_arquivo);
            }
        }
コード例 #5
0
        public async Task <IActionResult> Exportar()
        {
            UsuarioADE usuario = await ObterUsuarioLogado();

            try
            {
                Documento tabela = new Documento();
                tabela.IdCursoNavigation = await _cursoServices.BuscarPorId(usuario.IdCurso);

                tabela.IdCursoNavigation.Instituicao = await _servicoInstituicao.BuscarPorId(tabela.IdCursoNavigation.IdInstituicao);

                RequisitosBasicosCabecalho requisitosFicha = await ObterRequisitosBasicosUsuario(usuario);

                ArquivoDownload Arquivo = await servicoRegistroDeHoras.GerarTabelaHistorico(usuario, tabela, requisitosFicha);

                //await _atividadeEstagioServices.VerificarTarefasEConcluir(usuario, EnumEntidadesSistema., tabela.Identificador, EnumTipoAtividadeEstagio.DownloadOuImpressao, 1);
                return(File(Arquivo.Bytes, Arquivo.TipoArquivo, $"Tabela de Registro de Horas - {usuario.ToString()}.docx"));
            }
            catch (Exception ex)
            {
                System.Threading.Thread.Sleep(3000);
                await LogError($"{ex.Message}", "RegistroHoras", EnumTipoLog.ImpressaoArquivo);
            }
            ViewBag.Retorno = "É necessário ao menos um registro para realizar a exportação do histórico.";
            ModelState.AddModelError("Falha", ViewBag.Retorno);
            return(View("Index"));
        }
コード例 #6
0
        protected void btnExportar_Click(object sender, EventArgs e)
        {
            AtualizaCcLoteBLL bll = new AtualizaCcLoteBLL();

            DataTable dt = bll.ListarDadosParaExcel(Util.String2Short(txtEmpresa.Text), Util.String2Date(txtProcessamentoIni.Text),
                                                    Util.String2Date(txtProcessamentoFim.Text),
                                                    Util.String2Int32(txtMatricula.Text),
                                                    Util.String2Int32(txtRepresentante.Text),
                                                    txtNome.Text,
                                                    Util.String2Int64(txtCpf.Text),
                                                    Util.String2Short(txtBanco.Text),
                                                    Util.String2Int32(txtAgencia.Text),
                                                    txtTipConta.Text,
                                                    txtNumConta.Text);

            //Download do Excel
            ArquivoDownload adXlsHistConta = new ArquivoDownload();

            adXlsHistConta.nome_arquivo = "Arquivo_Exportado.xls";
            //adTxtRecad.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtRecad.nome_arquivo;
            adXlsHistConta.dados = dt;
            Session[ValidaCaracteres(adXlsHistConta.nome_arquivo)] = adXlsHistConta;
            string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsHistConta.nome_arquivo);

            //AdicionarAcesso(fUrl);
            AbrirNovaAba(upUpdatePanel, fUrl, adXlsHistConta.nome_arquivo);
        }
コード例 #7
0
        private bool InicializaDadosEMail(int pCOD_BOLETO, int?pNUM_DCMCOB_BLPGT = 0, string TIPO_BOLETO = "")
        {
            txtEMail.Text = txtEMail.Text.Trim();

            if (String.IsNullOrEmpty(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail obrigatório");
                return(false);
            }
            else if (!Util.ValidaEmail(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail inválido");
                return(false);
            }

            //ExtratoUtilizacaoBLL ExtUtilBLL = new ExtratoUtilizacaoBLL();
            //int iRepresentante = 0;
            //int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);
            //epDados = ExtUtilBLL.Consultar(int.Parse(CodEmpresa), int.Parse(CodMatricula), iRepresentante, DateTime.Parse(DatIni), DateTime.Parse(DatFim));
            //epDados.usuario = ddlRepresentante.SelectedItem.Text;

            //if (String.IsNullOrEmpty(epDados.empresa) && String.IsNullOrEmpty(epDados.registro))
            //{
            //    MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nDados não localizados para a matrícula " + CodMatricula);
            //    return false;
            //}

            ArquivoDownload newAd = new ArquivoDownload();

            newAd.nome_arquivo = nome_anexo + TIPO_BOLETO + "_" + pNUM_DCMCOB_BLPGT.ToString() + ".pdf";
            newAd.dados        = ReportCrystal.ExportarRelatorioPdf();
            lstAdPdf.Add(newAd);

            return(true);
        }
コード例 #8
0
        protected void btnSubmit_Gerar_Click(object sender, EventArgs e)
        {
            EmprestimoDescontoBLL bll = new EmprestimoDescontoBLL();
            Resultado             res = new Resultado();

            //Download do TXT
            ArquivoDownload adTxtEntidade = new ArquivoDownload();

            adTxtEntidade.nome_arquivo    = String.Format("entidade_externa_{0}.txt", ddlMesRef.SelectedValue.PadLeft(2, '0') + ddlAnoRef.SelectedValue);
            adTxtEntidade.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtEntidade.nome_arquivo;
            adTxtEntidade.dados           = null;
            Session[ValidaCaracteres(adTxtEntidade.nome_arquivo)] = adTxtEntidade;

            res = bll.GerarTxt(ddlMesRef.SelectedValue, ddlAnoRef.SelectedValue, adTxtEntidade.caminho_arquivo);
            if (res.Ok)
            {
                string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adTxtEntidade.nome_arquivo);
                AbrirNovaAba(upUpdatePanel, fUrl, adTxtEntidade.nome_arquivo);

                //Download do Excel
                ArquivoDownload adRelEmprestimo = new ArquivoDownload();
                adRelEmprestimo.nome_arquivo    = String.Format("Rel_Margem_Emprestimo_{0}.xls", ddlMesRef.SelectedValue.PadLeft(2, '0') + ddlAnoRef.SelectedValue);
                adRelEmprestimo.caminho_arquivo = null;
                adRelEmprestimo.dados           = bll.GerarDataTable(ddlMesRef.SelectedValue, ddlAnoRef.SelectedValue, 4);
                Session[ValidaCaracteres(adRelEmprestimo.nome_arquivo)] = adRelEmprestimo;
                fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adRelEmprestimo.nome_arquivo);

                AbrirNovaAba(upUpdatePanel, fUrl, adRelEmprestimo.nome_arquivo);
                MostraMensagem(lblMensagemInicial, res.Mensagem, "n_ok");
            }
            else
            {
                MostraMensagem(lblMensagemInicial, res.Mensagem, (res.Alerta ? "n_warning" : "n_error"));
            }
        }
コード例 #9
0
        public void VisualizarPdf(ReportDocument relatorio, ParameterFields paramFields, string caminho)
        {
            CrystalReportViewer1.ReportSource       = relatorio;
            CrystalReportViewer1.ParameterFieldInfo = paramFields;

            ArquivoDownload adExtratoPdf = new ArquivoDownload();

            adExtratoPdf.nome_arquivo    = "Aviso_pagto" + DateTime.Now.ToFileTime() + ".pdf";
            adExtratoPdf.caminho_arquivo = Server.MapPath(@"UploadFile\") + adExtratoPdf.nome_arquivo;
            adExtratoPdf.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;

            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();

            CrDiskFileDestinationOptions.DiskFileName = adExtratoPdf.caminho_arquivo;
            CrExportOptions = relatorio.ExportOptions;//Report document  object has to be given here
            CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
            CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
            CrExportOptions.FormatOptions         = CrFormatTypeOptions;

            relatorio.Export();

            Session[ValidaCaracteres(adExtratoPdf.nome_arquivo)] = adExtratoPdf;
            string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adExtratoPdf.nome_arquivo);

            AdicionarAcesso(fullUrl);
            //AbrirNovaAba(this, fullUrl, adExtratoPdf.nome_arquivo);
            Response.Redirect(fullUrl);
            //((BasePage)this.Page).ResponsePdf(adExtratoPDF.caminho_arquivo, adExtratoPDF.nome_arquivo);
            //ResponsePdf(adExtratoPDF.caminho_arquivo, adExtratoPDF.nome_arquivo);
        }
コード例 #10
0
        protected void btnExportar_Click(object sender, EventArgs e)
        {
            DebitoContaBLL bll = new DebitoContaBLL();
            DataTable      dt  = bll.ListarDadosParaExcel(Util.String2Short(txtPesqEmpresa.Text),
                                                          Util.String2Int32(txtPesqMatricula.Text),
                                                          Util.String2Int32(txtPesqRepresentante.Text),
                                                          Util.String2Int64(txtPesqCpf.Text),
                                                          txtPesNome.Text);

            //DataTable dt = bll.GetWhere(Util.String2Short(txtPesqEmpresa.Text),
            //                            Util.String2Int32(txtPesqMatricula.Text),
            //                            Util.String2Int32(txtPesqRepresentante.Text),
            //                            Util.String2Int64(txtPesqCpf.Text),
            //                            txtPesNome.Text);


            //Download do Excel
            ArquivoDownload adXlsDbtConta = new ArquivoDownload();

            adXlsDbtConta.nome_arquivo = "Arquivo_Exportado.xls";
            //adTxtRecad.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtRecad.nome_arquivo;
            adXlsDbtConta.dados = dt;
            Session[ValidaCaracteres(adXlsDbtConta.nome_arquivo)] = adXlsDbtConta;
            string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsDbtConta.nome_arquivo);

            //AdicionarAcesso(fUrl);
            AbrirNovaAba(upUpdatePanel, fUrl, adXlsDbtConta.nome_arquivo);
        }
コード例 #11
0
        public void btnImprimirSelecao_Click(object sender, EventArgs e)
        {
            ArquivoDownload adExtratoPdf = new ArquivoDownload();

            adExtratoPdf.nome_arquivo    = "Rel_Carta_Cancelamento.pdf";
            adExtratoPdf.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + empresa.ToString() + "_" + matricula.ToString() + "_" + adExtratoPdf.nome_arquivo;
            adExtratoPdf.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;
            Gera_Pdf(adExtratoPdf, true);
        }
コード例 #12
0
        public async Task <ArquivoDownload> GerarDownloadQuestionario(List <DadosAlunoKV> dadosAluno, Documento documento, UsuarioADE usuario, RequisitosBasicosCabecalho requisitosBasicos, EnumFormatoDocumento formatoDocumento)
        {
            await AtualizarRequisitosDeUsuario(dadosAluno, usuario);

            MemoryStream file = await GerarQuestionario(dadosAluno, documento, usuario, requisitosBasicos);

            ArquivoDownload arquivoDownload = new ArquivoDownload(file, formatoDocumento);

            await LogGeracaoDocumento(documento, usuario);

            return(arquivoDownload);
        }
コード例 #13
0
        protected void btnGerarPrevidencia_Click(object sender, EventArgs e)
        {
            GeraMailingBLL dadosPrev          = new GeraMailingBLL();
            DataTable      valorDtPrevidencia = dadosPrev.RetornaDtPrevidencia();

            ArquivoDownload adXlsMaling = new ArquivoDownload();

            adXlsMaling.nome_arquivo = "ExportPrevidencia_" + DateTime.Now.ToString("ddmmyyyy") + ".xls";
            adXlsMaling.dados        = valorDtPrevidencia;
            Session[ValidaCaracteres(adXlsMaling.nome_arquivo)] = adXlsMaling;
            string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsMaling.nome_arquivo);

            AbrirNovaAba(UpdatePanel, fUrl, adXlsMaling.nome_arquivo);
        }
コード例 #14
0
        private void VisualizarBoleto(int PK_BOLETO)
        {
            //ReportCrystal.VisualizaRelatorio();
            //ReportCrystal.Visible = true;
            ArquivoDownload adExtratoPdf = new ArquivoDownload();

            adExtratoPdf.nome_arquivo    = nome_anexo + PK_BOLETO.ToString() + ".pdf";
            adExtratoPdf.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + PK_BOLETO.ToString() + "_" + adExtratoPdf.nome_arquivo;
            adExtratoPdf.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;
            ReportCrystal.ExportarRelatorioPdf(adExtratoPdf.caminho_arquivo);

            Session[ValidaCaracteres(adExtratoPdf.nome_arquivo)] = adExtratoPdf;
            string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adExtratoPdf.nome_arquivo);

            AdicionarAcesso(fullUrl);
            AbrirNovaAba(UpdatePanel, fullUrl, adExtratoPdf.nome_arquivo);
        }
コード例 #15
0
        public async Task <ArquivoDownload> GerarTabelaHistorico(UsuarioADE usuario, Documento tabela, RequisitosBasicosCabecalho requisitosFichaRegistroHoras)
        {
            List <RegistroDeHoras> registros = await ObterRegistrosUsuario(usuario);

            int codigo = await RecuperarCodigoHistoricoGeracaoDocumento();

            if (registros.Count == 0)
            {
                throw new Exception("É necessário ao menos dois registros para realizar a exportação do histórico.");
            }
            MemoryStream    file            = (MemoryStream)GeradorDocumento.GerarDocumentoRegistroHoras(tabela, registros, requisitosFichaRegistroHoras, codigo);
            ArquivoDownload arquivoDownload = new ArquivoDownload(file, EnumFormatoDocumento.docx);

            await LogGeracaoDocumento(tabela, usuario);

            return(arquivoDownload);
        }
コード例 #16
0
        public void ExportarRelatorioHtml(string nome_arquivo)
        {
            InicializaRpt();

            ArquivoDownload adExtratoPDF = new ArquivoDownload();

            adExtratoPDF.nome_arquivo    = nome_arquivo;
            adExtratoPDF.caminho_arquivo = Server.MapPath(@"UploadFile\") + adExtratoPDF.nome_arquivo;

            foreach (var p in _relatorio.parametros)
            {
                relatorio.SetParameterValue(p.parametro, p.valor);
            }

            //relatorio.ExportToHttpResponse(ExportFormatType.PortableDocFormat, HttpContext.Current.Response, false, "");
            relatorio.ExportToHttpResponse(ExportFormatType.HTML40, HttpContext.Current.Response, false, "");
        }
コード例 #17
0
        protected void btnGerar_Click(object sender, EventArgs e)
        {
            DataTable        dt     = new DataTable();
            ControleFlagsBLL objBll = new ControleFlagsBLL();

            dt = objBll.geraGridGeral();

            ArquivoDownload arqGeral = new ArquivoDownload();

            arqGeral.nome_arquivo = "Rel_Controle_Flags.xlsx";
            arqGeral.dados        = dt;
            Session[ValidaCaracteres(arqGeral.nome_arquivo)] = arqGeral;
            string fullArqGeral = "WebFile.aspx?dwFile=" + ValidaCaracteres(arqGeral.nome_arquivo);

            AdicionarAcesso(fullArqGeral);
            AbrirNovaAba(upUpdatePanel, fullArqGeral, arqGeral.nome_arquivo);
        }
コード例 #18
0
        private bool InicializaDadosEMail(string CodEmpresa, string CodMatricula, string DataBase)
        {
            txtEMail.Text = txtEMail.Text.Trim();

            if (String.IsNullOrEmpty(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail obrigatório");
                return(false);
            }
            else if (!Util.ValidaEmail(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail inválido");
                return(false);
            }

            if (epDados == null)
            {
                extratoPrevidenciarioBLL extPrevBLL = new extratoPrevidenciarioBLL();
                epDados = extPrevBLL.Consultar(int.Parse(CodEmpresa), int.Parse(CodMatricula));
            }
            ArquivoDownload newAd = new ArquivoDownload();

            switch (optTipo.SelectedValue)
            {
            case "1":
                newAd.nome_arquivo = nome_anexo_extrato + DateTime.Today.ToString("yyyy_MM_dd") + ".pdf";
                break;

            case "2":
                newAd.nome_arquivo = nome_anexo_extrato + DateTime.Parse(DataBase).ToString("yyyy_MM_dd") + ".pdf";
                break;

            case "3":
                newAd.nome_arquivo = nome_anexo_ficha + DateTime.Today.ToString("yyyy_MM_dd") + ".pdf";
                break;

            case "4":
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nOpção inválida");
                ReportCrystal.Visible = false;
                return(false);
            }

            newAd.dados = ReportCrystal.ExportarRelatorioPdf();
            lstAdPdf.Add(newAd);
            return(true);
        }
コード例 #19
0
        protected void btnGerar_Click(object sender, EventArgs e)
        {
            ListaEnvioEmailBLL bll = new ListaEnvioEmailBLL();

            //DataTable dtSau = bll.GeraBoletoSaude();

            DataTable dtSau = bll.Gera();

            ArquivoDownload adBoleto = new ArquivoDownload();

            adBoleto.nome_arquivo = "Lista_Email_Boletos_Saude.xlsx";
            adBoleto.dados        = dtSau;
            Session[ValidaCaracteres(adBoleto.nome_arquivo)] = adBoleto;
            string fullBoleto = "WebFile.aspx?dwFile=" + ValidaCaracteres(adBoleto.nome_arquivo);

            AdicionarAcesso(fullBoleto);
            AbrirNovaAba(this.Page, fullBoleto, adBoleto.nome_arquivo);
        }
コード例 #20
0
        protected void btnRelatorio_Click(object sender, EventArgs e)
        {
            Processo_Mensagem.Visible = false;

            DataTable dtCC = new DataTable();
            DataTable dtGB = new DataTable();

            ExportaRelIntFinContabBLL bll = new ExportaRelIntFinContabBLL();

            dtCC = bll.ListarDadosCC(Convert.ToDateTime(txtDatInicio.Text), Convert.ToDateTime(txtDatFim.Text));
            dtGB = bll.ListarDadosGB(Convert.ToDateTime(txtDatInicio.Text), Convert.ToDateTime(txtDatFim.Text));

            if (dtCC.Rows.Count > 0)
            {
                //Download do Excel
                ArquivoDownload adXlsExportaRelCC = new ArquivoDownload();
                adXlsExportaRelCC.nome_arquivo = "Rel_Int_Contab.xls";
                //adTxtRecad.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtRecad.nome_arquivo;
                adXlsExportaRelCC.dados = dtCC;
                Session[ValidaCaracteres(adXlsExportaRelCC.nome_arquivo)] = adXlsExportaRelCC;
                string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsExportaRelCC.nome_arquivo);
                //   AdicionarAcesso(fUrl);
                AbrirNovaAba(this, fUrl, adXlsExportaRelCC.nome_arquivo);
            }

            if (dtGB.Rows.Count > 0)
            {
                //Download do Excel
                ArquivoDownload adXlsExportaRelGB = new ArquivoDownload();
                adXlsExportaRelGB.nome_arquivo = "Rel_Int_Fin.xls";
                //adTxtRecad.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtRecad.nome_arquivo;
                adXlsExportaRelGB.dados = dtGB;
                Session[ValidaCaracteres(adXlsExportaRelGB.nome_arquivo)] = adXlsExportaRelGB;
                string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsExportaRelGB.nome_arquivo);
                //   AdicionarAcesso(fUrl);
                AbrirNovaAba(this, fUrl, adXlsExportaRelGB.nome_arquivo);
            }

            if (dtCC.Rows.Count == 0 && dtGB.Rows.Count == 0)
            {
                MostraMensagem(Processo_Mensagem, "Não há registros para serem exportados !");
                return;
            }
        }
コード例 #21
0
        private void Gera_Pdf(ArquivoDownload adExtratoPdf, bool Download = false)
        {
            List <String> listaSubMatricula = new List <String>();

            foreach (GridViewRow row in grdCancelPlano.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    string[] planos = new string[3];

                    CheckBox    chkSelect       = (CheckBox)row.FindControl("chkSelect");
                    HiddenField hidSubMatricula = (HiddenField)row.FindControl("hidSubMatricula");

                    if (chkSelect.Checked == true)
                    {
                        listaSubMatricula.Add(hidSubMatricula.Value);
                    }
                }
            }

            if (listaSubMatricula.Count > 0)
            {
                String SubMats = String.Join(",", listaSubMatricula.ToArray());

                if (InicializaRelatorio(empresa.ToString(), matricula.ToString(), SubMats, ResponsavelPlano, hfProtocolo.Value))
                {
                    //ArquivoDownload adExtratoPdf = new ArquivoDownload();
                    //adExtratoPdf.nome_arquivo = "Rel_Carta_Cancelamento.pdf";
                    //adExtratoPdf.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + empresa.ToString() + "_" + matricula.ToString() + "_" + adExtratoPdf.nome_arquivo;
                    //adExtratoPdf.modo_abertura = System.Net.Mime.DispositionTypeNames.Inline;
                    ReportCrystal.ExportarRelatorioPdf(adExtratoPdf.caminho_arquivo);

                    if (Download)
                    {
                        Session[ValidaCaracteres(adExtratoPdf.nome_arquivo)] = adExtratoPdf;
                        string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adExtratoPdf.nome_arquivo);
                        AdicionarAcesso(fullUrl);
                        AbrirNovaAba(UpdatePanel, fullUrl, adExtratoPdf.nome_arquivo);
                    }
                }
            }
        }
コード例 #22
0
        protected void btnExportarRet_Click(object sender, EventArgs e)
        {
            DebitoContaRetornoBLL bll = new DebitoContaRetornoBLL();
            DataTable             dt  = bll.ListarDadosParaExcel(ddlNomeArquivo.SelectedValue,
                                                                 null,
                                                                 ddlTipoRegistro.SelectedValue,
                                                                 chkPesqComCritica.Checked);

            //Download do Excel
            ArquivoDownload adXlsDbtConta = new ArquivoDownload();

            adXlsDbtConta.nome_arquivo = "Arquivo_Retorno.xls";
            //adTxtRecad.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtRecad.nome_arquivo;
            adXlsDbtConta.dados = dt;
            Session[ValidaCaracteres(adXlsDbtConta.nome_arquivo)] = adXlsDbtConta;
            string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsDbtConta.nome_arquivo);

            //AdicionarAcesso(fUrl);
            AbrirNovaAba(upUpdatePanel, fUrl, adXlsDbtConta.nome_arquivo);
        }
コード例 #23
0
        protected void btnGerarRelatorio_Click(object sender, EventArgs e)
        {
            AberturaFinanceiraDAL Dal = new AberturaFinanceiraDAL();

            //List<FIN_TBL_RES_ABERT_FINANCEIRA_view2> list = Dal.GetDataExportar(Util.String2Int32(txtMes.Text), Util.String2Int32(txtAno.Text));
            List <FIN_TBL_RES_ABERT_FINANCEIRA_view3> list = Dal.GetDataConsolidado(Util.String2Int32(txtMes.Text), Util.String2Int32(txtAno.Text));

            DataTable dt = list.ToDataTable();

            //Download do Excel
            ArquivoDownload adXlsResAberturaFin = new ArquivoDownload();

            adXlsResAberturaFin.nome_arquivo = "Res_Abertura_Fin_" + txtMes.Text + "_" + txtAno.Text + ".xls";
            //adTxtRecad.caminho_arquivo = Server.MapPath(@"UploadFile\") + adTxtRecad.nome_arquivo;
            adXlsResAberturaFin.dados = dt;
            Session[ValidaCaracteres(adXlsResAberturaFin.nome_arquivo)] = adXlsResAberturaFin;
            string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adXlsResAberturaFin.nome_arquivo);

            //AdicionarAcesso(fUrl);
            AbrirNovaAba(UpdatePanel, fUrl, adXlsResAberturaFin.nome_arquivo);
        }
コード例 #24
0
        protected void btnEnviarSelecao_Click(object sender, EventArgs e)
        {
            if (verificarEmail())
            {
                enviarEmail = 1;
                email       = txtEmail.Text;

                ArquivoDownload adExtratoPdf = new ArquivoDownload();
                adExtratoPdf.nome_arquivo    = "Rel_Carta_Cancelamento.pdf";
                adExtratoPdf.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + empresa.ToString() + "_" + matricula.ToString() + "_" + adExtratoPdf.nome_arquivo;
                adExtratoPdf.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;
                Gera_Pdf(adExtratoPdf);

                enviarEmailPdf(ReportCrystal.ExportarRelatorioPdf());

                if (File.Exists(adExtratoPdf.caminho_arquivo))
                {
                    File.Delete(adExtratoPdf.caminho_arquivo);
                }
            }
        }
コード例 #25
0
 public void GeraRelatorio(DataTable dt, ArquivoDownload XlsBaseDados)
 {
     if (dt.Rows.Count > 0)
     {
         //ArquivoUpload dtRelatorio = new ArquivoUpload();
         //var nomeArquivo = Convert.ToString(DateTime.Today.Year) + "_" + Convert.ToString(DateTime.Today.Month) + "_" + Convert.ToString(DateTime.Today.Day) + "_DISTRIBUICAO_BOLETAS.xls";
         ArquivoDownload XlsDistribuicao = new ArquivoDownload();
         XlsDistribuicao.dados                 = dt;
         XlsDistribuicao.nome_arquivo          = Convert.ToString(DateTime.Today.Year) + "_" + Convert.ToString(DateTime.Today.Month) + "_" + Convert.ToString(DateTime.Today.Day) + "_DISTRIBUICAO_BOLETAS.xls";
         Session[XlsDistribuicao.nome_arquivo] = XlsDistribuicao;
         //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'WebFile.aspx?dwFile=distribuicao', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
         string fullUrl = "WebFile.aspx?dwFile=" + XlsDistribuicao.nome_arquivo;
         AdicionarAcesso(fullUrl);
         AbrirNovaAba(this, fullUrl, XlsDistribuicao.nome_arquivo);
         //ArquivoDownload XlsBaseDados = new ArquivoDownload();
         Session[XlsBaseDados.nome_arquivo] = XlsBaseDados;
         fullUrl = "WebFile.aspx?dwFile=" + XlsBaseDados.nome_arquivo;
         //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'WebFile.aspx?dwFile=basedados', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
         AdicionarAcesso(fullUrl);
         AbrirNovaAba(this, fullUrl, XlsBaseDados.nome_arquivo);
     }
 }
コード例 #26
0
        public void ExportToFile(string dwFile)
        {
            if (Session[dwFile] != null)
            {
                ArquivoDownload adArquivo = (ArquivoDownload)Session[dwFile];

                if (adArquivo.dados != null)
                {
                    switch (adArquivo.dados.GetType().Name)
                    {
                    case "DataTable":
                        ExportarArquivo(adArquivo.nome_arquivo,
                                        (DataTable)adArquivo.dados,
                                        adArquivo.opcao_arquivo);
                        break;

                    case "XmlDocument":
                        ResponseXml(adArquivo.nome_arquivo,
                                    (XmlDocument)adArquivo.dados);
                        break;

                    case "String":
                        ResponseHtml(adArquivo.nome_arquivo, (String)adArquivo.dados);
                        break;

                    case "Byte[]":
                        ResponseFile((byte[])adArquivo.dados, adArquivo.nome_arquivo, "", null);
                        break;
                    }
                }
                else
                {
                    ExportarArquivo(adArquivo.nome_arquivo,
                                    adArquivo.caminho_arquivo,
                                    adArquivo.modo_abertura);
                }
            }
        }
コード例 #27
0
        private bool InicializaDadosEMail(string CodEmpresa, string CodMatricula, string NumIdntfRptant, string NumSubMatric, string Semestre, string DatEmissao, string DatIni = " ")
        {
            txtEMail.Text = txtEMail.Text.Trim();

            if (String.IsNullOrEmpty(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail obrigatório");
                return(false);
            }
            else if (!Util.ValidaEmail(txtEMail.Text))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nE-Mail inválido");
                return(false);
            }

            ExtratoComponenteBLL ExtUtilBLL = new ExtratoComponenteBLL();
            int iRepresentante = 0;

            int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);
            epDados         = ExtUtilBLL.Consultar(int.Parse(CodEmpresa), int.Parse(CodMatricula), iRepresentante, 1, 2016);
            epDados.usuario = ddlRepresentante.SelectedItem.Text;

            if (String.IsNullOrEmpty(epDados.empresa) && String.IsNullOrEmpty(epDados.registro))
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, "Atenção\\n\\nDados não localizados para a matrícula " + CodMatricula);
                return(false);
            }

            ArquivoDownload newAd = new ArquivoDownload();

            // newAd.nome_arquivo = nome_anexo + DatEmissao.Replace("/", "_") + ".pdf";
            newAd.nome_arquivo = nome_anexo + ".pdf";
            newAd.dados        = ReportCrystal.ExportarRelatorioPdf();
            lstAdPdf.Add(newAd);

            return(true);
        }
コード例 #28
0
        protected void btnProcessar_Click(object sender, EventArgs e)
        {
            //trazer para uma variavel o vlaor digitado pelo usuario
            string nmCampanha = txtCampanha.Text.Trim();

            //tratar o texto, tirando espaço e acentuação
            nmCampanha = nmCampanha.Replace(" ", "");
            nmCampanha = Util.RemoverAcentuacao(nmCampanha);


            lblRegistros.Text = "";

            if (String.IsNullOrEmpty(nmCampanha))
            {
                MostraMensagemRodape("Atenção! Preencha o campo campanha para prosseguir");
                return;
            }

            if (uploadZip.HasFile)
            {
                if (uploadZip.PostedFile.ContentType.Equals("application/x-zip-compressed") || uploadZip.PostedFile.ContentType.Equals("application/octet-stream"))
                {
                    string pasta_html  = "";
                    string arquivo_zip = "";
                    string index_html  = "";
                    //string index_jpg = "";

                    try
                    {
                        string[] name           = Path.GetFileName(uploadZip.FileName).ToString().Split('.');
                        string   UploadFilePath = Server.MapPath("UploadFile\\");
                        pasta_html  = UploadFilePath + name[0] + "_" + System.DateTime.Now.ToFileTime();
                        arquivo_zip = pasta_html + "." + name[1];

                        if (name[1].ToUpper() != "ZIP")
                        {
                            throw new Exception("Extensão inválida. Carregue apenas arquivos compactados(.zip)");
                        }

                        if (!Directory.Exists(UploadFilePath))
                        {
                            Directory.CreateDirectory(UploadFilePath);
                        }

                        uploadZip.SaveAs(arquivo_zip);

                        ZipFile.ExtractToDirectory(arquivo_zip, pasta_html);
                        bool   encontrou  = false;
                        string pasta_alvo = pasta_html;

                        List <string> lista_pastas = new List <string>();
                        lista_pastas.Add(pasta_alvo);

                        int cont_pasta = 0;
                        while (cont_pasta < lista_pastas.Count)
                        {
                            foreach (string pasta in Directory.GetFiles(lista_pastas[cont_pasta]))
                            {
                                if (pasta.ToUpper().IndexOf("INDEX.HTML") > -1)
                                {
                                    index_html = pasta;
                                    encontrou  = true;
                                }
                            }

                            foreach (string pasta in Directory.GetDirectories(lista_pastas[cont_pasta]))
                            {
                                lista_pastas.Add(pasta);
                            }

                            cont_pasta++;
                        }

                        int           cont_pastaI   = 0;
                        List <string> lista_imagens = new List <string>();
                        while (cont_pastaI < lista_pastas.Count)
                        {
                            foreach (string pasta in Directory.GetFiles(lista_pastas[cont_pastaI]))
                            {
                                if (pasta.ToUpper().IndexOf(".JPG") > -1)
                                {
                                    //index_jpg = pasta;
                                    lista_imagens.Add(pasta);
                                    encontrou = true;
                                }
                            }

                            cont_pastaI++;
                        }

                        //Enviar arquivo para SFTP
                        string host     = "fcespihsp001";
                        string username = "******";
                        string password = "******";

                        if (encontrou == true)
                        {
                            EMailMarketingBLL emailMktBLL = new EMailMarketingBLL();

                            string index_html_conteudo = "";

                            try
                            {
                                index_html_conteudo = "";
                                using (StreamReader file = new StreamReader(index_html, Encoding.GetEncoding("ISO-8859-1")))
                                {
                                    index_html_conteudo = file.ReadToEnd();

                                    nmCampanha = emailMktBLL.ContCamp(host, username, password, nmCampanha);

                                    foreach (string index_jpg in lista_imagens)
                                    {
                                        //emailMktBLL.SendFTP(host, username, password, lista_imagens, nmCampanha);
                                        emailMktBLL.SendFTP(host, username, password, index_jpg, nmCampanha);
                                        string nom_arquivo = GetTagTarget(index_html_conteudo, "src=", Path.GetFileName(index_jpg));
                                        //string nom_arquivo = GetTagTarget(index_html_conteudo, "=", Path.GetFileName(index_jpg));
                                        index_html_conteudo = index_html_conteudo.Replace(nom_arquivo, "http://www.funcesp.com.br/emailmarketing/" + nmCampanha + "/" + Path.GetFileName(index_jpg));

                                        if (!index_html_conteudo.Contains("href=\"http://www."))
                                        {
                                            index_html_conteudo = index_html_conteudo.Replace("href=\"http://", "href=\"http://www.");
                                        }

                                        if (!index_html_conteudo.Contains("href"))
                                        {
                                            index_html_conteudo = index_html_conteudo.Replace("<img src", "<a href=\"https://www.funcesp.com.br\"target=\"_blank\" title=\"" + nmCampanha + "\">" + "\r\n" + "<img src");
                                        }
                                    }
                                }

                                if (!index_html.Contains("<p style"))
                                {
                                    //index_html_conteudo = index_html_conteudo.Replace("<body>", "<body>" + "\r\n" + "<p style=\"font-size:1px; color:#FFF\" align=\"center\"> Esta mensagem (incluindo seus anexos) é confidencial e é endereçada exclusivamente às pessoas e/ou instituições acima indicadas. Se você a recebeu por engano, por favor notifique o remetente e delete a mensagem do seu sistema. O uso não autorizado ou a disseminação desta mensagem por inteiro ou parcialmente é estritamente proibida. Os e-mails são suscetíveis a mudança, portanto, não somos responsáveis pela transmissão imprópria ou incompleta da informação contida nesta comunicação. </p>");
                                }

                                //download do arquivo html
                                ArquivoDownload htmlArquivo = new ArquivoDownload();
                                htmlArquivo.nome_arquivo = nmCampanha + ".txt";
                                htmlArquivo.dados        = index_html_conteudo;
                                Session[ValidaCaracteres(htmlArquivo.nome_arquivo)] = htmlArquivo;
                                string fUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(htmlArquivo.nome_arquivo);
                                AbrirNovaAba(upSimulacao, fUrl, htmlArquivo.nome_arquivo);
                            }

                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MostraMensagemRodape("Atenção! O arquivo não pôde ser carregado. Motivo: " + ex.Message);
                    }
                    finally
                    {
                        uploadZip.FileContent.Dispose();
                        uploadZip.FileContent.Flush();
                        uploadZip.PostedFile.InputStream.Flush();
                        uploadZip.PostedFile.InputStream.Close();
                        if (File.Exists(arquivo_zip))
                        {
                            File.Delete(arquivo_zip);
                        }
                        if (Directory.Exists(pasta_html))
                        {
                            Directory.Delete(pasta_html, true);
                        }
                    }
                }
                else if (uploadZip.PostedFile.ContentType.ToLower() == "image/png" ||
                         uploadZip.PostedFile.ContentType.ToLower() == "image/jpeg" ||
                         uploadZip.PostedFile.ContentType.ToLower() == "image/gif" ||
                         uploadZip.PostedFile.ContentType.ToLower() == "image/tiff")
                {
                    string[] nameImagem     = Path.GetFileName(uploadZip.FileName).ToString().Split('.');
                    string   UploadFilePath = Server.MapPath("UploadFile\\");
                    string   Imagem         = UploadFilePath + nameImagem[0];
                    string   UploadImagem   = Imagem + "." + nameImagem[1];
                    uploadZip.SaveAs(UploadImagem);

                    //Enviar arquivo para SFTP
                    string host     = "fcespihsp001";
                    string username = "******";
                    string password = "******";

                    try
                    {
                        EMailMarketingBLL Upload      = new EMailMarketingBLL();
                        string            nmCampanha2 = Upload.ContCamp(host, username, password, nmCampanha);
                        //Upload.SendFTPImagem(host, username, password, UploadImagem, nmCampanha);
                        Upload.SendFTP(host, username, password, UploadImagem, nmCampanha2);
                        hlkHtml.NavigateUrl = "http://www.funcesp.com.br/emailmarketing/" + nmCampanha2 + "/" + Path.GetFileName(uploadZip.FileName);
                        hlkHtml.Text        = hlkHtml.NavigateUrl;
                    }
                    catch (Exception ex)
                    {
                        MostraMensagemRodape("Atenção! O arquivo não pôde ser carregado. Motivo: " + ex.Message);
                    }
                    finally
                    {
                        uploadZip.FileContent.Dispose();
                        uploadZip.FileContent.Flush();
                        uploadZip.PostedFile.InputStream.Flush();
                        uploadZip.PostedFile.InputStream.Close();
                        if (File.Exists(UploadImagem))
                        {
                            File.Delete(UploadImagem);
                        }
                    }
                }
                else
                {
                    MostraMensagemRodape("Atenção! Carregue apenas compactados(.zip) ou Imagens");
                }
            }
            else
            {
                MostraMensagemRodape("Atenção! Selecione o arquivo ZIP para processar");
            }
        }
コード例 #29
0
        protected void imgAprovacao_Click(object sender, ImageClickEventArgs e)
        {
            AberturaFinanceiraDAL dal          = new AberturaFinanceiraDAL();
            ImageButton           imgAprovacao = (ImageButton)sender;
            GridViewRow           row          = (GridViewRow)imgAprovacao.NamingContainer;
            int numRegEmpresa  = 0;
            int numRegAprovado = 0;
            var user           = (ConectaAD)Session["objUser"];

            Resultado res = dal.AprovacaoAberturaFinanceira(Convert.ToInt32((row.FindControl("lblIdReg") as Label).Text), "SYS_FUNCESP");//user.login);

            numRegEmpresa  = dal.GetDataCountEmpresa(Convert.ToInt32((row.FindControl("lblEmpresa") as Label).Text), Convert.ToInt32(txtMes.Text), Convert.ToInt32(txtAno.Text));
            numRegAprovado = dal.GetDataCountAprovados(Convert.ToInt32((row.FindControl("lblEmpresa") as Label).Text), Convert.ToInt32(txtMes.Text), Convert.ToInt32(txtAno.Text));

            if (res.Ok)
            {
                if (numRegAprovado == numRegEmpresa)
                {
                    if (InicializaRelatorioValParticipante(((row.FindControl("lblEmpresa") as Label).Text), txtMes.Text.PadLeft(2, '0'), txtAno.Text))
                    {
                        ArquivoDownload adRelValPartExcel = new ArquivoDownload();
                        adRelValPartExcel.nome_arquivo    = relatorio_nome_part + "_" + (row.FindControl("lblNomEmpresa") as Label).Text.Replace(" ", "_") + "_" + txtMes.Text.PadLeft(2, '0') + txtAno.Text + ".xls";
                        adRelValPartExcel.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + adRelValPartExcel.nome_arquivo;
                        adRelValPartExcel.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;
                        ReportCrystal.ExportarRelatorioExcel(adRelValPartExcel.caminho_arquivo);

                        Session[ValidaCaracteres(adRelValPartExcel.nome_arquivo)] = adRelValPartExcel;
                        string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adRelValPartExcel.nome_arquivo);
                        AdicionarAcesso(fullUrl);
                        AbrirNovaAba(UpdatePanel, fullUrl, adRelValPartExcel.nome_arquivo);
                    }

                    if (InicializaRelatorioValCredenciado(((row.FindControl("lblEmpresa") as Label).Text), txtMes.Text.PadLeft(2, '0'), txtAno.Text))
                    {
                        ArquivoDownload adRelValCredExcel = new ArquivoDownload();
                        adRelValCredExcel.nome_arquivo    = relatorio_nome_cred + "_" + (row.FindControl("lblNomEmpresa") as Label).Text.Replace(" ", "_") + "_" + txtMes.Text.PadLeft(2, '0') + txtAno.Text + ".xls";
                        adRelValCredExcel.caminho_arquivo = Server.MapPath(@"UploadFile\") + DateTime.Now.ToFileTime() + "_" + adRelValCredExcel.nome_arquivo;
                        adRelValCredExcel.modo_abertura   = System.Net.Mime.DispositionTypeNames.Inline;
                        ReportCrystal.ExportarRelatorioExcel(adRelValCredExcel.caminho_arquivo);

                        Session[ValidaCaracteres(adRelValCredExcel.nome_arquivo)] = adRelValCredExcel;
                        string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(adRelValCredExcel.nome_arquivo);
                        AdicionarAcesso(fullUrl);
                        AbrirNovaAba(UpdatePanel, fullUrl, adRelValCredExcel.nome_arquivo);
                    }

                    MostraMensagemTelaUpdatePanel(UpdatePanel, "Todos os Movimentos da Empresa: " + (row.FindControl("lblNomEmpresa") as Label).Text + " Aprovados , Relatórios Gerados");
                    grdAberturaFinanceira.DataBind();
                }
                else
                {
                    MostraMensagemTelaUpdatePanel(UpdatePanel, "Aprovado com Sucesso");
                    grdAberturaFinanceira.DataBind();
                }
            }
            else
            {
                MostraMensagemTelaUpdatePanel(UpdatePanel, res.Mensagem);
                grdAberturaFinanceira.DataBind();
            }
        }
コード例 #30
0
        protected void btnGerarRel_Click(object sender, EventArgs e)
        {
            try
            {
                string tipo = ddlTipoRel.SelectedItem.Value.ToString();
                if (String.IsNullOrEmpty(txtDataInicial.Text) && !String.IsNullOrEmpty(txtDataFinal.Text))
                {
                    MostraMensagemTelaUpdatePanel(UpdatePanel, "Campo de data inicial vazio, favor preencher");
                    txtDataInicial.Focus();
                }
                else if (!String.IsNullOrEmpty(txtDataInicial.Text) && String.IsNullOrEmpty(txtDataFinal.Text))
                {
                    MostraMensagemTelaUpdatePanel(UpdatePanel, "Campo de data final vazio, favor preencher");
                    txtDataFinal.Focus();
                }
                else
                {
                    if (!String.IsNullOrEmpty(txtDataFinal.Text) && !String.IsNullOrEmpty(txtDataInicial.Text))
                    {
                        string dataInicial = txtDataInicial.Text.Replace("/", "-");
                        string dataFinal   = txtDataFinal.Text.Replace("/", "-");
                        RelatorioFestaAposentadosBLL objBLL = new RelatorioFestaAposentadosBLL();


                        string location = "window.location='UploadFile/Relatorio_Festa_Aposentados "
                                          + dataInicial + " á "
                                          + dataFinal + ".xlsx';";

                        string arquivo = Server.MapPath(@"UploadFile\\" + "Relatorio_Festa_Aposentados "
                                                        + dataInicial +
                                                        " á " + dataFinal + ".xlsx");

                        GeraArquivo(objBLL.geraRelatorio(Convert.ToDateTime(txtDataInicial.Text), Convert.ToDateTime(txtDataFinal.Text), tipo), dataInicial, dataFinal);

                        ArquivoDownload arqDownloadGeral = new ArquivoDownload();
                        arqDownloadGeral.nome_arquivo    = "Relatorio_Festa_Aposentados " + dataInicial + " á " + dataFinal + ".xlsx";
                        arqDownloadGeral.caminho_arquivo = arquivo;
                        arqDownloadGeral.modo_abertura   = System.Net.Mime.DispositionTypeNames.Attachment;
                        Session[ValidaCaracteres(arqDownloadGeral.nome_arquivo)] = arqDownloadGeral;
                        string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(arqDownloadGeral.nome_arquivo);
                        AdicionarAcesso(fullUrl);
                        AbrirNovaAba(UpdatePanel, fullUrl, arqDownloadGeral.nome_arquivo);
                    }
                    else
                    {
                        string dataInicial = "";
                        string dataFinal   = "";
                        RelatorioFestaAposentadosBLL objBLL = new RelatorioFestaAposentadosBLL();


                        string location = "window.location='UploadFile/Relatorio_Festa_Aposentados_Geral.xlsx';";

                        string arquivo = Server.MapPath(@"UploadFile\\" + "Relatorio_Festa_Aposentados_Geral.xlsx");

                        GeraArquivo(objBLL.geraRelatorioGeral(tipo), dataInicial, dataFinal);

                        ArquivoDownload arqDownloadGeral = new ArquivoDownload();
                        arqDownloadGeral.nome_arquivo    = "Relatorio_Festa_Aposentados_Geral.xlsx";
                        arqDownloadGeral.caminho_arquivo = arquivo;
                        arqDownloadGeral.modo_abertura   = System.Net.Mime.DispositionTypeNames.Attachment;
                        Session[ValidaCaracteres(arqDownloadGeral.nome_arquivo)] = arqDownloadGeral;
                        string fullUrl = "WebFile.aspx?dwFile=" + ValidaCaracteres(arqDownloadGeral.nome_arquivo);
                        AdicionarAcesso(fullUrl);
                        AbrirNovaAba(UpdatePanel, fullUrl, arqDownloadGeral.nome_arquivo);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }