Click here to Skip to main content
15,881,882 members
Articles / Containers / Virtual Machine

ASP.NET Report Kit Grasshoper (Race to Linux)

Rate me:
Please Sign up or sign in to vote.
2.38/5 (5 votes)
2 Oct 20057 min read 37.8K   19  
Porting and deploying the report starter kit to Linux (RH7.3/Tomcat5.0.28/Grasshoper1.61)
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.

License

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


Written By
Software Developer (Senior)
United States United States
I love to code! Working in C# is my passion, visit my github

Comments and Discussions