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.Persistent.Base.General
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Linq
Imports System.Linq.Expressions
Imports DevExpress.ExpressApp.ConditionalAppearance

<DefaultClassOptions()> _
<NavigationItem("FinancialTransactions")> _
<DeferredDeletion(False)> _
Public Class AssetsPCIHeader
    Inherits BaseObject
    Private _DateClose As Date 'Utolsó banki nap dátuma (csak az ezt megelőző tételek vagy u.a. dátumú tételek)
    Private _DateExecution As Date 'A fizetési felszólítás érvényességi dátuma
    Private _ShortName As String
    Private _QueryCustomersFrom As Boolean = False 'Lekérdezze e a saját céget is ?
    Private _ObjectCreated As Date 'Keletkezés dátuma
    Private _UserCreated As User 'Létrehozó felhasználó

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        Me.DateClose = Now
        Me.DateExecution = Now
 
        Dim _AssetsPCICustomersFrom As AssetsPCICustomersFrom
        Dim _CustomersFrom_Collection As New XPCollection(Of CustomersFrom)(Session)
        Dim _CustomersFrom As CustomersFrom

        For Each _CustomersFrom In _CustomersFrom_Collection
            _AssetsPCICustomersFrom = New AssetsPCICustomersFrom(Session)
            _AssetsPCICustomersFrom.AssetsPCIHeader = Me
            _AssetsPCICustomersFrom.CustomersFrom = _CustomersFrom
        Next
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            If Not SecuritySystem.CurrentUser Is Nothing Then
                _UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
            End If
        End If
    End Sub


    Property DateClose As Date
        Get
            Return _DateClose
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateClose", _DateClose, value)
        End Set
    End Property
    Property DateExecution As Date
        Get
            Return _DateExecution
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution", _DateExecution, 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 QueryCustomersFrom As Boolean
        Get
            Return _QueryCustomersFrom
        End Get
        Set(value As Boolean)
            SetPropertyValue("QueryCustomersFrom", _QueryCustomersFrom, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(ByVal 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

    <Association("AssetsPCIHeader-AssetsPCIRows", GetType(AssetsPCIRows)), VisibleInListView(False)> _
        ReadOnly Property AssetsPCIRows As XPCollection(Of AssetsPCIRows)
        Get
            Return GetCollection(Of AssetsPCIRows)("AssetsPCIRows")
        End Get
    End Property

    <VisibleInListView(False), VisibleInLookupListView(False)> _
    <Association("AssetsPCIHeader-AssetsPCICustomersFrom", GetType(AssetsPCICustomersFrom))> _
    ReadOnly Property AssetsPCICustomersFrom As XPCollection(Of AssetsPCICustomersFrom)
        Get
            Return GetCollection(Of AssetsPCICustomersFrom)("AssetsPCICustomersFrom")
        End Get
    End Property
End Class

