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.SystemModule
Imports DevExpress.Persistent.Base.Security

Imports DevExpress.ExpressApp.ConditionalAppearance
Imports DevExpress.ExpressApp.Filtering

'<EditorStateRuleAttribute("Show CurrencyRate when CurrencyName != HUF in FINAL", "CurrencyRate", EditorState.Hidden, "ContractRows.CurrencyName.ShortName = 'HUF'", ViewType.DetailView)> _
'<EditorStateRuleAttribute("Hide DateExecution when ContractRowsType != 1 in FINAL", "DateExecution", EditorState.Hidden, "ContractRows.ContractRowsType In(0,2)", ViewType.DetailView)> _
'<EditorStateRule("Hide DateCreated when ContractRowsType = 3 in FINAL", "DateCreated", EditorState.Hidden, "ContractRows.ContractRowsType = 3", ViewType.DetailView)> _

<Appearance("Show CurrencyRate when CurrencyName != HUF in FINAL", TargetItems:="CurrencyRate", Criteria:="ContractRows.CurrencyName.ShortName = 'HUF'", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<Appearance("Hide DateExecution when ContractRowsType != 1 in FINAL", TargetItems:="DateExecution", Criteria:="ContractRows.ContractRowsType In(0,2)", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<Appearance("Hide DateCreated when ContractRowsType = 3 in FINAL", TargetItems:="DateCreated", Criteria:="ContractRows.ContractRowsType = 3", Visibility:=Editors.ViewItemVisibility.Hide, Context:="DetailView")> _
<NavigationItem(False), CreatableItem(False)> _
Public Class ContractRowsToFinalInvoice
    Inherits BaseObject
    Private _DateCreated As Date = Now ' A számla kiállításának dátuma
    Private _DateExecution As Date 'Teljesítés dátuma
    Private _Description As String ' Megjegyzés
    Private _CurrencyRate As Double = 1 ' Árfolyam
    Private _ContractRows As ContractRows ' A Deviza típusához kell
    Private _BankInformation As BankInformation
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    ReadOnly Property DateCreated As Date
        Get
            Return _DateCreated
        End Get
    End Property
    <RuleRequiredField("ContractsRowsToFinalInvoice.DateExecution", DefaultContexts.Save, TargetCriteria:="ContractRows.ContractRowsType = 1")> _
    Property DateExecution As Date
        Get
            Return _DateExecution
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value)
        End Set
    End Property
    <Size(-1)> _
    Property Description As String
        Get
            Return _Description
        End Get
        Set(ByVal value As String)
            SetPropertyValue("Description", _Description, value)
        End Set
    End Property
    Property CurrencyRate As Double
        Get
            Return _CurrencyRate
        End Get
        Set(ByVal value As Double)
            SetPropertyValue("CurrencyRate", _CurrencyRate, value)
        End Set
    End Property
    Property ContractRows As ContractRows
        Get
            Return _ContractRows
        End Get
        Set(ByVal value As ContractRows)
            SetPropertyValue("ContractRows", _ContractRows, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("LiquidAssests.CustomerFrom = '@This.ContractRows.Contracts.CustomersFrom' AND LiquidAssests.LiquidAssetsType = 1")>
    Property BankInformation As BankInformation
        Get
            Return (_BankInformation)
        End Get
        Set(ByVal value As BankInformation)
            SetPropertyValue("CustomerBankAccounts", _BankInformation, value)
        End Set
    End Property
    <VisibleInListView(False)> _
    ReadOnly Property InvoiceRows As XPCollection(Of InvoiceRows)
        Get
            Dim _InvoiceRowsCollection As XPCollection(Of InvoiceRows) = New XPCollection(Of InvoiceRows) _
                (Session, CriteriaOperator.Parse("InvoiceHeader.Customers=? And InvoiceHeader.CustomersFrom=? And InvoiceHeader.InvoiceType.InvoiceTypeBase in (0,1) " & _
                                                 "And IsNull(InvoiceRowsAdvance)=True And InvoiceHeader.IsEditable=False And InvoiceHeader.IsStorno=False And InvoiceHeader.IsProforma=False AND ContractRows.Contracts=?", Me.ContractRows.Contracts.Customers, Me.ContractRows.Contracts.CustomersFrom, Me.ContractRows.Contracts))

            Return _InvoiceRowsCollection
        End Get
    End Property
End Class


