or
public
Report1(LINQToSQLDataContext dataContext)
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
// custom constructor actions
this
.DataContext = context;
// for debugging
detail.ItemDataBound +=
new
EventHandler(detail_ItemDataBound);
this
.detail.ItemDataBinding +=
new
EventHandler(detail_ItemDataBinding);
// force NeedDataSource to fire
this
.DataSource =
null
;
this
.NeedDataSource +=
new
EventHandler(Report1_NeedDataSource);
this
.Error +=
new
ErrorEventHandler(Report1_Error);
// replace the subReport in order to pass it the MyContactMethodController to replace its static DataSource
Report2 emailReport =
new
Report2SubReport(
this
.MyContactMethodController);
this
.Report2SubReport.ReportSource =
new
InstanceReportSource() { ReportDocument = emailReport };
this
.Report2SubReport.ReportSource.Parameters.Add(
new
Telerik.Reporting.Parameter(
"parameter1"
,
"=Fields.ID"
));
this
.Report2SubReport.ReportSource.Parameters.Add(
new
Telerik.Reporting.Parameter(
"effectiveDate"
,
"=Parameters.effectiveDate.Value"
));
}
#region Event Handlers
void
Report1_NeedDataSource(
object
sender, EventArgs e)
{
Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)sender;
var id = report.Parameters[
"ID"
].Value;
_ID = Convert.ToInt32(ufdID);
var effectiveDT = report.Parameters[
"effectiveDate"
].Value;
_effectiveDate = Convert.ToDateTime(effectiveDT);
this
.DataSource =
this
.MyDataController.GetHighLevelInfo(_ID, _effectiveDate);
}
// for debugging
void
Report1_ItemDataBinding(
object
sender, EventArgs e)
{
int
? id = (((Telerik.Reporting.Processing.ReportItemBase)(sender))).DataObject.RawData
as
int
?;
}
// for debugging
void
detail_ItemDataBinding(
object
sender, EventArgs e)
{
Telerik.Reporting.Processing.ReportSection reportSection = sender
as
Telerik.Reporting.Processing.ReportSection;
HighLevelInfo data = reportSection.DataObject.RawData
as
HighLevelInfo;
_ID = data.ID;
}
// for debugging
void
detail_ItemDataBound(
object
sender, EventArgs e)
{
Telerik.Reporting.Processing.ReportSection reportSection = sender
as
Telerik.Reporting.Processing.ReportSection;
var data = reportSection.DataObject.RawData;
}
void
Report1_Error(
object
sender, ErrorEventArgs eventArgs)
{
throw
new
Exception(
string
.Format(
"{0} Telerik Report Exception: {1}"
,
this
.Name, eventArgs.Exception.ToString()), eventArgs.Exception);
}
#endregion Event Handlers
public
Report2(DataController dc)
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
// save controller for the NeedDataSource event handler
this
.MyDataController = dc;
// force NeedDataSource to fire
this
.DataSource =
null
;
this
.NeedDataSource +=
new
EventHandler(Report2_NeedDataSource);
this
.Error +=
new
ErrorEventHandler(Report2_Error);
// replace the subReport in order to pass it the MyDataController
Report3 report3 =
new
Report3(
this
.MyDataController);
// force NeedDataSource to fire
report3.DataSource =
null
;
this
.Report3SubReport.ReportSource =
new
InstanceReportSource() { ReportDocument = report3 };
this
.Report3SubReport.ReportSource.Parameters.Add(
new
Telerik.Reporting.Parameter(
"parameter1"
,
"=Parameters.parameter1.Value"
));
this
.Report3SubReport.ReportSource.Parameters.Add(
new
Telerik.Reporting.Parameter(
"parameter2"
,
"=Parameters.effectiveDate.Value"
));
this
.Report3SubReport.ReportSource.Parameters.Add(
new
Telerik.Reporting.Parameter(
"parameter3"
,
"=Fields.ID"
));
this
.Report3SubReport.ReportSource.Parameters.Add(
new
Telerik.Reporting.Parameter(
"parameter4"
,
"=Fields.Name"
));
}
private
DataController MyDataController {
get
;
set
; }
private
void
Report2_NeedDataSource(
object
sender, EventArgs e)
{
int
parameter1 = Convert.ToInt32(
this
.ReportParameters[
"parameter1"
].Value);
DateTime effectiveDate = Convert.ToDateTime(
this
.ReportParameters[
"effectiveDate"
].Value);
List<DetailInfo> detailList =
this
.MyDataController.GetDetailInfoList(parameter1, effectiveDate);
this
.DataSource = detailList;
}
void
Report2_Error(
object
sender, ErrorEventArgs eventArgs)
{
throw
new
Exception(
string
.Format(
"{0} Telerik Report Exception: {1}"
,
this
.Name, eventArgs.Exception.ToString()), eventArgs.Exception);
}
public
Report3(DataController dc)
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
// save controller for the NeedDataSource event handler
this
.MyDataController = dc;
// force NeedDataSource to fire
this
.DataSource =
null
;
this
.NeedDataSource +=
new
EventHandler(Report3SubReport_NeedDataSource);
this
.Error +=
new
ErrorEventHandler(Report3SubReport_Error);
}
private
DataController MyDataController {
get
;
set
; }
private
void
Report3SubReport_NeedDataSource(
object
sender, EventArgs e)
{
int
parameter1 = Convert.ToInt32(
this
.ReportParameters[
"applicantUserFormDetailID"
].Value);
DateTime effectiveDate = Convert.ToDateTime(
this
.ReportParameters[
"effectiveDate"
].Value);
int
parameter3 = Convert.ToInt32(
this
.ReportParameters[
"skillCategoryID"
].Value);
List<MoreDetailInfo> moreDetailInfoList =
this
.MyDataController.GetMoreDetailInfo(parameter1, parameter2, effectiveDate);
// bind datasource directly to my table. Binding to this.DataSource leaves the table blank.
this
.MyTable.DataSource = moreDetailInfoList;
}
void
Report3SubReport_Error(
object
sender, ErrorEventArgs eventArgs)
{
throw
new
Exception(
string
.Format(
"{0} Telerik Report Exception: {1}"
,
this
.Name, eventArgs.Exception.ToString()), eventArgs.Exception);
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
Dim report As New Telerik.Reporting.Report() |
Dim detail As New Telerik.Reporting.DetailSection() |
Dim textBox2 As New Telerik.Reporting.TextBox() |
textBox2.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch)) |
textBox2.Value = "Hello World!" |
textBox2.Location = New Telerik.Reporting.Drawing.PointU(New Telerik.Reporting.Drawing.Unit(1.25, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0, Telerik.Reporting.Drawing.UnitType.Inch)) |
textBox2.Size = New Telerik.Reporting.Drawing.SizeU(New Telerik.Reporting.Drawing.Unit(4.75, Telerik.Reporting.Drawing.UnitType.Inch), New Telerik.Reporting.Drawing.Unit(0.25, Telerik.Reporting.Drawing.UnitType.Inch)) |
detail.Items.AddRange(New Telerik.Reporting.ReportItemBase() {textBox2}) |
detail.Height = New Telerik.Reporting.Drawing.Unit(0.3, Telerik.Reporting.Drawing.UnitType.Inch) |
report.Items.Add(DirectCast(detail, Telerik.Reporting.ReportItemBase)) |
ExportToPDF("Test", report) |
End Sub |
Sub ExportToPDF(ByVal reportName As String, ByVal reportToExport As Telerik.Reporting.Report) |
Dim mimeType As StringString = String.Empty |
Dim ext As StringString = String.Empty |
Dim encoding As EncodingEncoding = Encoding.[Default] |
Dim reportBytes As Byte() = ReportProcessor.Render("PDF", reportToExport, Nothing, mimeType, ext, encoding) |
Dim fileName As String = reportName + ".pdf" |
Response.Clear() |
Response.ContentType = mimeType |
Response.Cache.SetCacheability(HttpCacheability.[Private]) |
Response.Expires = -1 |
Response.Buffer = False |
Response.AddHeader("Content-Disposition", String.Format("{0};FileName=""{1}""", "attachment", fileName)) |
Response.OutputStream.Write(reportBytes, 0, reportBytes.Length) |
Response.[End]() |
End Sub |