CHAPTER 7 USING CUSTOM .NET CODE WITH REPORTS
Note If possible, you would want to get this information directly from the HR system, possibly through a web
service. The sample code included with this chapter includes a sample web service and a method to call it.
Using the XML file EmployeePay.xml (supplied as part of the code download for this chapter) in this
example allows you not only to write a custom assembly, but also to see the steps necessary to access a
protected resource such as a local file. To get the information from the XML file and make it available to
your report, create a class with a method that takes EmployeeID and a date as a parameter and that will
read the employee pay per visit rates from the XML file and then return the pay rate. Although we will
not cover it step by step in this chapter, the sample code included also contains an example of doing the
same thing using a web service. This allows you to simulate being able to interact with the HR system via
a web service instead of an exported file.
You can then reference the assembly that you have developed from an expression in the report and
use it to calculate the total visiting costs per patient.
To start, select File Add New Project from the menu. Pick Visual Basic Projects or Visual C#
Projects, depending on your preference. Select Class Library, and enter Employee for the name of the
project. In this example, we will show you how to use a Visual C# class library project, as shown in
Figure 7-9.
Figure 7-9. Add New ProJect dialog box