|
<html><head><link rel=stylesheet href=style.css></head><body><div class=SourcePanel style='font-size:12'><pre style='background-color:white'>
<font color= "blue">using</font> System;
<font color= "blue">using</font> System.Collections;
<font color= "blue"></font>
<font color= "blue">namespace</font> ASPNET.StarterKit.Reports.Components
<font color= "blue"></font>{
<font color= "green"> //*********************************************************************</font>
<font color= "green"> //</font>
<font color= "green"> // TabularReportCollection Class </font>
<font color= "green"> //</font>
<font color= "green"> // The TabularReportCollection is a Custom TabularReport collection used </font>
<font color= "green"> // to represent a list of tabular report data item.</font>
<font color= "green"> //</font>
<font color= "green"> //</font>
<font color= "green"> //*********************************************************************</font>
<font color= "blue"></font>
<font color= "blue"> public class</font> TabularReportCollection : ArrayList
<font color= "blue"> </font>{
<font color= "blue"> public enum</font> TabularReportFields
<font color= "blue"> </font>{
<font color= "blue"> </font>InitValue,
<font color= "blue"> </font>ProductName,
<font color= "blue"> </font>UnitsInStock,
<font color= "blue"> </font>UnitPrice
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> public void</font> Sort(TabularReportFields sortField, bool isAscending)
<font color= "blue"> </font>{
<font color= "blue"> switch</font> (sortField)
<font color= "blue"> </font>{
<font color= "blue"> case</font> TabularReportFields.ProductName:
<font color= "blue"> </font>base.Sort(new ProductNameComparer());
<font color= "blue"> </font>break;
<font color= "blue"> case</font> TabularReportFields.UnitsInStock:
<font color= "blue"> </font>base.Sort(new UnitsInStockComparer());
<font color= "blue"> </font>break;
<font color= "blue"> case</font> TabularReportFields.UnitPrice:
<font color= "blue"> </font>base.Sort(new UnitPriceComparer());
<font color= "blue"> </font>break;
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"></font><font color= "blue"> if </font>(!isAscending) base.Reverse();<font color= "blue"></font>
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> private </font>sealed class ProductNameComparer : IComparer
<font color= "blue"> </font>{
<font color= "blue"> public </font>int Compare(object x, object y)
<font color= "blue"> </font>{
<font color= "blue"> </font>TabularReport first = (TabularReport) x;
<font color= "blue"> </font>TabularReport second = (TabularReport) y;
<font color= "blue"> return</font> first.ProductName.CompareTo(second.ProductName);
<font color= "blue"> </font>}
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> private </font>sealed class UnitsInStockComparer : IComparer
<font color= "blue"> </font>{
<font color= "blue"> public </font>int Compare(object x, object y)
<font color= "blue"> </font>{
<font color= "blue"> </font>TabularReport first = (TabularReport) x;
<font color= "blue"> </font>TabularReport second = (TabularReport) y;
<font color= "blue"> return</font> first.UnitsInStock.CompareTo(second.UnitsInStock);
<font color= "blue"> </font>}
<font color= "blue"> </font>}
<font color= "blue"></font>
<font color= "blue"> private </font>sealed class UnitPriceComparer : IComparer
<font color= "blue"> </font>{
<font color= "blue"> public </font>int Compare(object x, object y)
<font color= "blue"> </font>{
<font color= "blue"> </font>TabularReport first = (TabularReport) x;
<font color= "blue"> </font>TabularReport second = (TabularReport) y;
<font color= "blue"> return</font> first.UnitPrice.CompareTo(second.UnitPrice);
<font color= "blue"> </font>}
<font color= "blue"> </font>}
<font color= "blue"> </font>}
<font color= "blue"></font>}
</pre>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.