AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=523&pId=-1
Sample App: FFAssist Using Crystal .NET for VS 2005 - Part 1
page
by Eric Landes
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 20291/ 35

Introduction

This article, along with at least another 2 parts, will attempt to dissect a sample application I will build throughout the articles.  We start with Crystal .NET basics, then work up to incorporating new .NET 2.0 features and Crystal .NET features into the sample. A link to the first version of the actual sample will be included in part 2.  Setup instructions are there as well.

Background

My background as a developer includes being responsible for developing many applicatins that include reports.  That introduced me to Crystal, starting with version 8.0.  I then had a lot of experience with the .NET version when Visual Studio .NET came out.  ASP.NET introduced a lot of great improvements for clasic asp web developers.  Crystal's .NET version had some improvements as well, but also introduced some drawbacks especially in the printing space.

With the new version of .NET looming, I began looking for some documentation on the new version of Crystal, included with Visual Studio. 

The sample applciation 

In looking at the new version of Visual Studio (formerly code-named Whidbey, now called Visual Studio 2005), I wanted to look specifically at what the new features this version of Crystal has.  This new version is based on the Crystal Reports 10 engine.  Since I have a lot of experience with Crystal .NET and the Crystal 8.5 version, I was hopeful that some issues I had found difficult had been solved.

I thought the best way to discover these issues was to develop a sample application in VS 2005.  Besides giving me some experience with Crystal .NET, I'd get some more experiences with the new server controls and data access components. 

I chose to make this sample something that may help me in my Fantasy Football league, since I really need help!  I finished last in my league this year, so next year, I need a boost.  Other FF aficiandos may want to use this sample as a basis, but change the stastical analysis parts to something that actually wins leagues!  By the end of this series of articles, this sample should be something useful for me in my fantasy league.  As far as your fantasy league, you'll probably need to make your own modifications.  Keep in mind that these beginning articles are a starting point sample application, not a finished product.

Back to the Crystal .NET tools included with VS 2005.  As I mentioned above, I had issues with the old version of Crystal .NET for VS 2003.  Some of those issues were , in no particular order:

  • Allow printing using the client printers from the Crystal Viewer
  • Simplify programmatically logging onto a the database.
  • Simplify applying Parameters to stored procedure data sources.
  • Allowing WYSIWYG reporting previews in Visual Studio when designing a report.

Some but not all of these issues appear to be solved.  I will cover them later in this article.

System Requirements

This application was developed on a AMD 1Gighz laptop with 256M RAM, Windows XP Professional, SQL Server 2000, and the Visual Studio 2005, Beta 1 Refresh.

Differences between Crystal .NET VS 2003 and 2005

Before I go over the architecture of the sample application, I want to go over the differences between Visual Studio 2005 Crystal .NET and Visual Studio 2003 Crystal .NET.  This comparison does not include standalone Crystal 9 or 10.

The biggest difference is the Crystal Viewer.  Many complaints on the mailing list center around printing with the viewer server control contained in Crystal .NET in VS 2002 and VS 2003 .  Since the ASP.NET control is server based, any application using that control for printing has to print using server based printers.  This led to most ASP.NET applications using Crystal to add a lot of code to output to PDF in the browser.  This usually involved coding output to the browser and streaming the file to a memory stream.  The article "Automagically Display Crystal Parameters: Part III" provides code examples on how to accomplish this.

Crystal Viewer in action

In VS 2005, the Viewer allows client side printing out of the box.  Drop the Viewer on a web page, bind it to an existing report, and run the project.  A simple report will display in the viewer ad allow you to export it to pdf and excel.  This is so much cleaner than the VS 2003 version.

Another stellar improvement to the Viewer is the ability to preview your report in the designer.  In the previous .NET version, to preview the report look and feel you had to either use a standalone version of Crystal, or run your application to view it.  Now, there is a way to preview that is similar to the standalone versions of Crystal.  This is quite helpful.

Another difference is that this version is based on the Crystal 10 engine which includes a more efficient data retrieving engine.  Also, it includes the ability to attach to ADO.NET datasets and classes.  I will attempt to attach to the  ObjectDataSource in a future part of the series. 

The ObjectDataSource is a quick and easy way to attach to your data layer using an Object Oriented pattern (or close to it) to access the data.  I will be exploring it's use with Crystal in a future article.

Application Architecture Explained

As stated before this sample application is to be used as the basis to analyze Fantasy Football players for my Fantasy Footbal team.  The first sample will show reports for Quarterback only.  As the application progresses, I will add features for different statistics for the different positions.

Simple Architecture Diagram

Simple Architecture diagram of application

The Crystal .NET reports will display the data sliced and diced in the way I want. The reports will be the view into most of the data, rather than using an ASP.NET form to view the data. 

There is also an administrative portion of the applicaiton that will allow the user to add players, teams, statistics and positions.  This could eventually be extended to include other fantasy sports, except for Fantasy NASCAR ;-). 

Eventually the data entry should be automated using screen scraping or RSS feeds from yahoo sports.

This application also utilizes some of the new data access controls included with VS 2005.  I utilize mainly the SQLDataSource control for access on the pages.  This gives a nice drag and drop utility, and it's like using a Data Access Layer.  While I don't have it persisting across the different pages and user controls, the concept is the same for each administrative page.  For those pages, it's very simple to set it up to do most of the CRUD functions using this control.

Database Schema

The following is the schema I developed for the different tables.  I am not using any type of naming convention for the table names, but I do with Stored Procedures and views.  The naming convention for the Stored Procedures is to put a p_ then a description of the function and finally the table name, or a description or the joins being used.  For example, a query selecting all records in the Players table would be called p_get_players. 

CREATE TABLE [dbo].[Players] (
[Player_id] [int] IDENTITY (1, 1) NOT NULL ,
[Team_ID] [int] NOT NULL ,
[Position_ID] [int] NOT NULL ,
[PlayerName] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[InjuryStatus] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]


GO


CREATE TABLE [dbo].[Positions] (
[PositionID] [int] IDENTITY (1, 1) NOT NULL ,
[Position] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Description] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]


GO


CREATE TABLE [dbo].[Stats] (
[Stats_ID] [int] IDENTITY (1, 1) NOT NULL ,
[Player_ID] [int] NOT NULL ,
[PassingYds] [int] NULL ,
[PassingAttmpts] [int] NULL ,
[PassingComplt] [int] NULL ,
[PassingTDs] [int] NULL ,
[Inteceptions] [int] NULL ,
[PassingLong] [int] NULL ,
[RuningYds] [int] NULL ,
[RunningAttmpts] [int] NULL ,
[RunningAvg] [int] NULL ,
[RunningTD] [int] NULL ,
[RunningLong] [int] NULL ,
[GameNumber] [int] NOT NULL ,
[Year] [int] NOT NULL 
) ON [PRIMARY]


GO


CREATE TABLE [dbo].[Teams] (
[TeamID] [int] IDENTITY (1, 1) NOT NULL ,
[TeamName] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[TeamCity] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[TeamState] [nchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL 
) ON [PRIMARY]


GO

Currently it's very simple, with Team, Player, Positions and Stats as the main table.  The first report in the application uses Stats, Player and Team.  In the second installment of this article, I'll step you through the code and pages.


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 11:47:52 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search