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
Imports DevExpress.ExpressApp.ConditionalAppearance

<DefaultClassOptions()> _
<NavigationItem(False)> _
<CreatableItem(False)> _
<Appearance("Reply - Disable ObjectCreated OrderOutHeader", AppearanceItemType.ViewItem, "1=1", TargetItems:="ObjectCreated", Enabled:=False)> _
<Appearance("Reply - Disable UserCreated OrderOutHeader", AppearanceItemType.ViewItem, "1=1", TargetItems:="UserCreated", Enabled:=False)> _
<Appearance("Reply - Disable Question when is not empty", TargetItems:="Question", Criteria:="IsNull(Question) = False", Enabled:=False, Context:="DetailView")> _
Public Class Reply
    Inherits BaseObject
    Private _Question As Question
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _Description As String
    Private _Attachment As FileData
    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
    Property Question As Question
        Get
            Return _Question
        End Get
        Set(value As Question)
            SetPropertyValue("Question", _Question, 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
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(value As Date)
            SetPropertyValue("ObjectCreated", _ObjectCreated, value)
        End Set
    End Property
    <Size(-1)> _
    Property Description As String
        Get
            Return _Description
        End Get
        Set(value As String)
            SetPropertyValue("Description", _Description, value)
        End Set
    End Property
    <VisibleInListView(False)> _
    Property Attachment As FileData
        Get
            Return _Attachment
        End Get
        Set(value As FileData)
            SetPropertyValue("Attachment", _Attachment, value)
        End Set
    End Property

    <VisibleInListView(False)> _
    <Size(-1)> _
    ReadOnly Property HTMLEvents As String
        Get
            Return CreateHTMLEvents(Me.Question, Session)
        End Get
    End Property

End Class
