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(), NavigationItem(False), CreatableItem(False)> _
Public Class DeliveryNoteInRRFC 'Szállítói számla igazolási sora és bejövő szállítólevél sora kapcsolat
    Inherits BaseObject

    Private _DeliveryNoteInRows As DeliveryNoteInRows 'Szállítólevél sor
    Private _RegistryRowsFinancialControlling As RegistryRowsFinancialControlling 'Számla igazolási sor
    Private _QTT_Controlled As Double 'Leigazolt mennyiség adott sorra vonatkozólag
    Private _BonusHUF As Double ' Bónusz erre a sorra vonatkozólag ! Ez csökkenti, vagy növeli a beszerzési értéket !
    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 OnSaved()
        MyBase.OnSaved()
        Dim _DeliveryNoteInRRFC_Collection As New XPCollection(Of DeliveryNoteInRRFC)(Session, CriteriaOperator.Parse("DeliveryNoteInRows=?", DeliveryNoteInRows))
        Dim _DeliveryNoteInRRFC As DeliveryNoteInRRFC
        Dim _QTT_Controlled As Double = 0
        For Each _DeliveryNoteInRRFC In _DeliveryNoteInRRFC_Collection
            _QTT_Controlled += _DeliveryNoteInRRFC._QTT_Controlled
        Next
        DeliveryNoteInRows.QTT_Controlled = _QTT_Controlled
        DeliveryNoteInRows.Save()
        DeliveryNoteInRows.DeliveryNoteInHeader.IsControlled = True
        For Each _DeliveryNoteInRows As DeliveryNoteInRows In DeliveryNoteInRows.DeliveryNoteInHeader.DeliveryNoteInrows
            If _DeliveryNoteInRows.QTT <> _DeliveryNoteInRows.QTT_Controlled Then
                DeliveryNoteInRows.DeliveryNoteInHeader.IsControlled = False
                Exit For
            End If
        Next
        DeliveryNoteInRows.DeliveryNoteInHeader.Save()
        Session.CommitTransaction()
    End Sub
   
    Property DeliveryNoteInRows As DeliveryNoteInRows
        Get
            Return _DeliveryNoteInRows
        End Get
        Set(value As DeliveryNoteInRows)
            SetPropertyValue("DeliveryNoteInRows", _DeliveryNoteInRows, value)
        End Set
    End Property
    Property RegistryRowsFinancialControlling As RegistryRowsFinancialControlling
        Get
            Return _RegistryRowsFinancialControlling
        End Get
        Set(value As RegistryRowsFinancialControlling)
            SetPropertyValue("RegistryRowsFinancialControlling", _RegistryRowsFinancialControlling, value)
        End Set
    End Property
    Property QTT_Controlled As Double
        Get
            Return _QTT_Controlled
        End Get
        Set(value As Double)
            SetPropertyValue("QTT_Controlled", _QTT_Controlled, value)
        End Set
    End Property
    Property BonusHUF As Double
        Get
            Return _BonusHUF
        End Get
        Set(value As Double)
            SetPropertyValue("BonusHUF", _BonusHUF, value)
        End Set
    End Property
End Class
