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.Utils

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

    Private _Products As Products

    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

    Property Products As Products
        Get
            Return _Products
        End Get
        Set(value As Products)
            SetPropertyValue("Products", _Products, value)
        End Set
    End Property

    <VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property ProductFinderInfo As XPCollection(Of ProductFinderInfo)
        Get
            Dim _ProductFinderInfo_Collection As New XPCollection(Of ProductFinderInfo)(Session, Session.ParseCriteria("1=2"))
            Dim _ProductFinderInfo As ProductFinderInfo
            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "ProductGroups")
            If _Products.ProductGroups IsNot Nothing Then
                _ProductFinderInfo.InfoString = _Products.ProductGroups.ShortName
            Else
                _ProductFinderInfo.InfoString = "Nincs beállítva!"
            End If
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)


            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "Description")
            _ProductFinderInfo.InfoString = _Products.Description
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "ProductNumber")
            _ProductFinderInfo.InfoString = _Products.ProductNumber
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "ShortName")
            _ProductFinderInfo.InfoString = _Products.ShortName
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "PacketUnitIn")
            _ProductFinderInfo.InfoString = _Products.PacketUnitIn.ToString
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "ProductStrategyCode")
            _ProductFinderInfo.InfoString = _Products.ProductStrategyCode
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "Units")
            If _Products.Units IsNot Nothing Then
                _ProductFinderInfo.InfoString = _Products.Units.ShortName
            Else
                _ProductFinderInfo.InfoString = "Nincs beállítva!"
            End If
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "CustomsTariff")
            If _Products.CustomsTariff IsNot Nothing Then
                _ProductFinderInfo.InfoString = _Products.CustomsTariff.CustomsTariffNumber
            Else
                _ProductFinderInfo.InfoString = "Nincs beállítva!"
            End If
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)


            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "GrossWeight")
            _ProductFinderInfo.InfoString = _Products.GrossWeight
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)


            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "ListPriceOutHUF")
            _ProductFinderInfo.InfoString = _Products.ListPriceOutHUF.ToString
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            _ProductFinderInfo = New ProductFinderInfo(Session)
            _ProductFinderInfo.PropertyName = CaptionHelper.GetMemberCaption(GetType(Products), "VAT")
            If _Products.VAT IsNot Nothing Then
                _ProductFinderInfo.InfoString = _Products.VAT.ShortName
            Else
                _ProductFinderInfo.InfoString = "Nincs beállítva!"
            End If
            _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            Dim _PricingActionRows As PricingActionRows = Session.FindObject(Of PricingActionRows) _
                                    (Session.ParseCriteria("Products=? and PricingActionHeader.IsActive=1 and PricingActionHeader.DateFrom<=Now() and PricingActionHeader.DateTo>=Now()", _Products))

            If _PricingActionRows IsNot Nothing Then

                _ProductFinderInfo = New ProductFinderInfo(Session)
                _ProductFinderInfo.PropertyName = "Akció!"
                _ProductFinderInfo.InfoString = Format(_PricingActionRows.ListPriceHUF, "#,##0") & Chr(13) & Chr(10) & _
                    _PricingActionRows.PricingActionHeader.ShortName & Chr(13) & Chr(10) & _PricingActionRows.PricingActionHeader.DateFrom.ToShortDateString & _
                    " - " & _PricingActionRows.PricingActionHeader.DateTo.ToShortDateString
                _ProductFinderInfo_Collection.Add(_ProductFinderInfo)

            End If

            Return _ProductFinderInfo_Collection
        End Get
    End Property
    <VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property StorageOutCirculation As XPCollection(Of StorageOutCirculation)
        Get
            Return New XPCollection(Of StorageOutCirculation)(Session, Session.ParseCriteria("Products=?", Products))
        End Get
    End Property
    <VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property StorageMoveEvents As XPCollection(Of StorageMoveEvents)
        Get
            Return New XPCollection(Of StorageMoveEvents)(Session, Session.ParseCriteria("StorageInRows.Products=?", Products))
        End Get
    End Property
End Class
