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

Public Class clsCotacao
    Private _CODIGO_COT As Integer
    Public Property CODIGO_COT() As Integer
        Get
            Return _CODIGO_COT
        End Get
        Set(ByVal value As Integer)
            _CODIGO_COT = value
        End Set
    End Property

    Private _CODIGO_PROJ As Long
    Public Property CODIGO_PROJ() As Long
        Get
            Return _CODIGO_PROJ
        End Get
        Set(ByVal value As Long)
            _CODIGO_PROJ = value
        End Set
    End Property

    Private _REFERENCIA_COT As String
    Public Property REFERENCIA_COT() As String
        Get
            Return _REFERENCIA_COT
        End Get
        Set(ByVal value As String)
            _REFERENCIA_COT = value
        End Set
    End Property

    Private _CODIGO_CONT As Integer
    Public Property CODIGO_CONT() As Integer
        Get
            Return _CODIGO_CONT
        End Get
        Set(ByVal value As Integer)
            _CODIGO_CONT = value
        End Set
    End Property

    Private _DATA_COT As DateTime
    Public Property DATA_COT() As DateTime
        Get
            Return _DATA_COT
        End Get
        Set(ByVal value As DateTime)
            _DATA_COT = value
        End Set
    End Property

    Private _VALOR_COT As Single
    Public Property VALOR_COT() As Single
        Get
            Return _VALOR_COT
        End Get
        Set(ByVal value As Single)
            _VALOR_COT = value
        End Set
    End Property

    Private _DESCONTO_COT As Single
    Public Property DESCONTO_COT() As Single
        Get
            Return _DESCONTO_COT
        End Get
        Set(ByVal value As Single)
            _DESCONTO_COT = value
        End Set
    End Property

    Private _VALORFINAL_COT As Single
    Public Property VALORFINAL_COT() As Single
        Get
            Return _VALORFINAL_COT
        End Get
        Set(ByVal value As Single)
            _VALORFINAL_COT = value
        End Set
    End Property

    Private _APROVADO_COT As Boolean
    Public Property APROVADO_COT() As Boolean
        Get
            Return _APROVADO_COT
        End Get
        Set(ByVal value As Boolean)
            _APROVADO_COT = 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 SelectCOTACAO() As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT * FROM TBL_COTACAO"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function

    Public Function SelectCotacaoForGrid(ByVal lngCodigo As Long) As DataSet
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "SELECT CODIGO_COT, REFERENCIA_COT, DATA_COT, VALOR_COT  FROM TBL_COTACAO WHERE CODIGO_PROJ = " & lngCodigo & " ORDER BY DATA_COT"
        Return clsBanco.RetornaDataSet(strsql.ToString)

    End Function

    Public Sub DeleteCOTACAO(ByVal IntCodigo As Integer)
        Dim clsBanco As New clsBanco
        Dim strsql As String
        strsql = "DELETE FROM TBL_COTACAO"
        strsql = strsql & " WHERE CODIGO_COT  =  " & IntCodigo
        clsBanco.ExecutaComando(strsql.ToString)
    End Sub

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

        Dim strsql As String

        strsql = "UPDATE TBL_COTACAO  SET "
        strsql = strsql & "CODIGO_PROJ = " & _CODIGO_PROJ
        strsql = strsql & ",REFERENCIA_COT= '" & _REFERENCIA_COT & "'"
        strsql = strsql & ",CODIGO_CONT = " & _CODIGO_CONT
        strsql = strsql & ",DATA_COT= '" & _DATA_COT & "'"
        strsql = strsql & ",APROVADO_COT= " & 1
        strsql = strsql & ",ATUALIZADO= " & 1
        strsql = strsql & ",DATAATUALIZACAO= '" & _DATAATUALIZACAO & "'"
        strsql = strsql & " WHERE CODIGO_COT = " & IntCodigo

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub

    Public Sub InsertCOTACAO()
        Dim clsBanco As New clsBanco

        Dim strsql As String

        strsql = "INSERT INTO TBL_COTACAO("
        strsql = strsql & "CODIGO_PROJ"
        strsql = strsql & ",REFERENCIA_COT"
        strsql = strsql & ",CODIGO_CONT"
        strsql = strsql & ",DATA_COT"
        strsql = strsql & ",VALOR_COT"
        strsql = strsql & ",DESCONTO_COT"
        strsql = strsql & ",VALORFINAL_COT"
        strsql = strsql & ",APROVADO_COT"
        strsql = strsql & ",ATUALIZADO"
        strsql = strsql & ",DATAATUALIZACAO"
        strsql = strsql & ")VALUES("
        strsql = strsql & _CODIGO_PROJ
        strsql = strsql & ",'" & _REFERENCIA_COT & "'"
        strsql = strsql & "," & _CODIGO_CONT
        strsql = strsql & ",'" & Format(_DATA_COT, "MM/dd/yyyy hh:mm:ss") & "'"
        strsql = strsql & "," & _VALOR_COT
        strsql = strsql & "," & _DESCONTO_COT
        strsql = strsql & "," & _VALORFINAL_COT

        If _APROVADO_COT = True Then
            strsql = strsql & "," & 1
        Else
            strsql = strsql & "," & 0
        End If
        strsql = strsql & "," & 1
        strsql = strsql & ",'" & Format(Date.Now, "MM/dd/yyyy hh:mm:ss") & "'"
        strsql = strsql & ")"

        clsBanco.ExecutaComando(strsql.ToString)
    End Sub

End Class

