Inheritance: ReportClass
Example #1
0
        private void bwExportarInforme_DoWork(object sender, DoWorkEventArgs e)
        {
            string pathArchivo = _exportPath + "\\" + _normbreArchivo + "." + _formato;
            pathArchivo = pathArchivo.ToLower();

            string fullPath = (pathArchivo).ToLower();

            InformeEventos informe = new InformeEventos();
            informe.SetDataSource(ManejoDB.ObtenerLogAccionesDB());
            ExportFormatType tipoFormato = ExportFormatType.NoFormat;
            switch (_formato)
            {
                case FormatoInforme.Doc:
                    tipoFormato = ExportFormatType.WordForWindows;
                    break;
                case FormatoInforme.Html:
                    tipoFormato = ExportFormatType.HTML40;
                    break;
                case FormatoInforme.Pdf:
                    tipoFormato = ExportFormatType.PortableDocFormat;
                    break;
                case FormatoInforme.Xls:
                    tipoFormato = ExportFormatType.Excel;
                    break;
                case FormatoInforme.Txt:
                    tipoFormato = ExportFormatType.Text;
                    break;
            }
            try
            {
                if (!Directory.Exists(_exportPath))
                    Directory.CreateDirectory(_exportPath);
                informe.ExportToDisk(tipoFormato, fullPath);
                MessageBox.Show("El informe se generĂ³ corrrectamente");
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,
                                "Ocurrio un error al guardar el informe, Asegurese de que el archivo no esta en uso.",
                                "Error al guardar el Informe", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            try
            {
                Process.Start(fullPath);
            }
            catch (Exception)
            {
            }
        }
Example #2
0
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
 {
     InformeEventos rpt = new InformeEventos();
     rpt.Site = this.Site;
     return rpt;
 }