Click here to Skip to main content
15,893,508 members
Articles / Programming Languages / Visual Basic

TeamVision

Rate me:
Please Sign up or sign in to vote.
3.08/5 (11 votes)
16 Nov 2009CPL3 min read 84.4K   5.4K   69  
A simple project task management application. A managed approach to help keep on top of your projects.
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.3082
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On

Imports TeamVision.Managers
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Reflection
Imports System.Text

'*************************************************************
' Class Name:  Task
' Purpose:  Class to encapsulate business rules and logic
' Description: 
'***************************************************************
Namespace Business
    
    Public Class Task
        Inherits Models.Task
        
        Private m_Category As Category
        
        Private m_Priority As Priority
        
        Private m_Project As Project
        
        Private m_State As State
        
        Private m_User As User
        
        Private m_Parent As Task
        
        Private m_ExpenseProxy As System.Collections.Generic.List(Of Expense) = Nothing
        
        Private m_PersonTaskProxy As System.Collections.Generic.List(Of PersonTask) = Nothing
        
        Private m_TaskFileProxy As System.Collections.Generic.List(Of TaskFile) = Nothing

        Private m_TaskChildrenProxy As System.Collections.Generic.List(Of Task) = Nothing
        
        Public Sub New()
            MyBase.New
            Me.InitializeClass
            m_ExpenseProxy = New System.Collections.Generic.List(Of Expense)
            m_PersonTaskProxy = New System.Collections.Generic.List(Of PersonTask)
            m_TaskFileProxy = New System.Collections.Generic.List(Of TaskFile)
        End Sub
        
        Public Sub New( _
                    ByVal TaskID As Integer,  _
                    ByVal CategoryID As Integer,  _
                    ByVal Comments As String,  _
                    ByVal DateCompleted As Date,  _
                    ByVal DateModified As Date,  _
                    ByVal Datestamp As Date,  _
                    ByVal Description As String,  _
                    ByVal DueDate As Date,  _
                    ByVal Duration As Double,  _
                    ByVal EstimatedHours As Double,  _
                    ByVal IsDeleted As Boolean,  _
                    ByVal Name As String,  _
                    ByVal Number As String,  _
                    ByVal ParentID As Integer,  _
                    ByVal PriorityID As Integer,  _
                    ByVal Progress As Double,  _
                    ByVal ProjectID As Integer,  _
                    ByVal Risk As Integer,  _
                    ByVal StartDate As Date,  _
                    ByVal StateID As Integer,  _
                    ByVal Summary As String,  _
                    ByVal UserID As Integer)
            MyBase.New
            Me.TaskID = TaskID
            Me.CategoryID = CategoryID
            Me.Comments = Comments
            Me.DateCompleted = DateCompleted
            Me.DateModified = DateModified
            Me.Datestamp = Datestamp
            Me.Description = Description
            Me.DueDate = DueDate
            Me.Duration = Duration
            Me.EstimatedHours = EstimatedHours
            Me.IsDeleted = IsDeleted
            Me.Name = Name
            Me.Number = Number
            Me.ParentID = ParentID
            Me.PriorityID = PriorityID
            Me.Progress = Progress
            Me.ProjectID = ProjectID
            Me.Risk = Risk
            Me.StartDate = StartDate
            Me.StateID = StateID
            Me.Summary = Summary
            Me.UserID = UserID
            m_ExpenseProxy = New System.Collections.Generic.List(Of Expense)
            m_PersonTaskProxy = New System.Collections.Generic.List(Of PersonTask)
            m_TaskFileProxy = New System.Collections.Generic.List(Of TaskFile)
        End Sub
        
        Public Sub New(ByVal row As Schema.TaskRow)
            MyBase.New
            Me.TaskID = row.TaskID
            Me.CategoryID = row.CategoryID
            Me.Comments = row.Comments
            Me.DateCompleted = row.DateCompleted
            Me.DateModified = row.DateModified
            Me.Datestamp = row.Datestamp
            Me.Description = row.Description
            Me.DueDate = row.DueDate
            Me.Duration = row.Duration
            Me.EstimatedHours = row.EstimatedHours
            Me.IsDeleted = row.IsDeleted
            Me.Name = row.Name
            Me.Number = row.Number
            Me.ParentID = row.ParentID
            Me.PriorityID = row.PriorityID
            Me.Progress = row.Progress
            Me.ProjectID = row.ProjectID
            Me.Risk = row.Risk
            Me.StartDate = row.StartDate
            Me.StateID = row.StateID
            Me.Summary = row.Summary
            Me.UserID = row.UserID
            m_ExpenseProxy = New System.Collections.Generic.List(Of Expense)
            m_PersonTaskProxy = New System.Collections.Generic.List(Of PersonTask)
            m_TaskFileProxy = New System.Collections.Generic.List(Of TaskFile)
        End Sub
        
        Public Property Category() As Category
            Get
                If (m_Category Is Nothing) Then
                    Me.LazyLoadCategory
                End If
                Return m_Category
            End Get
            Set
                m_Category = value
            End Set
        End Property
        
        Public Property Priority() As Priority
            Get
                If (m_Priority Is Nothing) Then
                    Me.LazyLoadPriority
                End If
                Return m_Priority
            End Get
            Set
                m_Priority = value
            End Set
        End Property
        
        Public Property Project() As Project
            Get
                If (m_Project Is Nothing) Then
                    Me.LazyLoadProject
                End If
                Return m_Project
            End Get
            Set
                m_Project = value
            End Set
        End Property
        
        Public Property State() As State
            Get
                If (m_State Is Nothing) Then
                    Me.LazyLoadState
                End If
                Return m_State
            End Get
            Set
                m_State = value
            End Set
        End Property
        
        Public Property User() As User
            Get
                If (m_User Is Nothing) Then
                    Me.LazyLoadUser
                End If
                Return m_User
            End Get
            Set
                m_User = value
            End Set
        End Property
        
        Public Property Parent() As Task
            Get
                If (m_Parent Is Nothing) Then
                    Me.LazyLoadParent
                End If
                Return m_Parent
            End Get
            Set
                m_Parent = value
            End Set
        End Property

        Public ReadOnly Property Children() As System.Collections.Generic.List(Of Task)
            Get
                m_TaskChildrenProxy = TaskManager.GetTasksByParentID(Me.TaskID)
                Return Me.m_TaskChildrenProxy
            End Get
        End Property
        
        Public ReadOnly Property Expenses() As System.Collections.Generic.List(Of Expense)
            Get
                m_ExpenseProxy = ExpenseManager.GetExpensesByTaskID(Me.TaskID)
                Return Me.m_ExpenseProxy
            End Get
        End Property
        
        Public ReadOnly Property PersonTasks() As System.Collections.Generic.List(Of PersonTask)
            Get
                m_PersonTaskProxy = PersonTaskManager.GetPersonTasksByTaskID(Me.TaskID)
                Return Me.m_PersonTaskProxy
            End Get
        End Property
        
        Public ReadOnly Property TaskFiles() As System.Collections.Generic.List(Of TaskFile)
            Get
                m_TaskFileProxy = TaskFileManager.GetTaskFilesByTaskID(Me.TaskID)
                Return Me.m_TaskFileProxy
            End Get
        End Property
        
        #Region "InitializeClass"
        Private Sub InitializeClass()
        End Sub
        #End Region
        
        #Region "OrderExpensesBy"
        Public Function OrderExpensesBy(ByVal ColumnName As String, ByVal ASC As String) As System.Collections.Generic.List(Of Expense)
            Dim sql As String = ""
            sql = ((((("[TaskID]=" + Me.TaskID.ToString)  _
                        + " ORDER BY ")  _
                        + ColumnName)  _
                        + " ")  _
                        + ASC)
            m_ExpenseProxy = ExpenseManager.GetExpensesWhere(sql)
            Return Me.m_ExpenseProxy
        End Function
        #End Region
        
        #Region "OrderPersonTasksBy"
        Public Function OrderPersonTasksBy(ByVal ColumnName As String, ByVal ASC As String) As System.Collections.Generic.List(Of PersonTask)
            Dim sql As String = ""
            sql = ((((("[TaskID]=" + Me.TaskID.ToString)  _
                        + " ORDER BY ")  _
                        + ColumnName)  _
                        + " ")  _
                        + ASC)
            m_PersonTaskProxy = PersonTaskManager.GetPersonTasksWhere(sql)
            Return Me.m_PersonTaskProxy
        End Function
        #End Region
        
        #Region "OrderTaskFilesBy"
        Public Function OrderTaskFilesBy(ByVal ColumnName As String, ByVal ASC As String) As System.Collections.Generic.List(Of TaskFile)
            Dim sql As String = ""
            sql = ((((("[TaskID]=" + Me.TaskID.ToString)  _
                        + " ORDER BY ")  _
                        + ColumnName)  _
                        + " ")  _
                        + ASC)
            m_TaskFileProxy = TaskFileManager.GetTaskFilesWhere(sql)
            Return Me.m_TaskFileProxy
        End Function
        #End Region
        
        #Region "RemoveExpense"
        Public Sub RemoveExpense(ByVal o As Business.Expense)
            ExpenseManager.Delete(o.ExpenseID)
        End Sub
        #End Region
        
        #Region "RemoveAllExpenses"
        Public Sub RemoveAllExpenses()
            m_ExpenseProxy.ForEach(AddressOf RemoveExpense)
        End Sub
        #End Region
        
        #Region "UpdateExpense"
        Public Sub UpdateExpense(ByVal o As Business.Expense)
            ExpenseManager.Update(o)
        End Sub
        #End Region
        
        #Region "UpdateAllExpenses"
        Public Sub UpdateAllExpenses()
            m_ExpenseProxy.ForEach(AddressOf UpdateExpense)
        End Sub
        #End Region
        
        #Region "RemovePersonTask"
        Public Sub RemovePersonTask(ByVal o As Business.PersonTask)
            PersonTaskManager.Delete(o.PersonTaskID)
        End Sub
        #End Region
        
        #Region "RemoveAllPersonTasks"
        Public Sub RemoveAllPersonTasks()
            m_PersonTaskProxy.ForEach(AddressOf RemovePersonTask)
        End Sub
        #End Region
        
        #Region "UpdatePersonTask"
        Public Sub UpdatePersonTask(ByVal o As Business.PersonTask)
            PersonTaskManager.Update(o)
        End Sub
        #End Region
        
        #Region "UpdateAllPersonTasks"
        Public Sub UpdateAllPersonTasks()
            m_PersonTaskProxy.ForEach(AddressOf UpdatePersonTask)
        End Sub
        #End Region
        
        #Region "RemoveTaskFile"
        Public Sub RemoveTaskFile(ByVal o As Business.TaskFile)
            TaskFileManager.Delete(o.TaskFileID)
        End Sub
        #End Region
        
        #Region "RemoveAllTaskFiles"
        Public Sub RemoveAllTaskFiles()
            m_TaskFileProxy.ForEach(AddressOf RemoveTaskFile)
        End Sub
        #End Region
        
        #Region "UpdateTaskFile"
        Public Sub UpdateTaskFile(ByVal o As Business.TaskFile)
            TaskFileManager.Update(o)
        End Sub
        #End Region
        
        #Region "UpdateAllTaskFiles"
        Public Sub UpdateAllTaskFiles()
            m_TaskFileProxy.ForEach(AddressOf UpdateTaskFile)
        End Sub
        #End Region
        
        #Region "LazyLoadCategory"
        Private Sub LazyLoadCategory()
            If (CategoryID > 0) Then
                m_Category = CategoryManager.GetByPrimaryKey(Me.CategoryID)
            End If
        End Sub
        #End Region
        
        #Region "LazyLoadPriority"
        Private Sub LazyLoadPriority()
            If (PriorityID > 0) Then
                m_Priority = PriorityManager.GetByPrimaryKey(Me.PriorityID)
            End If
        End Sub
        #End Region
        
        #Region "LazyLoadProject"
        Private Sub LazyLoadProject()
            If (ProjectID > 0) Then
                m_Project = ProjectManager.GetByPrimaryKey(Me.ProjectID)
            End If
        End Sub
        #End Region
        
        #Region "LazyLoadState"
        Private Sub LazyLoadState()
            If (StateID > 0) Then
                m_State = StateManager.GetByPrimaryKey(Me.StateID)
            End If
        End Sub
        #End Region
        
        #Region "LazyLoadUser"
        Private Sub LazyLoadUser()
            If (UserID > 0) Then
                m_User = UserManager.GetByPrimaryKey(Me.UserID)
            End If
        End Sub
        #End Region
        
        #Region "LazyLoadParent"
        Private Sub LazyLoadParent()
            If (ParentID > 0) Then
                m_Parent = TaskManager.GetByPrimaryKey(ParentID)
            End If
        End Sub
        #End Region
        
        #Region "ToString"
        Overrides Function ToString() As String
            Try 
                Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder
                sb.Append((("TaskID=" + TaskID.ToString)  _
                                + "::"))
                sb.Append((("CategoryID=" + CategoryID.ToString)  _
                                + "::"))
                sb.Append((("Comments=" + Comments.ToString)  _
                                + "::"))
                sb.Append((("DateCompleted=" + DateCompleted.ToString)  _
                                + "::"))
                sb.Append((("DateModified=" + DateModified.ToString)  _
                                + "::"))
                sb.Append((("Datestamp=" + Datestamp.ToString)  _
                                + "::"))
                sb.Append((("Description=" + Description.ToString)  _
                                + "::"))
                sb.Append((("DueDate=" + DueDate.ToString)  _
                                + "::"))
                sb.Append((("Duration=" + Duration.ToString)  _
                                + "::"))
                sb.Append((("EstimatedHours=" + EstimatedHours.ToString)  _
                                + "::"))
                sb.Append((("IsDeleted=" + IsDeleted.ToString)  _
                                + "::"))
                sb.Append((("Name=" + Name.ToString)  _
                                + "::"))
                sb.Append((("Number=" + Number.ToString)  _
                                + "::"))
                sb.Append((("ParentID=" + ParentID.ToString)  _
                                + "::"))
                sb.Append((("PriorityID=" + PriorityID.ToString)  _
                                + "::"))
                sb.Append((("Progress=" + Progress.ToString)  _
                                + "::"))
                sb.Append((("ProjectID=" + ProjectID.ToString)  _
                                + "::"))
                sb.Append((("Risk=" + Risk.ToString)  _
                                + "::"))
                sb.Append((("StartDate=" + StartDate.ToString)  _
                                + "::"))
                sb.Append((("StateID=" + StateID.ToString)  _
                                + "::"))
                sb.Append((("Summary=" + Summary.ToString)  _
                                + "::"))
                sb.Append((("UserID=" + UserID.ToString)  _
                                + "::"))
                Return sb.ToString
            Catch ex As System.Exception
                Return ""
            End Try
        End Function
        #End Region
    End Class
End Namespace

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, along with any associated source code and files, is licensed under The Common Public License Version 1.0 (CPL)


Written By
Founder Arkitech EBC Corporation
United States United States
MS, BBA, software developer, consultant, and trainer. Specializing in building data-centric applications designed for business, university, community & faith based organizations. Started developing Excel VBA macros and never looked back. Freelance developer utilizing VB.Net, SQL Server, Microsoft Access, and ASP.Net.

Comments and Discussions