Imports System
Imports System.ComponentModel

Imports DevExpress.Xpo
Imports DevExpress.Data.Filtering

Imports DevExpress.ExpressApp
Imports DevExpress.Persistent.Base
Imports DevExpress.Persistent.BaseImpl
Imports DevExpress.Persistent.Validation

Public Enum eHTMLMailTemplateState
    eInProgress = 0
    eReady = 1
    eDisposed = 2
End Enum
<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
Public Class HTMLMailTemplate
    Inherits BaseObject

    Private _HTMLMailTemplateState As eHTMLMailTemplateState
    Private _ShortName As String
    Private _HTMLBody As String
    Private _ObjectCreated As Date
    Private _UserCreated As User
    Private _ContactsProperties As String

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
        End If
    End Sub

    <RuleRequiredField("HTMLMailTemplate-HTMLMailTemplateState", DefaultContexts.Save)> _
    Property HTMLMailTemplateState As eHTMLMailTemplateState
        Get
            Return _HTMLMailTemplateState
        End Get
        Set(value As eHTMLMailTemplateState)
            SetPropertyValue("HTMLMailTemplateState", _HTMLMailTemplateState, value)
        End Set
    End Property
    <Size(255)> _
    <RuleRequiredField("HTMLMailTemplate-ShortName", DefaultContexts.Save)> _
    Property ShortName As String
        Get
            Return _ShortName
        End Get
        Set(value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    <Size(-1)> _
     <RuleRequiredField("HTMLMailTemplate-HTMLBody", DefaultContexts.Save)> _
    Property HTMLBody As String
        Get
            Return _HTMLBody
        End Get
        Set(value As String)
            SetPropertyValue("HTMLBody", _HTMLBody, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(value As Date)
            SetPropertyValue("ObjectCreated", _ObjectCreated, value)
        End Set
    End Property
    <NonCloneable> _
    Property UserCreated As User
        Get
            Return _UserCreated
        End Get
        Set(value As User)
            SetPropertyValue("UserCreated", _UserCreated, value)
        End Set
    End Property
    <VisibleInListView(False), VisibleInLookupListView(False)> _
    <NonPersistent()> _
    Property ContactsProperties As String
        Get
            Return _ContactsProperties
        End Get
        Set(value As String)
            SetPropertyValue("ContactsProperties", _ContactsProperties, value)
        End Set
    End Property
End Class
