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

Public Class clsFuncionario

    Private _CODIGO_FUNC As Integer
    Public Property CODIGO_FUNC() As Integer
        Get
            Return _CODIGO_FUNC
        End Get
        Set(ByVal value As Integer)
            _CODIGO_FUNC = value
        End Set
    End Property



    Private _CODIGO_CARGO As Integer
    Public Property CODIGO_CARGO() As Integer
        Get
            Return _CODIGO_CARGO
        End Get
        Set(ByVal value As Integer)
            _CODIGO_CARGO = value
        End Set
    End Property



    Private _NOME_FUNC As String
    Public Property NOME_FUNC() As String
        Get
            Return _NOME_FUNC
        End Get
        Set(ByVal value As String)
            _NOME_FUNC = value
        End Set
    End Property



    Private _ENDERECO_FUNC As String
    Public Property ENDERECO_FUNC() As String
        Get
            Return _ENDERECO_FUNC
        End Get
        Set(ByVal value As String)
            _ENDERECO_FUNC = value
        End Set
    End Property



    Private _NUMERO_FUNC As String
    Public Property NUMERO_FUNC() As String
        Get
            Return _NUMERO_FUNC
        End Get
        Set(ByVal value As String)
            _NUMERO_FUNC = value
        End Set
    End Property



    Private _COMPLEMENTO_FUNC As String
    Public Property COMPLEMENTO_FUNC() As String
        Get
            Return _COMPLEMENTO_FUNC
        End Get
        Set(ByVal value As String)
            _COMPLEMENTO_FUNC = value
        End Set
    End Property



    Private _BAIRRO_FUNC As String
    Public Property BAIRRO_FUNC() As String
        Get
            Return _BAIRRO_FUNC
        End Get
        Set(ByVal value As String)
            _BAIRRO_FUNC = value
        End Set
    End Property



    Private _CEP_FUNC As String
    Public Property CEP_FUNC() As String
        Get
            Return _CEP_FUNC
        End Get
        Set(ByVal value As String)
            _CEP_FUNC = value
        End Set
    End Property



    Private _CIDADE_FUNC As String
    Public Property CIDADE_FUNC() As String
        Get
            Return _CIDADE_FUNC
        End Get
        Set(ByVal value As String)
            _CIDADE_FUNC = value
        End Set
    End Property



    Private _ESTADO_FUNC As String
    Public Property ESTADO_FUNC() As String
        Get
            Return _ESTADO_FUNC
        End Get
        Set(ByVal value As String)
            _ESTADO_FUNC = value
        End Set
    End Property



    Private _TELEFONE_FUNC As String
    Public Property TELEFONE_FUNC() As String
        Get
            Return _TELEFONE_FUNC
        End Get
        Set(ByVal value As String)
            _TELEFONE_FUNC = value
        End Set
    End Property



    Private _TELEFAX_FUNC As String
    Public Property TELEFAX_FUNC() As String
        Get
            Return _TELEFAX_FUNC
        End Get
        Set(ByVal value As String)
            _TELEFAX_FUNC = value
        End Set
    End Property



    Private _CELULAR_FUNC As String
    Public Property CELULAR_FUNC() As String
        Get
            Return _CELULAR_FUNC
        End Get
        Set(ByVal value As String)
            _CELULAR_FUNC = value
        End Set
    End Property



    Private _EMAIL_FUNC As String
    Public Property EMAIL_FUNC() As String
        Get
            Return _EMAIL_FUNC
        End Get
        Set(ByVal value As String)
            _EMAIL_FUNC = value
        End Set
    End Property



    Private _RG_FUNC As String
    Public Property RG_FUNC() As String
        Get
            Return _RG_FUNC
        End Get
        Set(ByVal value As String)
            _RG_FUNC = value
        End Set
    End Property



    Private _CPF_FUNC As String
    Public Property CPF_FUNC() As String
        Get
            Return _CPF_FUNC
        End Get
        Set(ByVal value As String)
            _CPF_FUNC = value
        End Set
    End Property



    Private _DOC1_FUNC As String
    Public Property DOC1_FUNC() As String
        Get
            Return _DOC1_FUNC
        End Get
        Set(ByVal value As String)
            _DOC1_FUNC = value
        End Set
    End Property



    Private _DOC2_FUNC As String
    Public Property DOC2_FUNC() As String
        Get
            Return _DOC2_FUNC
        End Get
        Set(ByVal value As String)
            _DOC2_FUNC = value
        End Set
    End Property


    Private _USER_FUNC As String
    Public Property USER_FUNC() As String
        Get
            Return _USER_FUNC
        End Get
        Set(ByVal value As String)
            _USER_FUNC = value
        End Set
    End Property


    Private _PASSWORD_FUNC As String
    Public Property PASSWORD_FUNC() As String
        Get
            Return _PASSWORD_FUNC
        End Get
        Set(ByVal value As String)
            _PASSWORD_FUNC = 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 SelectFUNCIONARIO() As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT * FROM TBL_FUNCIONARIO"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function
    Public Function SelectFuncionariobyCode(ByVal intCodigo As Long) As SqlDataReader

        Dim clsbanco As New clsBanco
        Dim strsql As String

        strsql = "SELECT * FROM TBL_FUNCIONARIO "
        strsql = strsql & " WHERE CODIGO_FUNC = " & intCodigo

        Return clsbanco.RetornaDataReader(strsql.ToString)

    End Function
    Public Function SelectFUNCIONARIOFORgrid(ByVal strName As String) As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT F.CODIGO_FUNC,C.NOME_CARGO, F.NOME_FUNC, F.CIDADE_FUNC, F.ESTADO_FUNC"
        strsql = strsql & " FROM TBL_CARGO AS C INNER JOIN TBL_FUNCIONARIO AS F ON C.CODIGO_CARGO = F.CODIGO_CARGO"

        If Not String.IsNullOrEmpty(strName) Then
            strsql = strsql & " WHERE F.NOME_FUNC LIKE '" & strName & "%' AND "
        Else
            strsql = strsql & " WHERE "
        End If

        strsql = strsql & " C.CODIGO_CARGO <> 1"

        Return clsBanco.RetornaDataSet(strsql.ToString)
    End Function
    Public Sub DeleteFUNCIONARIO(ByVal IntCodigo As Integer)
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "DELETE FROM TBL_FUNCIONARIO"
        strsql = "WHERE CODIGO_FUNC  =  " & IntCodigo
        clsBanco.ExecutaComando(strsql.ToString)
    End Sub
    Public Sub UpdateFUNCIONARIO(ByVal IntCodigo As Integer)
        Dim clsBanco As New clsBanco

        Dim strsql As String

        strsql = "UPDATE TBL_FUNCIONARIO  SET "
        strsql = strsql & "CODIGO_CARGO = " & _CODIGO_CARGO
        strsql = strsql & ",NOME_FUNC= '" & _NOME_FUNC & "'"
        strsql = strsql & ",ENDERECO_FUNC= '" & _ENDERECO_FUNC & "'"
        strsql = strsql & ",NUMERO_FUNC= '" & _NUMERO_FUNC & "'"
        strsql = strsql & ",COMPLEMENTO_FUNC= '" & _COMPLEMENTO_FUNC & "'"
        strsql = strsql & ",BAIRRO_FUNC= '" & _BAIRRO_FUNC & "'"
        strsql = strsql & ",CEP_FUNC= '" & _CEP_FUNC & "'"
        strsql = strsql & ",CIDADE_FUNC= '" & _CIDADE_FUNC & "'"
        strsql = strsql & ",ESTADO_FUNC= '" & _ESTADO_FUNC & "'"
        strsql = strsql & ",TELEFONE_FUNC= '" & _TELEFONE_FUNC & "'"
        strsql = strsql & ",TELEFAX_FUNC= '" & _TELEFAX_FUNC & "'"
        strsql = strsql & ",CELULAR_FUNC= '" & _CELULAR_FUNC & "'"
        strsql = strsql & ",EMAIL_FUNC= '" & _EMAIL_FUNC & "'"
        strsql = strsql & ",RG_FUNC= '" & _RG_FUNC & "'"
        strsql = strsql & ",CPF_FUNC= '" & _CPF_FUNC & "'"
        strsql = strsql & ",DOC1_FUNC= '" & _DOC1_FUNC & "'"
        strsql = strsql & ",DOC2_FUNC= '" & _DOC2_FUNC & "'"
        strsql = strsql & ",ATUALIZADO= " & 1
        strsql = strsql & ",DATAATUALIZACAO= '" & _DATAATUALIZACAO & "'"
        strsql = strsql & " WHERE CODIGO_FUNC = " & IntCodigo

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub
    Public Sub InsertFUNCIONARIO()
        Dim clsBanco As New clsBanco
        Dim strsql As String

        strsql = "INSERT INTO TBL_FUNCIONARIO("
        strsql = strsql & "CODIGO_CARGO"
        strsql = strsql & ",NOME_FUNC"
        strsql = strsql & ",ENDERECO_FUNC"
        strsql = strsql & ",NUMERO_FUNC"
        strsql = strsql & ",COMPLEMENTO_FUNC"
        strsql = strsql & ",BAIRRO_FUNC"
        strsql = strsql & ",CEP_FUNC"
        strsql = strsql & ",CIDADE_FUNC"
        strsql = strsql & ",ESTADO_FUNC"
        strsql = strsql & ",TELEFONE_FUNC"
        strsql = strsql & ",TELEFAX_FUNC"
        strsql = strsql & ",CELULAR_FUNC"
        strsql = strsql & ",EMAIL_FUNC"
        strsql = strsql & ",RG_FUNC"
        strsql = strsql & ",CPF_FUNC"
        strsql = strsql & ",DOC1_FUNC"
        strsql = strsql & ",DOC2_FUNC"
        strsql = strsql & ",USER_FUNC"
        strsql = strsql & ",PASSWORD_FUNC"
        strsql = strsql & ",ATUALIZADO"
        strsql = strsql & ",DATAATUALIZACAO"
        strsql = strsql & ")VALUES("
        strsql = strsql & _CODIGO_CARGO
        strsql = strsql & ",'" & _NOME_FUNC & "'"
        strsql = strsql & ",'" & _ENDERECO_FUNC & "'"
        strsql = strsql & ",'" & _NUMERO_FUNC & "'"
        strsql = strsql & ",'" & _COMPLEMENTO_FUNC & "'"
        strsql = strsql & ",'" & _BAIRRO_FUNC & "'"
        strsql = strsql & ",'" & _CEP_FUNC & "'"
        strsql = strsql & ",'" & _CIDADE_FUNC & "'"
        strsql = strsql & ",'" & _ESTADO_FUNC & "'"
        strsql = strsql & ",'" & _TELEFONE_FUNC & "'"
        strsql = strsql & ",'" & _TELEFAX_FUNC & "'"
        strsql = strsql & ",'" & _CELULAR_FUNC & "'"
        strsql = strsql & ",'" & _EMAIL_FUNC & "'"
        strsql = strsql & ",'" & _RG_FUNC & "'"
        strsql = strsql & ",'" & _CPF_FUNC & "'"
        strsql = strsql & ",'" & _DOC1_FUNC & "'"
        strsql = strsql & ",'" & _DOC2_FUNC & "'"
        strsql = strsql & ",'" & _USER_FUNC & "'"
        strsql = strsql & ",'" & _PASSWORD_FUNC & "'"
        strsql = strsql & "," & 1
        strsql = strsql & ",'" & _DATAATUALIZACAO & "'"
        strsql = strsql & ")"

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

