Click here to Skip to main content
15,885,801 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 84K   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.Business
Imports TeamVision.Common
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Text

'*************************************************************
' Class Name:  TeamManager
' Purpose:  Data Access Object (DAO)
' Description: Sends and receives data from the database
'***************************************************************
Namespace Managers
    
    Public NotInheritable Class TeamManager
        
        Private Sub New()
            MyBase.New
        End Sub
        
        #Region "GetByPrimaryKey"
        <DataObjectMethod(DataObjectMethodType.[Select], false)>  _
        Public Shared Function GetByPrimaryKey(ByVal TeamID As Integer) As Team
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [Teams] WHERE ")
            sql.Append((" [TeamID]=" + TeamID.ToString))
            Dim dt As System.Data.DataTable = DataHandler.GetDataTable(sql.ToString)
            Dim row As System.Data.DataRow = Nothing
            row = dt.Rows(0)
            Dim biz As Team = New Team
            biz.TeamID = Utility.NullToZero(row("TeamID"))
            biz.Description = Utility.NullToString(row("Description"))
            biz.Name = Utility.NullToString(row("Name"))
            Return biz
        End Function
        #End Region
        
        #Region "GetTeamsWhere"
        <DataObjectMethod(DataObjectMethodType.[Select], false)>  _
        Public Shared Function GetTeamsWhere(ByVal WhereSQL As String) As System.Collections.Generic.List(Of Team)
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [Teams] WHERE ")
            sql.Append(WhereSQL)
            Dim dt As System.Data.DataTable = DataHandler.GetDataTable(sql.ToString)
            Dim row As System.Data.DataRow = Nothing
            Dim i As Integer
            Dim recordList As System.Collections.Generic.List(Of Team) = New System.Collections.Generic.List(Of Team)
            i = 0
            Do While (i  _
                        <= (dt.Rows.Count - 1))
                row = dt.Rows(i)
                Dim biz As Team = New Team
                biz.TeamID = Utility.NullToZero(row("TeamID"))
                biz.Description = Utility.NullToString(row("Description"))
                biz.Name = Utility.NullToString(row("Name"))
                recordList.Add(biz)
                i = (i + 1)
            Loop
            Return recordList
        End Function
        #End Region
        
        #Region "GetTeamTableWhere"
        <DataObjectMethod(DataObjectMethodType.[Select], false)>  _
        Public Shared Function GetTeamTableWhere(ByVal WhereSQL As String) As Schema.TeamTable
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [Teams] WHERE ")
            sql.Append(WhereSQL)
            Dim dt As System.Data.DataTable = DataHandler.GetDataTable(sql.ToString)
            Dim row As System.Data.DataRow = Nothing
            Dim i As Integer
            Dim table As Schema.TeamTable = New Schema.TeamTable
            Dim dr As Schema.TeamRow = Nothing
            i = 0
            Do While (i  _
                        <= (dt.Rows.Count - 1))
                row = dt.Rows(i)
                dr = table.NewTeamRow
                dr.TeamID = Utility.NullToZero(row("TeamID"))
                dr.Description = Utility.NullToString(row("Description"))
                dr.Name = Utility.NullToString(row("Name"))
                table.AddTeamRow(dr)
                i = (i + 1)
            Loop
            Return table
        End Function
        #End Region
        
        #Region "GetAllTeams"
        <DataObjectMethod(DataObjectMethodType.[Select], true)>  _
        Public Shared Function GetAllTeams() As System.Collections.Generic.List(Of Team)
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [Teams]")
            Dim dt As System.Data.DataTable = DataHandler.GetDataTable(sql.ToString)
            Dim row As System.Data.DataRow = Nothing
            Dim i As Integer
            Dim recordList As System.Collections.Generic.List(Of Team) = New System.Collections.Generic.List(Of Team)
            i = 0
            Do While (i  _
                        <= (dt.Rows.Count - 1))
                row = dt.Rows(i)
                Dim biz As Team = New Team
                biz.TeamID = Utility.NullToZero(row("TeamID"))
                biz.Description = Utility.NullToString(row("Description"))
                biz.Name = Utility.NullToString(row("Name"))
                recordList.Add(biz)
                i = (i + 1)
            Loop
            Return recordList
        End Function
        #End Region
        
        #Region "Insert"
        <DataObjectMethod(DataObjectMethodType.Insert, true)>  _
        Public Shared Function Insert(ByVal biz As Models.Team) As Integer
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("INSERT INTO [Teams] ( ")
            sql.Append("[Description], ")
            sql.Append("[Name] ")
            sql.Append(") VALUES ( ")
            sql.Append((("'" + biz.Description.ToString)  _
                            + "'"))
            sql.Append(", ")
            sql.Append((("'" + biz.Name.ToString)  _
                            + "'"))
            sql.Append(")")
            Dim ScalarID As Integer = DataHandler.Insert(sql.ToString, true)
            Return ScalarID
        End Function
        #End Region
        
        #Region "Update"
        <DataObjectMethod(DataObjectMethodType.Update, true)>  _
        Public Shared Sub Update(ByVal biz As Models.Team)
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("UPDATE [Teams] ")
            sql.Append(" SET ")
            sql.Append(((" [Description]='" + biz.Description.ToString)  _
                            + "', "))
            sql.Append(((" [Name]='" + biz.Name.ToString)  _
                            + "' "))
            sql.Append((" WHERE [TeamID]=" + biz.TeamID.ToString))
            DataHandler.Update(sql.ToString)
        End Sub
        #End Region
        
        #Region "Delete"
        <DataObjectMethod(DataObjectMethodType.Delete, true)>  _
        Public Shared Sub Delete(ByVal TeamID As Integer)
            Try 
                Dim sql As StringBuilder = New StringBuilder
                sql.Append("DELETE * FROM [Teams] WHERE ")
                sql.Append((" [TeamID]=" + TeamID.ToString))
                DataHandler.GetDataTable(sql.ToString)
            Catch ex As System.Exception
            End Try
        End Sub
        #End Region
        
        #Region "DeleteWhere"
        <DataObjectMethod(DataObjectMethodType.Delete, false)>  _
        Public Shared Sub DeleteWhere(ByVal WhereSQL As String)
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("DELETE * FROM [Teams] WHERE ")
            sql.Append(WhereSQL)
            DataHandler.GetDataTable(sql.ToString)
        End Sub
        #End Region
        
        #Region "GetPersonTeams"
        <DataObjectMethod(DataObjectMethodType.[Select], false)>  _
        Public Shared Function GetPersonTeams(ByVal biz As Team) As System.Collections.Generic.List(Of PersonTeam)
            'TODO: Define more complex and custom query SQL here. 
            '  ex.: SELECT DISTINCT, RIGHT JOIN, LEFT JOIN, etc...
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [PersonTeams] ")
            sql.Append(" WHERE ")
            sql.Append((" [PersonTeams].[TeamID]=" + biz.TeamID.ToString))
            Dim dt As DataTable = DataHandler.GetDataTable(sql.ToString)
            Dim i As Integer
            Dim recordList As System.Collections.Generic.List(Of PersonTeam) = New System.Collections.Generic.List(Of PersonTeam)
            i = 0
            Do While (i  _
                        <= (dt.Rows.Count - 1))
                Dim row As Datarow = dt.Rows(i)
                Dim PersonTeamID As Integer = Utility.NullToZero(row("PersonTeamID"))
                Dim Name As String = Utility.NullToString(row("Name"))
                Dim PersonID As Integer = Utility.NullToZero(row("PersonID"))
                Dim TeamID As Integer = Utility.NullToZero(row("TeamID"))
                recordList.Add(New PersonTeam(PersonTeamID,Name,PersonID,TeamID))
                i = (i + 1)
            Loop
            Return recordList
        End Function
        #End Region
        
        #Region "GetProjects"
        <DataObjectMethod(DataObjectMethodType.[Select], false)>  _
        Public Shared Function GetProjects(ByVal biz As Team) As System.Collections.Generic.List(Of Project)
            'TODO: Define more complex and custom query SQL here. 
            '  ex.: SELECT DISTINCT, RIGHT JOIN, LEFT JOIN, etc...
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [Projects] ")
            sql.Append(" WHERE ")
            sql.Append((" [Projects].[TeamID]=" + biz.TeamID.ToString))
            Dim dt As DataTable = DataHandler.GetDataTable(sql.ToString)
            Dim i As Integer
            Dim recordList As System.Collections.Generic.List(Of Project) = New System.Collections.Generic.List(Of Project)
            i = 0
            Do While (i  _
                        <= (dt.Rows.Count - 1))
                Dim row As Datarow = dt.Rows(i)
                Dim ProjectID As Integer = Utility.NullToZero(row("ProjectID"))
                Dim DateCreated As Date = Utility.NullToDate(row("DateCreated"))
                Dim Datestamp As Date = Utility.NullToDate(row("Datestamp"))
                Dim Description As String = Utility.NullToString(row("Description"))
                Dim DisplayID As Integer = Utility.NullToZero(row("DisplayID"))
                Dim FileUrl As String = Utility.NullToString(row("FileUrl"))
                Dim IsArchived As Boolean = Utility.NullToBool(row("IsArchived"))
                Dim IsDeleted As Boolean = Utility.NullToBool(row("IsDeleted"))
                Dim LastModified As Date = Utility.NullToDate(row("LastModified"))
                Dim Name As String = Utility.NullToString(row("Name"))
                Dim TeamID As Integer = Utility.NullToZero(row("TeamID"))
                recordList.Add(New Project(ProjectID,DateCreated,Datestamp,Description,DisplayID,FileUrl,IsArchived,IsDeleted,LastModified,Name,TeamID))
                i = (i + 1)
            Loop
            Return recordList
        End Function
        #End Region
        
        #Region "Count"
        Public Shared Function Count() As Integer
            Dim sql As StringBuilder = New StringBuilder
            sql.Append("SELECT * FROM [Teams]")
            Dim dt As System.Data.DataTable = DataHandler.GetDataTable(sql.ToString)
            Return dt.Rows.Count
        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