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

Public Enum eFixedAssetsUsingMoveType
    eIn = 0
    eOut = 1
End Enum
Public Enum eFixedAssetsUsingType
    eCustomers = 0
    eHRPerson = 1
    eCostHolder = 2
End Enum
<DefaultClassOptions()> _
<NavigationItem(False)> _
<CreatableItem(False)> _
Public Class FixedAssetsUsingHeader
    Inherits BaseObject
    Private _CustomersFrom As CustomersFrom
    Private _FixedAssetsUsingParameters As FixedAssetsUsingParameters
    Private _FixedAssetsUsingType As eFixedAssetsUsingType
    Private _HRPerson As HRPerson
    Private _Customers As Customers
    Private _CostHolder As CostHolder
    Private _CostPlace As CostPlace
    Private _DocumentNumber As String
    Private _DateExecution As Date
    Private _FixedAssetsUsingMoveType As eFixedAssetsUsingMoveType
    Private _ObjectCreated As Date
    Private _UserCreated As User

    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.
    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))
            DocumentNumber = Me.FixedAssetsUsingParameters.NumberGenerator.GetNewNumber(Me.FixedAssetsUsingParameters.NumberGenerator, Year(DateExecution).ToString)
        End If
    End Sub

    Property CustomersFrom As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    Property FixedAssetsUsingParameters As FixedAssetsUsingParameters
        Get
            Return _FixedAssetsUsingParameters
        End Get
        Set(value As FixedAssetsUsingParameters)
            SetPropertyValue("FixedAssetsUsingParameters", _FixedAssetsUsingParameters, value)
        End Set
    End Property
    Property FixedAssetsUsingType As eFixedAssetsUsingType
        Get
            Return _FixedAssetsUsingType
        End Get
        Set(value As eFixedAssetsUsingType)
            SetPropertyValue("FixedAssetsUsingType", _FixedAssetsUsingType, value)
        End Set
    End Property
    Property HRperson As HRPerson
        Get
            Return _HRperson
        End Get
        Set(value As HRPerson)
            SetPropertyValue("HRperson", _HRperson, value)
        End Set
    End Property
    Property Customers As Customers
        Get
            Return _Customers
        End Get
        Set(value As Customers)
            SetPropertyValue("Customers", _Customers, value)
        End Set
    End Property
    Property CostHolder As CostHolder
        Get
            Return _CostHolder
        End Get
        Set(value As CostHolder)
            SetPropertyValue("CostHolder", _CostHolder, value)
        End Set
    End Property
    Property CostPalce As CostPlace
        Get
            Return _CostPlace
        End Get
        Set(value As CostPlace)
            SetPropertyValue("CostPalce", _CostPlace, value)
        End Set
    End Property
    Property DocumentNumber As String
        Get
            Return _DocumentNumber
        End Get
        Set(value As String)
            SetPropertyValue("DocumentNumber", _DocumentNumber, 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 FixedAssetsUsingMoveType As eFixedAssetsUsingMoveType
        Get
            Return _FixedAssetsUsingMoveType
        End Get
        Set(value As eFixedAssetsUsingMoveType)
            SetPropertyValue("FixedAssetsUsingMoveType", _FixedAssetsUsingMoveType, 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
    <NonCloneable> _
    Property UserCreated As User
        Get
            Return _UserCreated
        End Get
        Set(value As User)
            SetPropertyValue("UserCreated", _UserCreated, value)
        End Set
    End Property

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