示例#1
0
 public void LoadReport(ReportState rptState, CrystalDecisions.Web.CrystalReportViewer crivew, string report)
 {
     if (rptState != ReportState.FromPostBack)
     {
         try
         {
             rptdoc = new ReportDocument();
             ParameterField         paramField  = new ParameterField();
             ParameterFields        paramFields = new ParameterFields();
             ParameterDiscreteValue paramDValue = new ParameterDiscreteValue();
             DataTable dt = new DataTable();
             dt = getdata();
             ds.Tables[0].Merge(dt);
             rptdoc.Load(Server.MapPath(report));
             rptdoc.SetDataSource(dt);
             crivew.ReportSource = rptdoc;
             paramField.Name     = "title";
             paramDValue.Value   = "Date:" + txtDate1.Text.ToString() + " To " + txtDate2.Text;
             paramField.CurrentValues.Add(paramDValue);
             paramField.HasCurrentValue = true;
             paramFields.Add(paramField);
             crivew.ParameterFieldInfo        = paramFields;
             crivew.EnableDatabaseLogonPrompt = false;
             crivew.EnableParameterPrompt     = false;
             Session["cr"] = rptdoc;
         }
         catch (NullReferenceException ex)
         {
             crivew.Visible = false;
         }
         catch (CrystalReportsException ex)
         {
             crivew.Visible = false;
             Response.Write(ex);
         }
         catch (IndexOutOfRangeException ex)
         {
             crivew.Visible = false;
             Response.Write(ex);
         }
         catch (SqlException ex)
         {
             crivew.Visible = false;
             Response.Write(ex);
         }
         catch (ArgumentNullException ex)
         {
             crivew.Visible = false;
             Response.Write(ex);
         }
         catch (COMException ex)
         {
             Response.Redirect("../../Login.aspx");
         }
     }
     else
     {
         crivew.ReportSource = (ReportDocument)Session["cr"];
     }
 }
示例#2
0
    private void ExportPDF()
    {
        try
        {
            lblInfo.Text = "Gerando arquivo pdf para anexo";
            DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("Pedidos"));
            if (!dinfo.Exists)
            {
                dinfo.Create();
            }
            if (File.Exists(Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf")))
            {
                File.Delete(Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf"));
            }
            CarregaDataTableParaImpressao();
            ReportDocument rpt             = new ReportDocument();
            dsPedido       TabelaImpressao = (dsPedido)Session["PedidoRes"];
            rpt.Load(Server.MapPath("rptPedido.rpt"));
            rpt.SetDataSource(TabelaImpressao);

            CrystalDecisions.Web.CrystalReportViewer cryView = new CrystalDecisions.Web.CrystalReportViewer();
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();
            CrDiskFileDestinationOptions.DiskFileName = Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf");
            CrExportOptions = rpt.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions         = CrFormatTypeOptions;
            }
            rpt.Export();
            lblInfo.Text = "Exportando arquivo para o servidor";
        }
        catch (Exception ex)
        {
            throw ex;
            //lblInfo.Text = ex.Message + (ex.InnerException != null ? ex.InnerException.Message : "");
        }
    }
示例#3
0
    private void ExportPDF(string sNameFile)
    {
        try
        {
            DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("Pedidos"));
            if (!dinfo.Exists)
            {
                dinfo.Create();
            }
            if (File.Exists(Server.MapPath("Pedidos\\" + sNameFile)))
            {
                File.Delete(Server.MapPath("Pedidos\\" + sNameFile + ".pdf"));
            }
            PesquisarDados(sCodigoPedido);
            ReportDocument rpt             = new ReportDocument();
            DataTable      TabelaImpressao = (DataTable)Session["PedidoRes"];
            rpt.Load(Server.MapPath("RelatorioPedido.rpt"));
            rpt.SetDataSource(TabelaImpressao);

            CrystalDecisions.Web.CrystalReportViewer cryView = new CrystalDecisions.Web.CrystalReportViewer();
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();
            CrDiskFileDestinationOptions.DiskFileName = Server.MapPath("Pedidos\\" + sNameFile + ".pdf");
            CrExportOptions = rpt.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions         = CrFormatTypeOptions;
            }
            rpt.Export();
        }
        catch (Exception ex)
        {
            throw ex;
            //lblInfo.Text = ex.Message + (ex.InnerException != null ? ex.InnerException.Message : "");
        }
    }
示例#4
0
    private void ExportPDF()
    {
        try
        {
            lblInfo.Text = "Gerando arquivo pdf para anexo";
            DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("Pedidos"));
            if (!dinfo.Exists)
            {
                dinfo.Create();
            }
            if (File.Exists(Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf")))
            {
                File.Delete(Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf"));
            }
            CarregaDataTableParaImpressao();
            ReportDocument rpt = new ReportDocument();
            dsPedido TabelaImpressao = (dsPedido)Session["PedidoRes"];
            rpt.Load(Server.MapPath("rptPedido.rpt"));
            rpt.SetDataSource(TabelaImpressao);

            CrystalDecisions.Web.CrystalReportViewer cryView = new CrystalDecisions.Web.CrystalReportViewer();
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
            CrDiskFileDestinationOptions.DiskFileName = Server.MapPath("Pedidos\\" + sCodigoPedido + ".pdf");
            CrExportOptions = rpt.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
            }
            rpt.Export();
            lblInfo.Text = "Exportando arquivo para o servidor";
        }
        catch (Exception ex)
        {
            throw ex;
            //lblInfo.Text = ex.Message + (ex.InnerException != null ? ex.InnerException.Message : "");
        }
    }
示例#5
0
    private void ExportPDF(string sNameFile)
    {
        try
        {
            DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath("Pedidos"));
            if (!dinfo.Exists)
            {
                dinfo.Create();
            }
            if (File.Exists(Server.MapPath("Pedidos\\" + sNameFile)))
            {
                File.Delete(Server.MapPath("Pedidos\\" + sNameFile + ".pdf"));
            }
            //            PesquisarDados();
            ReportDocument rpt = new ReportDocument();
            DataTable TabelaImpressao = (DataTable)Session["PedidoRes"];
            rpt.Load(Server.MapPath("RelatorioPedido.rpt"));
            rpt.SetDataSource(TabelaImpressao);

            CrystalDecisions.Web.CrystalReportViewer cryView = new CrystalDecisions.Web.CrystalReportViewer();
            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
            CrDiskFileDestinationOptions.DiskFileName = Server.MapPath("Pedidos\\" + sNameFile + ".pdf");
            CrExportOptions = rpt.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions = CrFormatTypeOptions;
            }
            rpt.Export();
        }
        catch (Exception ex)
        {
            throw ex;
            //lblInfo.Text = ex.Message + (ex.InnerException != null ? ex.InnerException.Message : "");
        }
    }