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 event to create the report object, load the report file, set its data source, and send the report back as a PDF to the Response object.

When I showed Mary the My Request report and the Role report she was quite happy; but like most clients, she wanted more. Her immediate reaction was to ask for a whole slew of new reports. She now wants a report that displays a list of outstanding requests, a report that shows the requests by current owner, and a report of approved requests. After talking it over with her for a few moments, I figured out that she wants the same report each time, but that the criteria for each report are different.

This leads into the next chapter, which creates a server-side control that enables a user to dynamically create a where clause that can be applied to a report or even a List object. The QueryBuilder control is specifically designed to address Mary's new need: the same report with different criteria. The control is smart enough to handle ANDs and ORs and even predecessors. It can save you a lot of time when it comes to reports and lists of data, and it gives users a lot of flexibility when using your application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.162.26