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("SQL Imports"), CreatableItem(False)> _
<Appearance("Disable UserCreated-C3CImportHeader", AppearanceItemType.ViewItem, "1=1", TargetItems:="UserCreated", Enabled:=False)> _
<Appearance("Disable ObjectCreated-C3CImportHeader", AppearanceItemType.ViewItem, "1=1", TargetItems:="ObjectCreated", Enabled:=False)> _
Public Class C3CImportHeader
    Inherits BaseObject
    Private _CustomersFrom As CustomersFrom 'Saját cég kötelező
    'Private _InvoiceType As InvoiceType 'Számla tipusa kötelező
    'Private _PaymentOption As PaymentOption 'Kötelező
    Private _ShortName As String
    Private _FileItems As FileData
    Private _FileInvoices As FileData
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _OutputDirectory As String

    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

    <RuleRequiredField()> _
    Public Property CustomersFrom As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(ByVal value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    '<RuleRequiredField()> _
    'Public Property InvoiceType As InvoiceType
    '    Get
    '        Return _InvoiceType
    '    End Get
    '    Set(ByVal value As InvoiceType)
    '        SetPropertyValue("InvoiceType", _InvoiceType, value)
    '    End Set
    'End Property
    '<RuleRequiredField()> _
    'Public Property PaymentOption As PaymentOption
    '    Get
    '        Return _PaymentOption
    '    End Get
    '    Set(ByVal value As PaymentOption)
    '        SetPropertyValue("PaymentOption", _PaymentOption, value)
    '    End Set
    'End Property
    <RuleRequiredField("C3CImportHeader-ShortName", DefaultContexts.Save)> _
    Public Property ShortName As String
        Get
            Return _ShortName
        End Get
        Set(ByVal value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    <NonCloneable()> _
    Public Property FileItems As FileData
        Get
            Return _FileItems
        End Get
        Set(ByVal value As FileData)
            SetPropertyValue("FileItems", _FileItems, value)
        End Set
    End Property
    <NonCloneable()> _
        Public Property FileInvoices As FileData
        Get
            Return _FileInvoices
        End Get
        Set(ByVal value As FileData)
            SetPropertyValue("FileInvoices", _FileInvoices, value)
        End Set
    End Property
    <NonCloneable()> _
        Public Property UserCreated As User
        Get
            Return _UserCreated
        End Get
        Set(ByVal value As User)
            SetPropertyValue("UserCreated", _UserCreated, value)
        End Set
    End Property
    <NonCloneable()> _
        Public Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("ObjectCreated", _ObjectCreated, value)
        End Set
    End Property
    <Size(4000)> _
    Public Property OutputDirectory As String
        Get
            Return _OutputDirectory
        End Get
        Set(value As String)
            SetPropertyValue("OutputDirectory", _OutputDirectory, value)
        End Set
    End Property

    <VisibleInListView(False)> _
    <Association("C3CImportHeader-C3CImportRows", GetType(C3CImportRows))> _
    <NonCloneable()> _
    ReadOnly Property C3CImportRows As XPCollection(Of C3CImportRows)
        Get
            Return GetCollection(Of C3CImportRows)("C3CImportRows")
        End Get
    End Property
    <VisibleInListView(False)> _
    <Association("C3CImportHeader-C3CGeneratedInvoice", GetType(C3CGeneratedInvoice))> _
    <NonCloneable()> _
    ReadOnly Property C3CGeneratedInvoice As XPCollection(Of C3CGeneratedInvoice)
        Get
            Return GetCollection(Of C3CGeneratedInvoice)("C3CGeneratedInvoice")
        End Get
    End Property
End Class
