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 RecipeFrom
    Inherits BaseObject
    Private _Recipe As Recipe 'Recept
    Private _RowGroup1 As String 'Szöveges csoportosítás (nem kötelező)
    Private _RowGroup2 As String 'Szöveges másodlagos csoportosítás (nem kötelező)
    Private _Products As Products 'Termék
    Private _Storage As Storage 'Raktár
    Private _QTT As Double 'Mennyiség
    Private _ListPriceHUF As Double
    Private _ListPriceDEV As Double

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

    <Association("Recipe-RecipeFrom", GetType(Recipe))> _
    Property Recipe As Recipe
        Get
            Return _Recipe
        End Get
        Set(value As Recipe)
            SetPropertyValue("Recipe", _Recipe, value)
        End Set
    End Property
    Property RowGroup1 As String
        Get
            Return _RowGroup1
        End Get
        Set(value As String)
            SetPropertyValue("RowGroup1", _RowGroup1, value)
        End Set
    End Property
    Property RowGroup2 As String
        Get
            Return _RowGroup2
        End Get
        Set(value As String)
            SetPropertyValue("RowGroup2", _RowGroup2, value)
        End Set
    End Property
    <ImmediatePostData(True)> _
    Property Products As Products
        Get
            Return _Products
        End Get
        Set(value As Products)
            SetPropertyValue("Products", _Products, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving Then
                If value IsNot Nothing Then
                    If Me.ListPriceHUF = 0 Then
                        Me.ListPriceHUF = value.ListPriceOutHUF
                    End If
                    If Me.ListPriceDEV = 0 Then
                        Me.ListPriceDEV = value.ListPriceOutDEV
                    End If
                End If
            End If
        End Set
    End Property
    Property Storage As Storage
        Get
            Return _Storage
        End Get
        Set(value As Storage)
            SetPropertyValue("Storage", _Storage, value)
        End Set
    End Property
    Property QTT As Double
        Get
            Return _QTT
        End Get
        Set(value As Double)
            SetPropertyValue("QTT", _QTT, value)
        End Set
    End Property
    <RuleRange(DefaultContexts.Save, 5, Double.MaxValue, TargetCriteria:="ListPriceDEV=0")> _
    Property ListPriceHUF As Double
        Get
            Return _ListPriceHUF
        End Get
        Set(value As Double)
            SetPropertyValue("ListPriceHUF", _ListPriceHUF, value)
        End Set
    End Property
    <RuleRange(DefaultContexts.Save, 0.0001, Double.MaxValue, TargetCriteria:="ListPriceHUF=0")> _
    Property ListPriceDEV As Double
        Get
            Return _ListPriceDEV
        End Get
        Set(value As Double)
            SetPropertyValue("ListPriceDEV", _ListPriceDEV, value)
        End Set
    End Property
End Class
