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

<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False), DefaultProperty("ShortName")> _
<FileAttachment("ExcelFile")> _
Public Class ImmovablesCostRecordExcel
    Inherits BaseObject
    Private _ShortName As String
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _ExcelProperty As String
    Private _ExcelFile As FileData
    Private _ImportExcelFile As FileData
    Private _DateExecution As Date
    Private _IsEditable As Boolean = True
    Private _IsStorno As Boolean = False

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        Dim _ImmovablesCostRecordMainGroup_Collection As New XPCollection(Of ImmovablesCostRecordMainGroup)(Session, CriteriaOperator.Parse("1=1"))

        For Each _ImmovablesCostRecordMainGroup As ImmovablesCostRecordMainGroup In _ImmovablesCostRecordMainGroup_Collection
            Dim _ImmovablesCostRecordExcelMainGroup As New ImmovablesCostRecordExcelMainGroup(Session)
            _ImmovablesCostRecordExcelMainGroup.ImmovablesCostRecordExcel = Me
            _ImmovablesCostRecordExcelMainGroup.IsUseInExcel = True
            _ImmovablesCostRecordExcelMainGroup.ImmovablesCostRecordMainGroup = _ImmovablesCostRecordMainGroup
        Next
        Me.DateExecution = GetSQLTime(Session)
    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("ImmovablesCostRecordExcel-ShortName", DefaultContexts.Save)> _
    Property ShortName As String
        Get
            Return _ShortName
        End Get
        Set(value As String)
            SetPropertyValue("ShortName", _ShortName, 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 ExcelProperty As String
        Get
            Return _ExcelProperty
        End Get
        Set(value As String)
            SetPropertyValue("ExcelProperty", _ExcelProperty, value)
        End Set
    End Property
    <Aggregated(), ExpandObjectMembers(ExpandObjectMembers.Never)> _
    Property ExcelFile As FileData
        Get
            Return _ExcelFile
        End Get
        Set(value As FileData)
            SetPropertyValue("ExcelFile", _ExcelFile, value)
        End Set
    End Property
    <Aggregated(), ExpandObjectMembers(ExpandObjectMembers.Never)> _
    Property ImportExcelFile As FileData
        Get
            Return _ImportExcelFile
        End Get
        Set(value As FileData)
            SetPropertyValue("ImportExcelFile", _ImportExcelFile, value)
        End Set
    End Property
    Property DateExecution As Date
        Get
            Return _DateExecution.Date
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value.Date)
        End Set
    End Property
    Property IsEditable As Boolean
        Get
            Return _IsEditable
        End Get
        Set(value As Boolean)
            SetPropertyValue("IsEditable", _IsEditable, value)
        End Set
    End Property
    Property IsStorno As Boolean
        Get
            Return _IsStorno
        End Get
        Set(value As Boolean)
            SetPropertyValue("IsStorno", _IsStorno, value)
        End Set
    End Property

    '-------------------------ReadOnly ----------------
    <Association("ImmovablesCostRecordMainGroup-ImmovablesCostRecordExcel", GetType(ImmovablesCostRecordExcelMainGroup)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property ImmovablesCostRecordExcelMainGroup As XPCollection(Of ImmovablesCostRecordExcelMainGroup)
        Get
            Return GetCollection(Of ImmovablesCostRecordExcelMainGroup)("ImmovablesCostRecordExcelMainGroup")
        End Get
    End Property
    <Association("ImmovablesCostRecordExcel-ImmovablesCostRecordExcelImmovables", GetType(ImmovablesCostRecordExcelImmovables)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property ImmovablesCostRecordExcelImmovables As XPCollection(Of ImmovablesCostRecordExcelImmovables)
        Get
            Return GetCollection(Of ImmovablesCostRecordExcelImmovables)("ImmovablesCostRecordExcelImmovables")
        End Get
    End Property
End Class
