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

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

    Private _RowIndex As Long
    Private _StorageOutHeader As StorageOutHeader ' -- Kitárolás fejléc
    Private _StorageComputed As StorageComputed ' -- Raktárkészlet
    Private _OrderInRows As OrderInRows '-- Bejövő megrendelés sora
    Private _QTT As Double ' -- Mennyiség
    Private _QTT_Will As Double ' -- Mennyiség (Szándék)
    Private _QTT_To_DeliveryOut As Double '-- Kiszállított mennyiség
    Private _Products As Products ' -- Termék
    Private _OnStorno As Boolean = False ' -- Stornírozás alatt van e?

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        QTT = 0
        QTT_Will = 0
        QTT_To_DeliveryOut = 0
        OnStorno = False
        RowIndex = -1
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        QTT = Math.Round(QTT, 4, MidpointRounding.AwayFromZero)
        QTT_To_DeliveryOut = Math.Round(QTT_To_DeliveryOut, 4, MidpointRounding.AwayFromZero)
        QTT_Will = Math.Round(QTT_Will, 4, MidpointRounding.AwayFromZero)
    End Sub

    Public Sub RemoveRows()
        For Each _StorageOutRows As StorageOutRows In Me.StorageOutHeader.StorageOutRows
            If _StorageOutRows.RowIndex > Me.RowIndex Then
                _StorageOutRows.RowIndex -= 1
            End If
        Next
    End Sub
    Property RowIndex As Long
        Get
            Return _RowIndex
        End Get
        Set(ByVal value As Long)
            SetPropertyValue("RowIndex", _RowIndex, value)
        End Set
    End Property
    <Association("StorageOut", GetType(StorageOutHeader))> _
    Property StorageOutHeader() As StorageOutHeader
        Get
            Return _StorageOutHeader
        End Get
        Set(ByVal value As StorageOutHeader)
            SetPropertyValue("StorageOutHeader", _StorageOutHeader, value)
        End Set
    End Property
    <DataSourceCriteria("Storage = '@This.StorageOutHeader.Storage'")> _
    Property StorageComputed() As StorageComputed
        Get
            Return _StorageComputed
        End Get
        Set(ByVal value As StorageComputed)
            SetPropertyValue("StorageComputed", _StorageComputed, value)
        End Set
    End Property
    Property OrderInRows() As OrderInRows
        Get
            Return _OrderInRows
        End Get
        Set(ByVal value As OrderInRows)
            SetPropertyValue("OrderInRows", _OrderInRows, value)
        End Set
    End Property
    <RuleRequiredField("", DefaultContexts.Save)> _
    Property QTT() As Double
        Get
            Return _QTT
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("QTT", _QTT, value)
        End Set
    End Property
    <RuleRequiredField("", DefaultContexts.Save)> _
    Property QTT_Will() As Double
        Get
            Return _QTT_Will
        End Get
        Set(ByVal value As Double)
            _QTT_Will = value
        End Set
    End Property
    Property QTT_To_DeliveryOut As Double
        Get
            Return _QTT_To_DeliveryOut
        End Get
        Set(value As Double)
            SetPropertyValue("QTT_To_DeliveryOut", _QTT_To_DeliveryOut, value)
        End Set
    End Property
    Property Products() As Products
        Get
            Return _Products
        End Get
        Set(ByVal value As Products)
            SetPropertyValue("Products", _Products, value)
        End Set
    End Property
    Property OnStorno() As Boolean
        Get
            Return _OnStorno
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("OnStorno", _OnStorno, value)
        End Set
    End Property
    <VisibleInListView(False)> _
    <Association("StorageOutIn", GetType(StorageOutRowsInRows))> _
    Public ReadOnly Property StorageOutRowsInRows() As XPCollection(Of StorageOutRowsInRows)
        Get
            Return GetCollection(Of StorageOutRowsInRows)("StorageOutRowsInRows")
        End Get
    End Property
End Class
