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
'-- Termék, termék beszállítók
<DefaultClassOptions()> _
<NavigationItem(False), CreatableItem(False), DefaultProperty("DisplayName")> _
Public Class CustomersOrderPriority 'Termék beszállítók !!! Egy termékhez lehet több is !!!
    Inherits BaseObject

    Private _CustomersOrder As CustomersOrder
    Private _RowIndex As Long ' Sorrend !!! Kitől rendelünk elsődlegesen.
    Private _Products As Products 'Termék
    Private _DeadlineDay As Long 'Mennyi idő mulva tudja szállítani (átlagosan) napban
    Private _DeadlineWeek As Long 'Mennyi idő mulva tudja szállítani (átlagosan) hétben, ez kerekített a napi értékből
    Private _MinOrderQTT As Double 'Minimális rendelési mennyiség !
    Private _MinOrderUnit As Units 'Ehhez tartozó rendelési mennyiség 

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

    Property CustomersOrder As CustomersOrder
        Get
            Return _CustomersOrder
        End Get
        Set(value As CustomersOrder)
            SetPropertyValue("CustomersOrder", _CustomersOrder, value)
        End Set
    End Property
    Property RowIndex As Long
        Get
            Return _RowIndex
        End Get
        Set(value As Long)
            SetPropertyValue("RowIndex", _RowIndex, value)
        End Set
    End Property
    <Association("Products-CustomersOrderPriority", GetType(Products))> _
    Property Products() As Products
        Get
            Return _Products
        End Get
        Set(ByVal value As Products)
            SetPropertyValue("Products", _Products, value)
        End Set
    End Property
    Property DeadlineDay As Long
        Get
            Return _DeadlineDay
        End Get
        Set(ByVal value As Long)
            SetPropertyValue("DeadlineDay", _DeadlineDay, value)
            If Not Session.IsObjectsLoading And Not Session.IsObjectsSaving Then
                If value Mod 7 = 0 Then
                    DeadlineWeek = CType(value / 7, Long)
                Else
                    DeadlineWeek = CType(value / 7, Long) + 1
                End If
            End If
        End Set
    End Property
    Property DeadlineWeek As Long
        Get
            Return _DeadlineWeek
        End Get
        Set(value As Long)
            SetPropertyValue("DeadlineWeek", _DeadlineWeek, value)
        End Set
    End Property
    Property MinOrderQTT As Double
        Get
            Return _MinOrderQTT

        End Get
        Set(ByVal value As Double)
            SetPropertyValue("MinOrderQTT", _MinOrderQTT, value)
        End Set
    End Property
    Property MinOrderUnit As Units
        Get
            Return _MinOrderUnit
        End Get
        Set(ByVal value As Units)
            SetPropertyValue("MinOrderUnit", _MinOrderUnit, value)
        End Set
    End Property

    ReadOnly Property DisplayName As String
        Get
            If CustomersOrder IsNot Nothing Then
                Return CustomersOrder.FullName
            Else
                Return ""
            End If
        End Get
    End Property
End Class







