simplereport.cs

来自「ASP.NET 建立和发布可自定义 Web 报表的指南」· CS 代码 · 共 83 行

CS
83
字号
using System;
using System.Data;
using System.Configuration;
using ASPNET.StarterKit.Reports.DataAccessLayer;
using System.Collections;

namespace ASPNET.StarterKit.Reports.Components
{
	//*********************************************************************
	//
	// SimpleReport Class
	//
	// The SimpleReport class is used to represent a data item for Simple Report 
	// and is mainly used to retrieve data from the database.
	//
	//*********************************************************************

	public class SimpleReport
	{
		private string _city;
		private string _companyName;
		private string _contactName;
		private string _contactTitle;
		private string _phone;

		public string City
		{
			get { return _city; }
			set { _city = value; }
		}

		public string CompanyName
		{
			get { return _companyName; }
			set { _companyName = value; }
		}

		public string ContactName
		{
			get { return _contactName; }
			set { _contactName = value; }
		}
		
		public string ContactTitle
		{
			get { return _contactTitle; }
			set { _contactTitle = value; }
		}

		public string Phone
		{
			get { return _phone; }
			set { _phone = value; }
		}

		//*********************************************************************
		//
		// GetCustomerContacts method retrieves all the necessary customer contacts
		// information from the database and transforms the result to a SimpleReportCollection
		// custom colletion before returning it to the calling function
		//
		//*********************************************************************
		
		public static SimpleReportCollection GetCustomerContacts()
		{
			DataSet dsData = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings[Global.CfgKeyConnString], "Reports_GetCustomerContacts");
			SimpleReportCollection items = new SimpleReportCollection();

			foreach(DataRow row in dsData.Tables[0].Rows)
			{
				SimpleReport item = new SimpleReport();
				item.City = row["City"].ToString();
				item.CompanyName = row["CompanyName"].ToString();
				item.ContactName = row["ContactName"].ToString();
				item.ContactTitle = row["ContactTitle"].ToString();
				item.Phone = row["Phone"].ToString();
				items.Add(item);
			}
			return items;
		}	
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?