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

Public Class clsDivisao


    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 _NOME_DIV As String
    Public Property NOME_DIV() As String
        Get
            Return _NOME_DIV
        End Get
        Set(ByVal value As String)
            _NOME_DIV = 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 SelectDivisaoByID(ByVal intCodigo As Integer) As String
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT * FROM TBL_DIVISAO"
        strsql = strsql & " WHERE CODIGO_DIV =" & intCodigo

        Dim dr As SqlDataReader = clsBanco.RetornaDataReader(strsql.ToString)
        strsql = ""

        If dr.Read() Then
            strsql = dr("NOME_DIV").ToString
        End If

        Return strsql



    End Function
    Public Function SelectdivisaoForGrid() As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT CODIGO_DIV, NOME_DIV FROM TBL_DIVISAO"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function


    Public Function SelectDIVISAOforTreeview() As SqlDataReader
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT * FROM TBL_DIVISAO"
        Return clsBanco.RetornaDataReader(strsql.ToString)

    End Function

    Public Function SelectDIVISAO() As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT * FROM TBL_DIVISAO"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function
    Public Function SelectDIVISAOForCombo() As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT CODIGO_DIV, NOME_DIV FROM TBL_DIVISAO ORDER BY NOME_DIV"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function

    Public Sub DeleteDIVISAO(ByVal IntCodigo As Integer)
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "DELETE FROM TBL_DIVISAO"
        strsql = strsql & " WHERE CODIGO_DIV  =  " & IntCodigo
        clsBanco.ExecutaComando(strsql.ToString)
    End Sub




    Public Sub UpdateDIVISAO(ByVal IntCodigo As Integer)
        Dim clsBanco As New clsBanco

        Dim strsql As String

        strsql = "UPDATE TBL_DIVISAO  SET "
        strsql = strsql & "NOME_DIV= '" & _NOME_DIV & "'"
        strsql = strsql & ",ATUALIZADO= " & 1
        strsql = strsql & ",DATAATUALIZACAO= '" & _DATAATUALIZACAO & "'"
        strsql = strsql & " WHERE CODIGO_DIV = " & IntCodigo

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub




    Public Sub InsertDIVISAO()
        Dim clsBanco As New clsBanco

        Dim strsql As String

        strsql = "INSERT INTO TBL_DIVISAO("
        strsql = strsql & "NOME_DIV"
        strsql = strsql & "ATUALIZADO"
        strsql = strsql & "DATAATUALIZACAO"
        strsql = strsql & ")VALUES("
        strsql = strsql & "'" & _NOME_DIV & "'"
        strsql = strsql & "," & 1
        strsql = strsql & ",'" & _DATAATUALIZACAO & "'"
        strsql = strsql & ")"

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub
End Class

