To create the report, I used the DataSet referenced later in this article (in the Creating the Data Object section) as the data source. The report will render players' totals and averages per year. Let's set up the Report!
In my Visual Studio Project, I add a new item (right-click on the Project) and select a Crystal Report, and name it PlayersWithYards.rpt.
Figure 1:
Next, select the "Using the Report Wizard" option to begin the creation of the report. I did some additional formatting of the report after using the wizard, so feel free to use the downloaded report if you do not wish to repeat this process. We'll step through the initial creation of the report to get the feel for how similar this is to using a SQL statement or stored procedure.
Once you accept the Standard report wizard, the Data tab is displayed. Because the Business Object is in a different Project (named FFBusinessObjects), select ADO.NET from the "Create a New Connection" option. I then browsed in the File Path box to the FFAssistantDataSet.xsd DataSet schema found in the FFBusinessObjects project (in my case C:\Dev\FFAssistant\FFBusObjects). You then need to select all the available tables (Players, Positions, Stats, and Teams).
In the next dialog box, you need to create the relations between Teams and Positions, to Players. You're probably already familiar with this, but simply drag and drop the TeamID from Teams to the Players table. Do the same thing with the PositionID from the Positions table to the Players table.
In the next dialog box (Fields to Display), select the Position field from the Position table, PlayerName from the Players table, all the Passing fields (PassingYds, PassingAttmpts, PassingCmplt, PassingTDs, Interceptions, and PassingLong), Year and Gamenumber from the Stats table, TeamCity, and TeamName from the Teams table.
In the Grouping dialog box, select PlayerName then Year. In the next dialog, you are asked what fields to sum. Remove all of the sums at the PlayerName Grouping level. Also remove the sum of Year and GameNumber at the Year level.
In the next Group Sorting dialogue box, leave the ordering on none. In the chart dialogue box, be sure to accept the default. Next, don’t add anything in the Record selection dialogue box. Finally, select the Leading Break Style in the next dialogue box. You've now created the Report.