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

<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
Public Class PricingActionHeader
    Inherits BaseObject

    Private _CustomersFrom As Customers
    Private _ShortName As String
    Private _DateFrom As Date
    Private _DateTo As Date
    Private _DocumentNumber As String
    Private _CurrencyName As CurrencyName
    Private _Criterion As String
    Private _UserCreated As User
    Private _ObjectCreated As Date
    Private _IsActive As Boolean = False

    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))
        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 ShortName As String
        Get
            Return _ShortName
        End Get
        Set(value As String)
            SetPropertyValue("ShortName", _ShortName, value)
        End Set
    End Property
    Property DateFrom As Date
        Get
            Return _DateFrom
        End Get
        Set(value As Date)
            SetPropertyValue("DateFrom", _DateFrom, value)
        End Set
    End Property
    Property DateTo As Date
        Get
            Return _DateTo
        End Get
        Set(value As Date)
            SetPropertyValue("DateTo", _DateTo, 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 CurrencyName As CurrencyName
        Get
            Return _CurrencyName
        End Get
        Set(value As CurrencyName)
            SetPropertyValue("CurrencyName", _CurrencyName, value)
        End Set
    End Property
    Private ReadOnly Property ObjectType() As Type
        Get
            Return GetType(Products)
        End Get
    End Property
    <CriteriaOptions("ObjectType"), Size(-1), ImmediatePostData()> _
    Public Property Criterion() As String
        Get
            Return _Criterion
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Criterion", _Criterion, 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 IsActive As Boolean
        Get
            Return _IsActive
        End Get
        Set(value As Boolean)
            SetPropertyValue("IsActive", _IsActive, value)
        End Set
    End Property
    '//XPCollection
    <Association("PricingActionHeader-PricingActionRows", GetType(PricingActionRows)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property PricingActionRows As XPCollection(Of PricingActionRows)
        Get
            Return GetCollection(Of PricingActionRows)("PricingActionRows")
        End Get
    End Property
End Class
