Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

18.05 C# Code Listings

C# Code Listings

The C# code listings are equivalent to the VB.NET code listings.

Listing 18-1. Consuming a project’s web service
private void Form1_Load(object sender, System.EventArgs e)
{
crystalReportViewer1.ReportSource = new localhost.EmployeeListService();
}
Listing 18-2. Preview a report using the web service URL.
private void Form1_Load(object sender, System.EventArgs e)
{
crystalReportViewer1.ReportSource =
"http://localhost/VBWebService/EmployeeListService.asmx";
}
Listing 18-3. Print a web service report without previewing it.
private void Form1_Load(object sender, System.EventArgs e)
{
crystalReportViewer1.ReportSource =
"http://localhost/VBWebService/EmployeeListService.asmx";
crystalReportViewer1.PrintReport();
crystalReportViewer1.ReportSource = null;
}
Listing 18-4. Setting the parameter of a report web service.
private void Form1_Load(object sender, System.EventArgs e)
{
CrystalDecisions.Shared.IParameterField ParameterField;
CrystalDecisions.Shared.ParameterDiscreteValue DiscreteValue =
new CrystalDecisions.Shared.ParameterDiscreteValue();
crystalReportViewer1.ReportSource =
"http://localhost/C_WebService/EmployeeListService.asmx";
ParameterField = crystalReportViewer1.ParameterFieldInfo["LastName"];
DiscreteValue.Value = "B*";
ParameterField.CurrentValues.Add(DiscreteValue);
}
Listing 18-5. Assign a DataSet object to the report’s data source
public virtual ReportDocument CreateReport()
{
EmployeeList report =
new EmployeeList();
//Put all your report modification code here
DataSet MyDataSet = new DataSet();
//Call one of the sample methods from Chapter 17 for populating
//the DataSet object
FillDataSet(MyDataSet);
report.SetDataSource(MyDataSet);
report.InitReport += new EventHandler( this.webService.OnInitReport );
return ( report );
}