'****************************************************************************************************************
'* Id Application modified by:   Date(MM/dd/yyyy)   Description													*
'* -- ------------------------   --------           -------------------------------------------	    			*
'* 01 Raśl Callupe - PACNET      22/10/2006         Creation of the class                                       *
'****************************************************************************************************************

Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.ApplicationBlocks.Data

Public Class CC_Reminder

    Sub New()

    End Sub

    Public Function GetReminders() As DataSet
        Dim strConnectionString As String = ConfigurationSettings.AppSettings("ConnectionString")
        Dim strSPName As String = "SP_CAMS_GET_REMINDERS"
        Dim dsResult As DataSet

        Try
            dsResult = SqlHelper.ExecuteDataset(strConnectionString, CommandType.StoredProcedure, strSPName)
        Catch ex As Exception
            dsResult = Nothing
        End Try

        Return dsResult
    End Function

    Public Function GetGrantTypes() As DataSet
        Dim oCC_GrantType As New CC_GrantType
        Dim dsResult As DataSet

        Try
            dsResult = oCC_GrantType.GetGrantTypes(0, 0)
        Catch ex As Exception
            dsResult = Nothing
        End Try

        Return dsResult
    End Function

    Public Function Update(ByVal prmRem As EC_Reminder, Optional ByRef strErrorMsg As String = "") As Boolean
        Dim strConnectionString As String = ConfigurationSettings.AppSettings("ConnectionString")
        Dim strSPName As String = "SP_CAMS_SET_UPDATE_REMINDER"
        Dim arrParams(2) As SqlParameter
        Dim bSuccess As Boolean = False

        With prmRem
            arrParams(0) = New SqlParameter("@REMINDERID", SqlDbType.Int)
            arrParams(0).Value = .ReminderID

            arrParams(1) = New SqlParameter("@THRESHOLD", SqlDbType.Int)
            If .Threshold.Trim.Equals(String.Empty) Then
                arrParams(1).Value = DBNull.Value
            Else
                arrParams(1).Value = .Threshold
            End If

            arrParams(2) = New SqlParameter("@TTTRBRT", SqlDbType.Int)
            If .TTTRBRT.Trim.Equals(String.Empty) Then
                arrParams(2).Value = DBNull.Value
            Else
                arrParams(2).Value = .TTTRBRT
            End If

        End With

        Try
            SqlHelper.ExecuteNonQuery(strConnectionString, CommandType.StoredProcedure, strSPName, arrParams)
            bSuccess = True
        Catch ex As Exception
            bSuccess = False
            strErrorMsg = ex.Message
        End Try

        Return bSuccess
    End Function

End Class

Public Class EC_Reminder
    Private _nReminderId As Integer
    Private _strName As String
    Private _strDescription As String
    Private _strDependsonGT As String
    Private _strThreshold As String
    Private _strTTTRBRT As String

    Public Property ReminderID() As Integer
        Get
            Return _nReminderId
        End Get
        Set(ByVal Value As Integer)
            _nReminderId = Value
        End Set
    End Property

    Public Property Name() As String
        Get
            Return _strName
        End Get
        Set(ByVal Value As String)
            _strName = Value
        End Set
    End Property

    Public Property Description() As String
        Get
            Return _strDescription
        End Get
        Set(ByVal Value As String)
            _strDescription = Value
        End Set
    End Property

    Public Property DependsonGT() As String
        Get
            Return _strDependsonGT
        End Get
        Set(ByVal Value As String)
            _strDependsonGT = Value
        End Set
    End Property

    Public Property Threshold() As String
        Get
            Return _strThreshold
        End Get
        Set(ByVal Value As String)
            _strThreshold = Value
        End Set
    End Property

    Public Property TTTRBRT() As String
        Get
            Return _strTTTRBRT
        End Get
        Set(ByVal Value As String)
            _strTTTRBRT = Value
        End Set
    End Property

End Class

