9.4. Summary

This chapter described a pattern for creating reports within an enterprise-level application. The Crystal Reports for .NET objects are a great add-on to Visual Studio that enable you to easily generate reports in any application, and the Crystal Reports designer enables you to customize nearly every aspect of the report. The Crystal object model enables you to manipulate the report at runtime. You can change groups, sorting, selection formulas, formula fields, and almost any aspect of the report. It is definitely a top-notch tool when it comes to reporting.

The steps to create a Crystal Reports are as follows:

  • Create a stored procedure with a denormalized view of the data.

  • Add the stored procedure to the methods of the DataContext object.

  • Create a data class in the DAL to call the DataContext's method.

  • Create a business class in the BLL to call the Data class. This class should return the data as an object array.

  • Create a DataSet in the UI layer that will be used as the placeholder for the fields in the report. The dataset will never be used at runtime — it is merely a schema that the report designer needs to enable you to design the report.

  • Add a Crystal Reports file to the project and use the schema as the database source.

  • Add a button or use a button on a master page to display the report. The button's onclick attribute should call the GetPrintButtonScript method in the BasePage class to show the report in a new window correctly.

  • Add code to the Print button's OnClick ...

Get ASP.NET 3.5 Enterprise Application Development with Visual Studio® 2008: Problem - Design - Solution now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.