Imports System.Collections.Generic
Imports System.Text
Imports System.Data.SqlClient
Imports System.Data

Public Class clsProjeto

    Private _CODIGO_PROJ As Long
    Public Property CODIGO_PROJ() As Long
        Get
            Return clsFuncoesGerais.GetCodigo()
        End Get
        Set(ByVal value As Long)
            _CODIGO_PROJ = value
        End Set
    End Property
    Private _CODIGO_EMP As Long
    Public Property CODIGO_EMP() As Long
        Get
            Return _CODIGO_EMP
        End Get
        Set(ByVal value As Long)
            _CODIGO_EMP = value
        End Set
    End Property
    Private _NOME_PROJ As String
    Public Property NOME_PROJ() As String
        Get
            Return _NOME_PROJ
        End Get
        Set(ByVal value As String)
            _NOME_PROJ = value
        End Set
    End Property
    Private _CODIGO_CLASS As Integer
    Public Property CODIGO_CLASS() As Integer
        Get
            Return _CODIGO_CLASS
        End Get
        Set(ByVal value As Integer)
            _CODIGO_CLASS = value
        End Set
    End Property
    Private _CODIGO_DIV As Integer
    Public Property CODIGO_DIV() As Integer
        Get
            Return _CODIGO_DIV
        End Get
        Set(ByVal value As Integer)
            _CODIGO_DIV = value
        End Set
    End Property
    Private _CODIGO_TIPO As Integer
    Public Property CODIGO_TIPO() As Integer
        Get
            Return _CODIGO_TIPO
        End Get
        Set(ByVal value As Integer)
            _CODIGO_TIPO = value
        End Set
    End Property

    Private _PREVISAOFECHAMENTO_PROJ As DateTime
    Public Property PREVISAOFECHAMENTO() As DateTime
        Get
            Return _PREVISAOFECHAMENTO_PROJ
        End Get
        Set(ByVal value As DateTime)
            _PREVISAOFECHAMENTO_PROJ = value
        End Set
    End Property



    Private _DATA_PROJ As DateTime
    Public Property DATA_PROJ() As DateTime
        Get
            Return _DATA_PROJ
        End Get
        Set(ByVal value As DateTime)
            _DATA_PROJ = value
        End Set
    End Property
    Private _ATIVO As Boolean
    Public Property ATIVO() As Boolean
        Get
            Return _ATIVO
        End Get
        Set(ByVal value As Boolean)
            _ATIVO = value
        End Set
    End Property
    Private _ATUALIZADO As Boolean
    Public Property ATUALIZADO() As Boolean
        Get
            Return _ATUALIZADO
        End Get
        Set(ByVal value As Boolean)
            _ATUALIZADO = value
        End Set
    End Property
    Private _DATAATUALIZACAO As DateTime
    Public Property DATAATUALIZACAO() As DateTime
        Get
            Return _DATAATUALIZACAO
        End Get
        Set(ByVal value As DateTime)
            _DATAATUALIZACAO = value
        End Set
    End Property
    Public Function SelectPROJETO() As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT * FROM TBL_PROJETO"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function
    Public Function SelectProjetoforTreeview(ByVal intCodigoEMP As Long, ByVal intCodigodIV As Integer) As SqlDataReader

        Dim clsBanco As New clsBanco
        Dim strsql As String

        strsql = ""
        strsql = strsql & "SELECT "
        strsql = strsql & "CODIGO_PROJ"
        strsql = strsql & ",NOME_PROJ "
        strsql = strsql & ",CODIGO_DIV"
        strsql = strsql & " FROM TBL_PROJETO "
        strsql = strsql & " WHERE  CODIGO_EMP = " & intCodigoEMP
        strsql = strsql & " AND  CODIGO_DIV = " & intCodigodIV
        Return clsBanco.RetornaDataReader(strsql.ToString)

    End Function
    Public Sub DeletePROJETO(ByVal IntCodigo As Long)
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "DELETE FROM TBL_PROJETO"
        strsql = strsql & " WHERE CODIGO_PROJ  =  " & IntCodigo
        clsBanco.ExecutaComando(strsql.ToString)
    End Sub




    Public Sub UpdatePROJETO(ByVal IntCodigo As Long)
        Dim clsBanco As New clsBanco

        Dim strsql As String

        strsql = "UPDATE TBL_PROJETO  SET "
        strsql = strsql & "CODIGO_EMP = " & _CODIGO_EMP
        strsql = strsql & ",NOME_PROJ= '" & _NOME_PROJ & "'"
        strsql = strsql & ",CODIGO_DIV = " & _CODIGO_DIV
        strsql = strsql & ",CODIGO_TIPO = " & _CODIGO_TIPO
        strsql = strsql & ",PREVISAOFECHAMENTO_PROJ = '" & _PREVISAOFECHAMENTO_PROJ & "'"
        strsql = strsql & ",DATA_PROJ= '" & _DATA_PROJ & "'"
        strsql = strsql & ",ATIVO= " & 1
        strsql = strsql & ",ATUALIZADO= " & 1
        strsql = strsql & ",DATAATUALIZACAO= '" & _DATAATUALIZACAO & "'"
        strsql = strsql & " WHERE CODIGO_PROJ = " & IntCodigo

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub
    Public Function InsertPROJETO() As Long

        Dim clsBanco As New clsBanco
        Dim strsql As String

        Dim strCodigo As String = CStr(clsFuncoesGerais.GetCodigo())

        strsql = "INSERT INTO TBL_PROJETO("
        strsql = strsql & "CODIGO_PROJ"
        strsql = strsql & ",CODIGO_EMP"
        strsql = strsql & ",NOME_PROJ"
        strsql = strsql & ",CODIGO_DIV"
        strsql = strsql & ",CODIGO_TIPO"
        strsql = strsql & ",PREVISAOFECHAMENTO_PROJ"
        strsql = strsql & ",DATA_PROJ"
        strsql = strsql & ",ATIVO"
        strsql = strsql & ",ATUALIZADO"
        strsql = strsql & ",DATAATUALIZACAO"
        strsql = strsql & ")VALUES("
        strsql = strsql & strCodigo
        strsql = strsql & "," & _CODIGO_EMP
        strsql = strsql & ",'" & _NOME_PROJ & "'"
        strsql = strsql & "," & _CODIGO_DIV
        strsql = strsql & "," & _CODIGO_TIPO
        strsql = strsql & ",'" & _PREVISAOFECHAMENTO_PROJ & "'"
        strsql = strsql & ",'" & _DATA_PROJ & "'"
        strsql = strsql & "," & 1
        strsql = strsql & "," & 1
        strsql = strsql & ",'" & _DATAATUALIZACAO & "'"
        strsql = strsql & ")"

        clsBanco.ExecutaComando(strsql.ToString)

        Return CLng(strCodigo)

    End Function
End Class

