In many applications, reports are indispensable, a good report can visually let people grasp the situation of data, convenient decision-making. In this article, we will take a three-tier structure of the asp.net process as an example, introduce how to use the Crystal Report, to produce a statement, which introduces a lot of asp.net and Crystal report skills.
In this example, the application we envision is to produce a report for a sales department, where the manager can look at the sales over a period of time and reflect the sales trend in the form of a list or line chart. We'll use SQL Server 2000 as a database, using vb.net to write the middle-tier logic layer, while the presentation layer on the front end uses C #. Let's look at the structure of the database first.
The Tbitem table contains the items ordered in each order, Tbsales stores each order, Tblsalesperson is the salesperson's table, and every salesperson who holds the publisher.
Next, use SQL Server 2000来 to create these tables. The structure of the table looks like this:
CREATE TABLE [dbo].[tblItem] (
[ItemId] [int] NOT NULL ,
[Description] [varchar] (50) NOT NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[tblSalesPerson] (
[SalesPersonId] [int] NOT NULL ,
[UserName] [varchar] (50) NOT NULL ,
[Password] [varchar] (30) NOT NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[tblSales] (
[SaleId] [int] IDENTITY (1, 1) NOT NULL ,
[SalesPersonId] [int] NOT NULL ,
[ItemId] [int] NOT NULL ,
[SaleDate] [datetime] NOT NULL ,
[Amount] [int] NOT NULL
) ON [PRIMARY]
and use the following code to create a constraint relationship between tables.
ALTER TABLE tblItem
ADD CONSTRAINT PK_ItemId
PRIMARY KEY (ItemId)
GO
ALTER TABLE tblSalesPerson
ADD CONSTRAINT PK_SalesPersonId
PRIMARY KEY (SalesPersonId)
GO
ALTER TABLE tblSales
ADD CONSTRAINT FK_ItemId
FOREIGN KEY (ItemId) REFERENCES tblItem(ItemId)
GO
ALTER TABLE tblSales
ADD CONSTRAINT FK_SalesPersonId
FOREIGN KEY (SalesPersonId) REFERENCES tblSalesPerson(SalesPersonId)
GO