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

Public Class clsContato

    Private _CODIGO_CONT As Long
    Public Property CODIGO_CONT() As Long
        Get
            Return _CODIGO_CONT
        End Get
        Set(ByVal value As Long)
            _CODIGO_CONT = 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_CONT As String
    Public Property NOME_CONT() As String
        Get
            Return _NOME_CONT
        End Get
        Set(ByVal value As String)
            _NOME_CONT = value
        End Set
    End Property

    Private _DEPARTAMENTO_CONT As String
    Public Property DEPARTAMENTO_CONT() As String
        Get
            Return _DEPARTAMENTO_CONT
        End Get
        Set(ByVal value As String)
            _DEPARTAMENTO_CONT = value
        End Set
    End Property

    Private _CARGO_CONT As String
    Public Property CARGO_CONT() As String
        Get
            Return _CARGO_CONT
        End Get
        Set(ByVal value As String)
            _CARGO_CONT = value
        End Set
    End Property

    Private _TELEFONE_CONT As String
    Public Property TELEFONE_CONT() As String
        Get
            Return _TELEFONE_CONT
        End Get
        Set(ByVal value As String)
            _TELEFONE_CONT = value
        End Set
    End Property

    Private _CELULAR_CONT As String
    Public Property CELULAR_CONT() As String
        Get
            Return _CELULAR_CONT
        End Get
        Set(ByVal value As String)
            _CELULAR_CONT = value
        End Set
    End Property

    Private _TELEFAX_CONT As String
    Public Property TELEFAX_CONT() As String
        Get
            Return _TELEFAX_CONT
        End Get
        Set(ByVal value As String)
            _TELEFAX_CONT = value
        End Set
    End Property

    Private _EMAIL_CONT As String
    Public Property EMAIL_CONT() As String
        Get
            Return _EMAIL_CONT
        End Get
        Set(ByVal value As String)
            _EMAIL_CONT = 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 SelectContatoForGrid(ByVal lngCodigo As Long) As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT CODIGO_CONT, NOME_CONT,DEPARTAMENTO_CONT,CARGO_CONT,TELEFONE_CONT,EMAIL_CONT FROM TBL_CONTATO "
        strsql = strsql & " WHERE CODIGO_EMP = " & lngCodigo
        Return clsBanco.RetornaDataSet(strsql.ToString)
    End Function

    Public Function SelectContatoForCombo(ByVal lngCodigo As Long) As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT CODIGO_CONT, NOME_CONT FROM TBL_CONTATO"
        strsql = strsql & " WHERE CODIGO_EMP = " & lngCodigo & " ORDER BY NOME_CONT"

        Return clsBanco.RetornaDataSet(strsql.ToString)
    End Function



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

    End Function

    Public Sub DeleteCONTATO(ByVal IntCodigo As Long)
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "DELETE FROM TBL_CONTATO"
        strsql = strsql & " WHERE CODIGO_CONT  =  " & IntCodigo
        clsBanco.ExecutaComando(strsql.ToString)
    End Sub


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

        Dim strsql As String

        strsql = "UPDATE TBL_CONTATO  SET "
        strsql = strsql & "CODIGO_EMP = " & _CODIGO_EMP
        strsql = strsql & ",NOME_CONT= '" & _NOME_CONT & "'"
        strsql = strsql & ",DEPARTAMENTO_CONT= '" & _DEPARTAMENTO_CONT & "'"
        strsql = strsql & ",CARGO_CONT= '" & _CARGO_CONT & "'"
        strsql = strsql & ",TELEFONE_CONT= '" & _TELEFONE_CONT & "'"
        strsql = strsql & ",CELULAR_CONT= '" & _CELULAR_CONT & "'"
        strsql = strsql & ",TELEFAX_CONT= '" & _TELEFAX_CONT & "'"
        strsql = strsql & ",EMAIL_CONT= '" & _EMAIL_CONT & "'"
        strsql = strsql & ",ATIVO= " & 1
        strsql = strsql & ",ATUALIZADO= " & 1
        strsql = strsql & ",DATAATUALIZACAO= '" & _DATAATUALIZACAO & "'"
        strsql = strsql & " WHERE CODIGO_CONT = " & IntCodigo

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub

    Public Sub InsertCONTATO()
        Dim clsBanco As New clsBanco

        Dim strsql As String

        strsql = "INSERT INTO TBL_CONTATO("
        strsql = strsql & "CODIGO_CONT"
        strsql = strsql & ",CODIGO_EMP"
        strsql = strsql & ",NOME_CONT"
        strsql = strsql & ",DEPARTAMENTO_CONT"
        strsql = strsql & ",CARGO_CONT"
        strsql = strsql & ",TELEFONE_CONT"
        strsql = strsql & ",CELULAR_CONT"
        strsql = strsql & ",TELEFAX_CONT"
        strsql = strsql & ",EMAIL_CONT"
        strsql = strsql & ",ATIVO"
        strsql = strsql & ",ATUALIZADO"
        strsql = strsql & ",DATAATUALIZACAO"
        strsql = strsql & ")VALUES("
        strsql = strsql & _CODIGO_CONT
        strsql = strsql & "," & _CODIGO_EMP
        strsql = strsql & ",'" & _NOME_CONT & "'"
        strsql = strsql & ",'" & _DEPARTAMENTO_CONT & "'"
        strsql = strsql & ",'" & _CARGO_CONT & "'"
        strsql = strsql & ",'" & _TELEFONE_CONT & "'"
        strsql = strsql & ",'" & _CELULAR_CONT & "'"
        strsql = strsql & ",'" & _TELEFAX_CONT & "'"
        strsql = strsql & ",'" & _EMAIL_CONT & "'"
        strsql = strsql & "," & 1
        strsql = strsql & "," & 1
        strsql = strsql & ",'" & _DATAATUALIZACAO & "'"
        strsql = strsql & ")"
        clsBanco.ExecutaComando(strsql.ToString)
    End Sub
End Class

