|
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Namespace ASPNET.StarterKit.Reports.Components
'*********************************************************************
'
' This class inherits from the ArrayList class. This 'thin class'
' will hold the result values from the stored procedure queries
' run in the HierarchicalReport class.
'
'*********************************************************************
Public Class HierarchicalReportCollection
Inherits ArrayList
Public Enum HierarchicalReportFields
InitValue
Territory
SalesTotals
EmployeeName
End Enum 'HierarchicalReportFields
'*********************************************************************
'
' Sort()
'
' This is where the actual sorting takes place when the user clicks
' on a column header. Based on which column the user clicks,
' represented by an enum, the Sort() method calls the appropriate
' IComparer class to compare the items in the base Array List.
'
'*********************************************************************
Public Overloads Sub Sort(ByVal sortField As HierarchicalReportFields, ByVal isAscending As Boolean)
Select Case sortField
Case HierarchicalReportFields.Territory
MyBase.Sort(New TerritoryNameComparer())
Case HierarchicalReportFields.SalesTotals
MyBase.Sort(New SalesTotalsComparer())
Case HierarchicalReportFields.EmployeeName
MyBase.Sort(New EmployeeNameComparer())
End Select
If Not isAscending Then
MyBase.Reverse()
End If
End Sub 'Sort
Private NotInheritable Class TerritoryNameComparer
Implements IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
Dim first As HierarchicalReport = CType(x, HierarchicalReport)
Dim second As HierarchicalReport = CType(y, HierarchicalReport)
Return first.TerritoryDescription.CompareTo(second.TerritoryDescription)
End Function 'Compare
End Class 'TerritoryNameComparer
Private NotInheritable Class SalesTotalsComparer
Implements IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
Dim first As HierarchicalReport = CType(x, HierarchicalReport)
Dim second As HierarchicalReport = CType(y, HierarchicalReport)
Return first.SalesTotals.CompareTo(second.SalesTotals)
End Function 'Compare
End Class 'SalesTotalsComparer
Private NotInheritable Class EmployeeNameComparer
Implements IComparer
Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare
Dim first As HierarchicalReport = CType(x, HierarchicalReport)
Dim second As HierarchicalReport = CType(y, HierarchicalReport)
Return first.EmployeeName.CompareTo(second.EmployeeName)
End Function 'Compare
End Class 'EmployeeNameComparer
End Class 'HierarchicalReportCollection
End Namespace 'ASPNET.StarterKit.Reports.Components
|
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