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.Editors

Public Enum eABRQueryDateType
    eFromDateExecution = 0
    eFromDateRegistry = 1
End Enum
<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False)> _
<DeferredDeletion(False)> _
Public Class ABRQueryHeader 'Aging Balance Report (korosított követelésekről szóló kimutatás)
    Inherits BaseObject
    Private _DateClose As Date 'Záródátum
    Private _ShortName As String 'A lekérdezés megnevezése
    Private _PartnerType As ePartnerType
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _ABRQueryDateType As eABRQueryDateType = eABRQueryDateType.eFromDateExecution

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
        ' This constructor is used when an object is loaded from a persistent storage.
        ' Do not place any code here or place it only when the IsLoading property is false:
        ' if (!IsLoading){
        '   It is now OK to place your initialization code here.
        ' }
        ' or as an alternative, move your initialization code into the AfterConstruction method.
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        ' Place here your initialization code.
        Dim _ABRQueryCustomersFrom As ABRQueryCustomersFrom
        Dim _CustomersFrom_Collection As New XPCollection(Of CustomersFrom)(Session)
        Dim _CustomersFrom As CustomersFrom

        For Each _CustomersFrom In _CustomersFrom_Collection
            _ABRQueryCustomersFrom = New ABRQueryCustomersFrom(Session)
            _ABRQueryCustomersFrom.ABRQueryHeader = Me
            _ABRQueryCustomersFrom.CustomersFrom = _CustomersFrom
        Next
        DateClose = Now
    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 DateClose As Date
        Get
            Return _DateClose
        End Get
        Set(value As Date)
            SetPropertyValue("DateClose", _DateClose, 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 PartnerType As ePartnerType
        Get
            Return _PartnerType
        End Get
        Set(value As ePartnerType)
            SetPropertyValue("PartnerType", _PartnerType, 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
    Property ABRQueryDateType As eABRQueryDateType
        Get
            Return _ABRQueryDateType
        End Get
        Set(value As eABRQueryDateType)
            SetPropertyValue("ABRQueryDateType", _ABRQueryDateType, value)
        End Set
    End Property
    
    <Association("ABRQueryHeader-ABRQueryRows", GetType(ABRQueryRows)), VisibleInListView(False)> _
    ReadOnly Property ABRQueryRows As XPCollection(Of ABRQueryRows)
        Get
            Return GetCollection(Of ABRQueryRows)("ABRQueryRows")
        End Get
    End Property
    <Association("ABRQueryHeader-ABRQueryRowsDetail", GetType(ABRQueryRowsDetail)), VisibleInListView(False)> _
    ReadOnly Property ABRQueryRowsDetail As XPCollection(Of ABRQueryRowsDetail)
        Get
            Return GetCollection(Of ABRQueryRowsDetail)("ABRQueryRowsDetail")
        End Get
    End Property
    <Association("ABRQueryHeader-ABRQueryCustomersFrom", GetType(ABRQueryCustomersFrom)), VisibleInListView(False)> _
    ReadOnly Property ABRQueryCustomersFrom As XPCollection(Of ABRQueryCustomersFrom)
        Get
            Return GetCollection(Of ABRQueryCustomersFrom)("ABRQueryCustomersFrom")
        End Get
    End Property
End Class
