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

<DefaultClassOptions()> _
<NonPersistent()> _
<NavigationItem(False)> _
<CreatableItem(False)> _
Public Class APCSheetByTerritorial_Change_PopUp
    Inherits BaseObject

    Private _APCSheetHeader As APCSheetHeader
    Private _City As String 'település
    Private _LotNumber As String 'Helyrajzi szám
    Private _BlockNumber As String 'Termőterülethez tartozó blokkszám
    Private _OwnerState As eOwnerState 'Bérlő vagy tulajdonos
    Private _DueDateRent As Date 'Bérlet lejárta dátuma

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
    End Sub

    <Browsable(False)> _
    Property APCSheetHeader As APCSheetHeader
        Get
            Return _APCSheetHeader
        End Get
        Set(value As APCSheetHeader)
            SetPropertyValue("APCSheetHeader", _APCSheetHeader, value)
        End Set
    End Property
    <Size(255)> _
    Property City As String
        Get
            Return _City
        End Get
        Set(value As String)
            SetPropertyValue("City", _City, value)
        End Set
    End Property
    <Size(255)> _
    Property LotNumber As String
        Get
            Return _LotNumber
        End Get
        Set(value As String)
            SetPropertyValue("LotNumber", _LotNumber, value)
        End Set
    End Property
    <Size(255)> _
    Property BlockNumber As String
        Get
            Return _BlockNumber
        End Get
        Set(value As String)
            SetPropertyValue("BlockNumber", _BlockNumber, value)
        End Set
    End Property
    Property OwnerState As eOwnerState
        Get
            Return _OwnerState
        End Get
        Set(value As eOwnerState)
            SetPropertyValue("OwnerState", _OwnerState, value)
        End Set
    End Property
    Property DueDateRent As Date
        Get
            Return _DueDateRent
        End Get
        Set(value As Date)
            SetPropertyValue("DueDateRent", _DueDateRent, value)
        End Set
    End Property
    <Browsable(False)> _
    ReadOnly Property TerritorialProducts As XPCollection(Of Products)
        Get
            Dim _ProductsCoollection As XPCollection(Of Products) = Nothing

            If APCSheetHeader IsNot Nothing Then
                If APCSheetHeader.APCSheetByProducts.Count > 0 Then
                    Dim _Filter As String = "Oid in("

                    For Each _APCSheetByProducts As APCSheetByProducts In APCSheetHeader.APCSheetByProducts
                        _Filter += "'" + _APCSheetByProducts.Products.Oid.ToString + "',"
                    Next
                    _Filter = _Filter.Remove(_Filter.Length - 1, 1)
                    _Filter += ")"
                    _ProductsCoollection = New XPCollection(Of Products)(Session, CriteriaOperator.Parse(_Filter))
                End If
            End If

            Return _ProductsCoollection
        End Get
    End Property
End Class
