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)> _
<Appearance("Disable non editable properties",
                          AppearanceItemType:="ViewItem",
                          criteria:="1=1",
                          TargetItems:="BankSavedFileName;BankPrepareName;AmountHUF;AmountDEV",
                          Enabled:=False)> _
<Appearance("Disable actions if currentstep is not first",
                          AppearanceItemType:="Action",
                          Criteria:="RegistryHeader.CurrentWorkflowSystemSteps.StepIndex <> 1",
                          TargetItems:="New;Delete",
                          Enabled:=False, Context:="Any")> _
<Appearance("Disable all property when transfered",
                          AppearanceItemType:="ViewItem",
                          criteria:="BankSavedFileName != ''",
                          TargetItems:="*",
                          Enabled:=False, Context:="Any")> _
Public Class RegistryBankTransfer
    Inherits BaseObject
    Private _RegistryHeader As RegistryHeader 'Iktatás fejléce
    Private _AmountHUF As Double = 0 'Utalandó összeg HUF
    Private _AmountDEV As Double = 0 'Utalandó összeg DEV
    Private _DatePayment As Date 'Fizetési határidő
    Private _IsBlocked As Boolean = False 'Blokkolva
    Private _Note As String 'Utalásra kerülő megjegyzés
    Private _BankSavedFileName As String  'Milyen banki csomagba ment el?
    Private _BankPrepareName As String = "" 'Előkészítési megnevezés
    Private _RowType As eHoldRowType = eHoldRowType.Normal
    Private _BallanceDEV As Double 'Egyenleg (DEV)
    Private _BallanceHUF As Double 'Egyenleg (HUF)
    Private _Description_Private As String
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        If Session.IsNewObject(Me) Then
            BankSavedFileName = ""
            BankPrepareName = ""
        End If
    End Sub
    <Browsable(False)> _
    <Association("RegistryHeader-RegistryBankTransfer", GetType(RegistryHeader))> _
    Property RegistryHeader As RegistryHeader
        Get
            Return _RegistryHeader
        End Get
        Set(ByVal value As RegistryHeader)
            SetPropertyValue("RegistryHeader", _RegistryHeader, value)
            If Not Session.IsObjectsSaving And Not Session.IsObjectsLoading And Me.RegistryHeader IsNot Nothing Then
                AmountHUF = Me.RegistryHeader.BruttoAmountRemainingBank
            End If
        End Set
    End Property
    Property AmountHUF As Double
        Get
            Return _AmountHUF
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("AmountHUF", _AmountHUF, value)
        End Set
    End Property
    Property AmountDEV As Double
        Get
            Return _AmountDEV
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("AmountDEV", _AmountDEV, value)
            If Not Session.IsObjectsSaving And Not Session.IsObjectsLoading And Me.RegistryHeader IsNot Nothing Then
                If Not Me.RegistryHeader.F_CurrencyName.ShortName = "HUF" Then
                    Me.AmountHUF = Math.Round((value * Me.RegistryHeader.F_CurrencyRate), 0, MidpointRounding.AwayFromZero)
                End If
            End If
        End Set
    End Property
    <RuleRequiredField("RegistryBankTransfer.DatePayment", DefaultContexts.Save)> _
    Property DatePayment As Date
        Get
            Return _DatePayment
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DatePayment", _DatePayment, value)
        End Set
    End Property
    Property IsBlocked As Boolean
        Get
            Return _IsBlocked
        End Get
        Set(ByVal value As Boolean)
            SetPropertyValue("IsBlocked", _IsBlocked, value)
        End Set
    End Property
    Property Note As String
        Get
            Return _Note
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Note", _Note, value)
        End Set
    End Property
    Property BankSavedFileName As String
        Get
            Return _BankSavedFileName
        End Get
        Set(ByVal value As String)
            SetPropertyValue("BankSavedFileName", _BankSavedFileName, value)
        End Set
    End Property
    Property BankPrepareName As String
        Get
            Return _BankPrepareName
        End Get
        Set(value As String)
            SetPropertyValue("BankPrepareName", _BankPrepareName, value)
        End Set
    End Property
    Property RowType As eHoldRowType
        Get
            Return _RowType
        End Get
        Set(value As eHoldRowType)
            SetPropertyValue("RowType", _RowType, value)
        End Set
    End Property
    Property BallanceHUF As Double
        Get
            Return _BallanceHUF
        End Get
        Set(value As Double)
            SetPropertyValue("BallanceHUF", _BallanceHUF, value)
        End Set
    End Property
    Property BallanceDEV As Double
        Get
            Return _BallanceDEV
        End Get
        Set(value As Double)
            SetPropertyValue("BallanceDEV", _BallanceDEV, value)
        End Set
    End Property
    <Size(-1)> _
    Property Description_Private As String
        Get
            Return _Description_Private
        End Get
        Set(value As String)
            SetPropertyValue("Description_Private", _Description_Private, value)
        End Set
    End Property

End Class

