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

'-- Paraméterek, enumok
<DefaultClassOptions()>
<NavigationItem(False), CreatableItem(False)> _
Public Class CRMEstate_Leads_Activity
    Inherits MySchedule
    Private _CRMEstate_Leads As CRMEstate_Leads
    Private _HRPersonEvent As HRPersonEvent
    Public Sub New(ByVal session As Session)
        MyBase.New(session)      
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()

        'HRPersonEvents készítése is ! Meg értelemszerűen módosítása is !
        If Me.EventType = eEventType.eMeeting Then
            If HRPersonEvent Is Nothing Then
                _HRPersonEvent = New HRPersonEvent(Session)
                Dim _HRPerson As HRPerson = Session.FindObject(Of HRPerson)(CriteriaOperator.Parse("User.Oid=?", SecuritySystem.CurrentUser.oid))
                _HRPersonEvent.Resources.Add(_HRPerson)
            End If
            _HRPersonEvent.Subject = Me.Subject
            _HRPersonEvent.StartOn = Me.StartOn
            _HRPersonEvent.EndOn = Me.EndOn
            _HRPersonEvent.Status = Me.Status
            _HRPersonEvent.Type = Me.Type
            _HRPersonEvent.Save()
        End If
    End Sub
    Protected Overrides Sub OnDeleting()
        MyBase.OnDeleting()
        If Me.HRPersonEvent IsNot Nothing Then
            Session.Delete(Me.HRPersonEvent)
        End If
    End Sub
    <Association("CRMEstate_Leads-CRMEstate_Leads_Activity", GetType(CRMEstate_Leads))> _
    Property CRMEstate_Leads As CRMEstate_Leads
        Get
            Return _CRMEstate_Leads
        End Get
        Set(value As CRMEstate_Leads)
            SetPropertyValue("CRMEstate_Leads", _CRMEstate_Leads, value)
        End Set
    End Property
    <Browsable(False)> _
    Property HRPersonEvent As HRPersonEvent
        Get
            Return _HRPersonEvent
        End Get
        Set(value As HRPersonEvent)
            SetPropertyValue("HRPersonEvent", _HRPersonEvent, value)
        End Set
    End Property

    <VisibleInDetailView(False)> _
    ReadOnly Property ImageType As Image
        Get
            Select Case Me.EventType
                Case eEventType.eAlert
                    Return ImageLoader.Instance.GetImageInfo("bell").Image
                Case eEventType.eEMailIn
                    Return ImageLoader.Instance.GetImageInfo("mail_into").Image
                Case eEventType.eEmailOut
                    Return ImageLoader.Instance.GetImageInfo("mail_out").Image
                Case eEventType.eMeeting
                    Return ImageLoader.Instance.GetImageInfo("calendar").Image
                Case eEventType.ePhoneConversation
                    Return ImageLoader.Instance.GetImageInfo("mobilephone1").Image
                Case Else
                    Return Nothing
            End Select
        End Get
    End Property
End Class



