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

'-- Termék, termék beszállítók
<DefaultClassOptions()> _
<NavigationItem("BusinessStocks")> _
<Appearance("Installation - ObjectCreated Disable all time", AppearanceItemType.ViewItem, "1=1", TargetItems:="ObjectCreated", Enabled:=False)> _
<Appearance("Installation - UserCreated Disable all time", AppearanceItemType.ViewItem, "1=1", TargetItems:="UserCreated", Enabled:=False)> _
Public Class Installation
    Inherits HCategory
    Private _DocumentNumber As String
    Private _InstallationType As InstallationType
    Private _Description As String 'Leírás
    Private _IsParent As Boolean = True 'Szülő-e ?
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _TakeoverProtocolRows As TakeoverProtocolRows

    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 String.IsNullOrEmpty(DocumentNumber) Then
            DocumentNumber = _InstallationType.NumberGenerator.GetNewNumber(_InstallationType.NumberGenerator)
        End If
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
        End If
    End Sub
    <NonCloneable()> _
    Property DocumentNumber As String
        Get
            Return _DocumentNumber
        End Get
        Set(value As String)
            SetPropertyValue("DocumentNumber", _DocumentNumber, value)
        End Set
    End Property
    Property Description() As String
        Get
            Return _Description
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Description", _Description, value)
        End Set
    End Property
    Property IsParent() As Boolean
        Get
            Return _IsParent
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("IsParent", _IsParent, value)
        End Set
    End Property
    Property InstallationType As InstallationType
        Get
            Return _InstallationType
        End Get
        Set(value As InstallationType)
            SetPropertyValue("InstallationType", _InstallationType, 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
    <Browsable(False)> _
    <VisibleInListView(False)> _
    <VisibleInDetailView(False)> _
    Property TakeoverProtocolRows As TakeoverProtocolRows
        Get
            Return _TakeoverProtocolRows
        End Get
        Set(value As TakeoverProtocolRows)
            SetPropertyValue("TakeoverProtocolRows", _TakeoverProtocolRows, value)
        End Set
    End Property

    '-------------ReadOnly-----------
    <VisibleInListView(False)> _
    <Aggregated(), Association("Installation-InstallationDocumentations", GetType(InstallationDocumentations))> _
    Public ReadOnly Property InstallationDocumentations() As XPCollection(Of InstallationDocumentations)
        Get
            Return GetCollection(Of InstallationDocumentations)("InstallationDocumentations")
        End Get
    End Property
    <VisibleInListView(False)> _
    <Association("Installation-InstallationProductsVariable", GetType(InstallationProductsVariable))> _
    ReadOnly Property InstallationProductsVariable As XPCollection(Of InstallationProductsVariable)
        Get
            Return GetCollection(Of InstallationProductsVariable)("InstallationProductsVariable")
        End Get
    End Property
End Class







