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 System.Drawing
Imports DevExpress.ExpressApp.Utils

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

    Private _CustomersFrom As CustomersFrom
    Private _Products As Products
    Private _RowIndex As Long
    Private _DateExecution As Date
    Private _QTT_Before As Double
    Private _QTT_In As Double
    Private _QTT_Out As Double
    Private _QTT_After As Double
    Private _AveragePriceHUF_After As Double
    Private _SumAveragePriceHUF_After As Double
    Private _AveragePriceHUF_Before As Double
    Private _SumAveragePriceHUF_Before As Double

    Private _MainIndex As Long

    Private _DeliveryNoteInRRFC As DeliveryNoteInRRFC 'Leigazolt szállítólevél sor
    Private _InvoiceRows As InvoiceRows 'Vevői számla sor 
    Private _StorageInRows As StorageInRows 'Gyártásból bevétel sor
    Private _StorageOutRowsInRows As StorageOutRowsInRows 'Gyártásba kiadás sor

    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 CustomersFrom As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    Property Products As Products
        Get
            Return _Products
        End Get
        Set(value As Products)
            SetPropertyValue("Products", _Products, 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
    Property DateExecution As Date
        Get
            Return _DateExecution
        End Get
        Set(value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value)
        End Set
    End Property
    Property QTT_Before As Double
        Get
            Return Math.Round(_QTT_Before, 4, MidpointRounding.AwayFromZero)
        End Get
        Set(value As Double)
            SetPropertyValue("QTT_Before", _QTT_Before, Math.Round(value, 4, MidpointRounding.AwayFromZero))
        End Set
    End Property
    Property QTT_In As Double
        Get
            Return Math.Round(_QTT_In, 4, MidpointRounding.AwayFromZero)
        End Get
        Set(value As Double)
            SetPropertyValue("QTT_In", _QTT_In, Math.Round(value, 4, MidpointRounding.AwayFromZero))
        End Set
    End Property
    Property QTT_Out As Double
        Get
            Return Math.Round(_QTT_Out, 4, MidpointRounding.AwayFromZero)
        End Get
        Set(value As Double)
            SetPropertyValue("QTT_Out", _QTT_Out, Math.Round(value, 4, MidpointRounding.AwayFromZero))
        End Set
    End Property
    Property QTT_After As Double
        Get
            Return Math.Round(_QTT_After, 4, MidpointRounding.AwayFromZero)
        End Get
        Set(value As Double)
            SetPropertyValue("QTT_After", _QTT_After, Math.Round(value, 4, MidpointRounding.AwayFromZero))
        End Set
    End Property
    Property AveragePriceHUF_After As Double
        Get
            Return _AveragePriceHUF_After
        End Get
        Set(value As Double)
            SetPropertyValue("AveragePriceHUF_After", _AveragePriceHUF_After, value)
        End Set
    End Property
    Property SumAveragePriceHUF_After As Double
        Get
            Return _SumAveragePriceHUF_After
        End Get
        Set(value As Double)
            SetPropertyValue("SumAveragePriceHUF_After", _SumAveragePriceHUF_After, value)
        End Set
    End Property
    Property AveragePriceHUF_Before As Double
        Get
            Return _AveragePriceHUF_Before
        End Get
        Set(value As Double)
            SetPropertyValue("AveragePriceHUF_Before", _AveragePriceHUF_Before, value)
        End Set
    End Property
    Property SumAveragePriceHUF_Before As Double
        Get
            Return _SumAveragePriceHUF_Before
        End Get
        Set(value As Double)
            SetPropertyValue("SumAveragePriceHUF_Before", _SumAveragePriceHUF_Before, value)
        End Set
    End Property
    Property MainIndex As Long
        Get
            Return _MainIndex
        End Get
        Set(value As Long)
            SetPropertyValue("MainIndex", _MainIndex, value)
        End Set
    End Property
    Property DeliveryNoteInRRFC As DeliveryNoteInRRFC
        Get
            Return _DeliveryNoteInRRFC
        End Get
        Set(value As DeliveryNoteInRRFC)
            SetPropertyValue("DeliveryNoteInRRFC", _DeliveryNoteInRRFC, value)
        End Set
    End Property
    Property InvoiceRows As InvoiceRows
        Get
            Return _InvoiceRows
        End Get
        Set(value As InvoiceRows)
            SetPropertyValue("InvoiceRows", _InvoiceRows, value)
        End Set
    End Property
    Property StorageInRows As StorageInRows
        Get
            Return _StorageInRows
        End Get
        Set(value As StorageInRows)
            SetPropertyValue("StorageInRows", _StorageInRows, value)
        End Set
    End Property
    Property StorageOutRowsInRows As StorageOutRowsInRows
        Get
            Return _StorageOutRowsInRows
        End Get
        Set(value As StorageOutRowsInRows)
            SetPropertyValue("StorageOutRowsInRows", _StorageOutRowsInRows, value)
        End Set
    End Property
    <VisibleInDetailView(False)> _
    ReadOnly Property Image1 As Image
        Get
            Select Case RowIndex
                Case 0
                    If DeliveryNoteInRRFC IsNot Nothing Then
                        Return ImageLoader.Instance.GetImageInfo("arrow_down_blue").Image
                    ElseIf StorageInRows IsNot Nothing Then
                        Return ImageLoader.Instance.GetImageInfo("arrow_down_gear_blue").Image
                    End If
                Case 1
                    If InvoiceRows IsNot Nothing Then
                        Return ImageLoader.Instance.GetImageInfo("arrow_up_green").Image
                    ElseIf StorageOutRowsInRows IsNot Nothing Then
                        Return ImageLoader.Instance.GetImageInfo("arrow_up_gear_green").Image
                    End If
                Case Else
                    Return Nothing
            End Select
        End Get
    End Property
End Class
