xinjiang/SGGL/FineUIPro.Web/HJGL/TrustManage/Fastreport.aspx.cs

104 lines
3.4 KiB
C#

using BLL;
using FastReport;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.TrustManage
{
public partial class Fastreport : PageBase
{
public string ReportPath
{
get
{
return (string)ViewState["ReportPath"];
}
set
{
ViewState["ReportPath"] = value;
}
}
public List<DataTable> dataTables
{
get
{
return (List<DataTable>)Session["ReportDataTables"];
}
}
public Dictionary<string, string> ParameterValues
{
get
{
return (Dictionary<string, string>)Session["ReportParameterValues"];
}
}
protected void Page_Load(object sender, EventArgs e)
{
ReportPath = Request.Params["ReportPath"];
WebReport1.StartReport += WebReport1_StartReport;
if (dataTables!=null&&dataTables.Count > 0)
{
for (int i = 0; i < dataTables.Count; i++)
{
WebReport1.RegisterData(dataTables[i], dataTables[i].TableName);
}
}
WebReport1.Report.Load(ReportPath);
if (WebReport1.Report.Dictionary.Connections.Count > 0)
{
WebReport1.Report.Dictionary.Connections[0].ConnectionString = Funs.ConnString;
WebReport1.Report.Save(ReportPath);
}
WebReport1.ReportFile = ReportPath;
WebReport1.Prepare();
// WebReport1.ExportPdf();
}
private void demo()
{
Report report2 = new Report(); //Create a Report instance which will be displayed in the second tab
report2.RegisterData(dataTables[0], dataTables[0].TableName); //Register data source in the report object
if (ParameterValues.Count > 0)
{
foreach (KeyValuePair<string, string> kvp in ParameterValues)
{
report2.Report.SetParameterValue(kvp.Key, kvp.Value);
}
// WebReport1.Report.SetParameterValue("CH_TrustID", Session["CH_TrustID"].ToString());
}
report2.Load(ReportPath); //Load a report into the report object
report2.Prepare();
// Report report3 = new Report(); //Create a Report instance which will be displayed in the third tab
report2.Load(@"D:\fastreport\FastReports\FastReport.Net Trial\Demos\Reports\Text.frx");
// report2.AddChild(report3);
report2.Prepare(true);
FastReport.Export.Pdf.PDFExport exp = new FastReport.Export.Pdf.PDFExport();
report2.Export(exp, @"C:\Users\1420031550\Desktop\demo.pdf");
}
private void WebReport1_StartReport(object sender, EventArgs e)
{
if (ParameterValues.Count > 0)
{
foreach (KeyValuePair<string, string> kvp in ParameterValues)
{
WebReport1.Report.SetParameterValue(kvp.Key, kvp.Value);
}
// WebReport1.Report.SetParameterValue("CH_TrustID", Session["CH_TrustID"].ToString());
}
}
}
}