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 System.Drawing
Imports System.IO
Imports DevExpress.ExpressApp.Utils

<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
Public Class CRM_LeadsDocumentation
    Inherits FileAttachmentBase

    Private _CRM_Leads As CRM_Leads
    Private _Status As eProductsDocumentationStatus
    Private _RowGroup1 As String 'Szöveges csoportosítás (nem kötelező)
    Private _RowGroup2 As String 'Szöveges másodlagos csoportosítás (nem kötelező)
    Private _ShortName As String
    Private _Description As String
    Private _FileCreated As Date
    Private _FileModified As Date
    Private _ObjectCreated As Date
    Private _UserCreated As User

    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
    <Association("CRM_Leads-CRM_LeadsDocumentation", GetType(CRM_Leads))> _
    Property CRM_Leads As CRM_Leads
        Get
            Return _CRM_Leads
        End Get
        Set(value As CRM_Leads)
            SetPropertyValue("CRM_Leads", _CRM_Leads, value)
        End Set
    End Property
    Public Property Status() As eProductsDocumentationStatus
        Get
            Return _Status
        End Get
        Set(ByVal value As eProductsDocumentationStatus)
            SetPropertyValue("Status", _Status, value)
        End Set
    End Property
    Public Property RowGroup1() As String
        Get
            Return _RowGroup1
        End Get
        Set(ByVal value As String)
            SetPropertyValue("RowGroup1", _RowGroup1, value)
        End Set
    End Property
    Public Property RowGroup2() As String
        Get
            Return _RowGroup2
        End Get
        Set(ByVal value As String)
            SetPropertyValue("RowGroup2", _RowGroup2, value)
        End Set
    End Property
    Property ShortName As String
        Get
            Return _ShortName
        End Get
        Set(value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    Property Description As String
        Get
            Return _Description
        End Get
        Set(value As String)
            SetPropertyValue("Description", _Description, value)
        End Set
    End Property
    Property FileCreated As Date
        Get
            Return _FileCreated
        End Get
        Set(value As Date)
            SetPropertyValue("FileCreated", _FileCreated, value)
        End Set
    End Property
    Property FileModified As Date
        Get
            Return _FileModified
        End Get
        Set(value As Date)
            SetPropertyValue("FileModified", _FileModified, 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

    '--------ReadOnly---------
    <VisibleInDetailView(False)> _
    ReadOnly Property ImageType As Image
        Get
            Select Case Path.GetExtension(File.FileName)
                Case ".xls", ".xlsx"
                    Return ImageLoader.Instance.GetImageInfo("XLS").Image
                Case ".doc", ".docx"
                    Return ImageLoader.Instance.GetImageInfo("DOC").Image
                Case ".pdf"
                    Return ImageLoader.Instance.GetImageInfo("PDF").Image
                Case ".txt"
                    Return ImageLoader.Instance.GetImageInfo("NoImage").Image
                Case Else
                    Return ImageLoader.Instance.GetImageInfo("NoImage").Image
                    Return Nothing
            End Select
        End Get
    End Property
End Class
