⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tabularreportcollection.cs

📁 ASP.NET 建立和发布可自定义 Web 报表的指南
💻 CS
字号:
using System;
using System.Collections;

namespace ASPNET.StarterKit.Reports.Components
{
	//*********************************************************************
	//
	// TabularReportCollection Class 
	//
	// The TabularReportCollection is a Custom TabularReport collection used 
	// to represent a list of tabular report data item.
	//
	//
	//*********************************************************************

	public class TabularReportCollection : ArrayList
	{
		public enum TabularReportFields
		{
			InitValue,
			ProductName,
			UnitsInStock,
			UnitPrice
		}

		public void Sort(TabularReportFields sortField, bool isAscending)
		{
			switch (sortField) 
			{
				case TabularReportFields.ProductName:
					base.Sort(new ProductNameComparer());
					break;
				case TabularReportFields.UnitsInStock:
					base.Sort(new UnitsInStockComparer());
					break;
				case TabularReportFields.UnitPrice:
					base.Sort(new UnitPriceComparer());
					break;
			}

			if (!isAscending) base.Reverse();
		}

		private sealed class ProductNameComparer : IComparer 
		{
			public int Compare(object x, object y)
			{
				TabularReport first = (TabularReport) x;
				TabularReport second = (TabularReport) y;
				return first.ProductName.CompareTo(second.ProductName);
			}
		}

		private sealed class UnitsInStockComparer : IComparer 
		{
			public int Compare(object x, object y)
			{
				TabularReport first = (TabularReport) x;
				TabularReport second = (TabularReport) y;
				return first.UnitsInStock.CompareTo(second.UnitsInStock);
			}
		}

		private sealed class UnitPriceComparer : IComparer 
		{
			public int Compare(object x, object y)
			{
				TabularReport first = (TabularReport) x;
				TabularReport second = (TabularReport) y;
				return first.UnitPrice.CompareTo(second.UnitPrice);
			}
		}
	}
}

⌨️ 快捷键说明

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