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
Public Enum eConversationType
    eNotset = -1
    ePhone = 0
    ePersonal = 1
    eMail = 2
End Enum
<DefaultClassOptions(), NavigationItem(False), CreatableItem(False)> _
Public Class AssetsHandlingCPBActivity
    Inherits BaseObject

    Private _Customers As Customers
    Private _NoteCustomers As String
    Private _NotePrivate As String
    Private _DateDeadline As Date 'Határidő
    Private _Amount As Double = 0 ' Összeget fizet határidőig 
    Private _AmountPercent As Double '%-ot fizet határidőig
    Private _ConversationType As eConversationType
    Private _ObjectCreated As Date 'Keletkezés dátuma
    Private _UserCreated As User 'Létrehozó felhasználó

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

        If Session.IsNewObject(Me) Then
            Me.ConversationType = eConversationType.eNotset
        End If
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If Session.IsNewObject(Me) Then
            Me.ObjectCreated = GetSQLTime(Session)
            If SecuritySystem.CurrentUser IsNot Nothing Then
                Me.UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
            End If
        End If
    End Sub

    <RuleRequiredField("AssetsHandlingCPBActivity-Customers", DefaultContexts.Save)> _
    Public Property Customers As Customers
        Get
            Return _Customers
        End Get
        Set(ByVal value As Customers)
            SetPropertyValue("Customers", _Customers, value)
        End Set
    End Property
    <RuleRequiredField("AssetsHandlingCPBActivity-NoteCustomers", DefaultContexts.Save), Size(-1)> _
    Public Property NoteCustomers As String
        Get
            Return _NoteCustomers
        End Get
        Set(value As String)
            SetPropertyValue("NoteCustomers", _NoteCustomers, value)
        End Set
    End Property
    <RuleRequiredField("AssetsHandlingCPBActivity-NotePrivate", DefaultContexts.Save), Size(-1)> _
    Public Property NotePrivate As String
        Get
            Return _NotePrivate
        End Get
        Set(value As String)
            SetPropertyValue("NotePrivate", _NotePrivate, value)
        End Set
    End Property
    Public Property DateDeadline As Date
        Get
            Return _DateDeadline
        End Get
        Set(value As Date)
            SetPropertyValue("DateDeadline", _DateDeadline, value)
        End Set
    End Property
    Public Property Amount As Double
        Get
            Return _Amount
        End Get
        Set(value As Double)
            SetPropertyValue("Amount", _Amount, value)
        End Set
    End Property
    Public Property AmountPercent As Double
        Get
            Return _AmountPercent
        End Get
        Set(value As Double)
            SetPropertyValue("AmountPercent", _AmountPercent, value)
        End Set
    End Property
    <RuleValueComparison("AssetsHandlingCPBActivity-ConversationType", DefaultContexts.Save, ValueComparisonType.NotEquals, eConversationType.eNotset)> _
    Public Property ConversationType As eConversationType
        Get
            Return _ConversationType
        End Get
        Set(value As eConversationType)
            SetPropertyValue("ConversationType", _ConversationType, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("ObjectCreated", _ObjectCreated, value)
        End Set
    End Property
    <NonCloneable> _
    Property UserCreated As User
        Get
            Return _UserCreated
        End Get
        Set(value As User)
            SetPropertyValue("UserCreated", _UserCreated, value)
        End Set
    End Property

End Class
