Imports System.Data.SqlClient
Imports System.Data

Public Class clsLogin



    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 _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 _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


    Public Function ValidaFuncionario(ByVal strUsuario As String, ByVal strPwd As String) As Integer

        Dim clsbanco As New clsBanco
        Dim dr As SqlDataReader
        Dim strsql As String

        strsql = "Select CODIGO_FUNC FROM TBL_FUNCIONARIO "
        strsql = strsql & " WHERE USER_FUNC = '" & strUsuario & "'"
        strsql = strsql & " AND PASSWORD_FUNC = '" & strPwd & "'"

        dr = clsbanco.RetornaDataReader(strsql.ToString)

        If dr.Read() Then
            Return CInt(dr(0))
        Else
            Return 0
        End If


    End Function
    Public Function UserRoleFuncionario(ByVal intCodigo As Integer) As SqlDataReader

        Dim clsbanco As New clsBanco
        Dim dr As SqlDataReader
        Dim strsql As String

        strsql = "Select C.NOME_CARGO, F.NOME_FUNC FROM TBL_CARGO AS C INNER JOIN TBL_FUNCIONARIO AS F "
        strsql = strsql & " ON C.CODIGO_CARGO = F.CODIGO_CARGO "
        strsql = strsql & " WHERE F.CODIGO_FUNC = " & intCodigo

        dr = clsbanco.RetornaDataReader(strsql.ToString)
        Return dr


    End Function


End Class
