    Imports System
    Imports System.Configuration
    Imports System.Data
    Imports ASPNET.StarterKit.TimeTracker.DataAccessLayer

    Namespace ASPNET.StarterKit.TimeTracker.BusinessLogicLayer

        '*********************************************************************
        '
        '    ProjectReportCategory Class
        '
        '    This class represents category item in Project Report page
        '
        '*********************************************************************

        Public Class ProjectReportCategory
            Private _actualHours As Decimal
            Private _categoryID As Integer
            Private _categoryName As String
            Private _categoryShortName As String
            Private _estDuration As Decimal

            Public Sub New()
                _categoryID = 0
                _categoryName = String.Empty
                _categoryShortName = String.Empty
                _estDuration = 0D
                _actualHours = 0D
            End Sub 'New

            Public Property ActualHours() As Decimal
                Get
                    Return _actualHours
                End Get
                Set(ByVal Value As Decimal)
                    _actualHours = Value
                End Set
            End Property

            Public Property CategoryID() As Integer
                Get
                    Return _categoryID
                End Get
                Set(ByVal Value As Integer)
                    _categoryID = Value
                End Set
            End Property

            Public Property CategoryName() As String
                Get
                    Return _categoryName
                End Get
                Set(ByVal Value As String)
                    _categoryName = Value
                End Set
            End Property

            Public Property CategoryShortName() As String
                Get
                    Return _categoryShortName
                End Get
                Set(ByVal Value As String)
                    _categoryShortName = Value
                End Set
            End Property

            Public Property EstDuration() As Decimal
                Get
                    Return _estDuration
                End Get
                Set(ByVal Value As Decimal)
                    _estDuration = Value
                End Set
            End Property

            '*********************************************************************
            '
            '    GetCategorySummary returns project report category summary by each project.
            '
            '*********************************************************************

            Public Shared Function GetCategorySummary(ByVal projectID As Integer) As ProjectReportCategoryCollection
                Dim dsCats As DataSet = SqlHelper.ExecuteDataset(ConfigurationSettings.AppSettings(Web.Global.CfgKeyConnString), "TT_ListCategoriesByProject", projectID)
                Dim categoryList As New ProjectReportCategoryCollection()

                ' Separate Data into a list of collections.
                Dim row As DataRow
                For Each row In dsCats.Tables(0).Rows
                    Dim cat As New ProjectReportCategory()
                    cat.CategoryID = Convert.ToInt32(row("CategoryID"))
                    cat.CategoryName = row("Name").ToString()
                    cat.CategoryShortName = row("CategoryShortName").ToString()
                    cat.EstDuration = Convert.ToDecimal(row("EstDuration"))
                    cat.ActualHours = Convert.ToDecimal(row("ActualHours"))

                    categoryList.Add(cat)
                Next row

                Return categoryList
            End Function 'GetCategorySummary
        End Class 'ProjectReportCategory
    End Namespace 'ASPNET.StarterKit.TimeTracker.BusinessLogicLayer