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

Public Enum eOfferAskInState
    eNotSet = -1
    eInProgress = 0 'Folyamatban
    eWin = 1 'Megnyert
    eLost = 2 'Elvesztett
    eNextStep = 3 'Következő körös
    eWait = 4 'Visszajelzésre vár
    eWaitDecisions = 5
    eRejected = 6 'Lemondott, nem adunk ajánlatot
End Enum
<DefaultClassOptions()> _
<NavigationItem(False)> _
<CreatableItem(False)> _
<Appearance("OfferAskIn - Disable ObjectCreated", AppearanceItemType.ViewItem, "1=1", TargetItems:="ObjectCreated", Enabled:=False)> _
<Appearance("OfferAskIn - Disable UserCreated", AppearanceItemType.ViewItem, "1=1", TargetItems:="UserCreated", Enabled:=False)> _
Public Class OfferAskIn 'Bejövő ajánlatkérés
    Inherits BaseObject

    Private _RegistryHeader As RegistryHeader 'Iktatás
    Private _CustomersFrom As CustomersFrom 'Saját cég
    Private _Customers As Customers 'Partner
    Private _Contacts As Contacts 'Kapcsolat
    Private _JobNumberObjects As JobNumberObjects 'Project

    Private _DocumentNumber As String 'Dokumentum sorszáma
    Private _OfferAskInState As eOfferAskInState 'Státusz

    Private _DateExecution As Date 'Dátum
    Private _DateValid As Date 'Határidő

    Private _ObjectCreated As Date 'Létrehozva
    Private _UserCreated As User 'Létrehozta

    Private _HRPerson_Responsible As HRPerson

    Private _IsQualified As Boolean = False

    Private _CustomersName As String
    Private _ContactsName As String
    Private _ContactsPhone As String
    Private _ContactsEMail As String
    Private _JobNumberName As String 'Ha nincs minősítve, akkor a munka megnevezése

    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()
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))
        End If
    End Sub

    Property RegistryHeader As RegistryHeader
        Get
            Return _RegistryHeader
        End Get
        Set(value As RegistryHeader)
            SetPropertyValue("RegistryHeader", _RegistryHeader, value)
        End Set
    End Property
    Property CustomersFrom As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    Property Customers As Customers
        Get
            Return _Customers
        End Get
        Set(value As Customers)
            SetPropertyValue("Customers", _Customers, value)
        End Set
    End Property
    Property Contacts As Contacts
        Get
            Return _Contacts
        End Get
        Set(value As Contacts)
            SetPropertyValue("Contacts", _Contacts, value)
        End Set
    End Property
    Property JobNumberObjects As JobNumberObjects
        Get
            Return _JobNumberObjects
        End Get
        Set(value As JobNumberObjects)
            SetPropertyValue("JobNumberObjects", _JobNumberObjects, value)
        End Set
    End Property
    Property DocumentNumber As String
        Get
            Return _DocumentNumber
        End Get
        Set(value As String)
            SetPropertyValue("DocumentNumber", _DocumentNumber, value)
        End Set
    End Property
    Property OfferAskInState As eOfferAskInState
        Get
            Return _OfferAskInState
        End Get
        Set(value As eOfferAskInState)
            SetPropertyValue("OfferAskInState", _OfferAskInState, 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 DateValid As Date
        Get
            Return _DateValid
        End Get
        Set(value As Date)
            SetPropertyValue("DateValid", _DateValid, value)
        End Set
    End Property
    <NonCloneable> _
    Property ObjectCreated As Date
        Get
            Return _ObjectCreated
        End Get
        Set(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

    Property HRPerson_Responsible As HRPerson
        Get
            Return _HRPerson_Responsible
        End Get
        Set(value As HRPerson)
            SetPropertyValue("HRPerson_Responsible", _HRPerson_Responsible, value)
        End Set
    End Property
    Property IsQualified As Boolean
        Get
            Return _IsQualified
        End Get
        Set(value As Boolean)
            SetPropertyValue("IsQualified", _IsQualified, value)
        End Set
    End Property

    Property CustomersName As String
        Get
            Return _CustomersName
        End Get
        Set(value As String)
            SetPropertyValue("CustomersName", _CustomersName, value)
        End Set
    End Property
    Property ContactsName As String
        Get
            Return _ContactsName
        End Get
        Set(value As String)
            SetPropertyValue("ContactsName", _ContactsName, value)
        End Set
    End Property
    Property ContactsPhone As String
        Get
            Return _ContactsPhone
        End Get
        Set(value As String)
            SetPropertyValue("ContactsPhone", _ContactsPhone, value)
        End Set
    End Property
    Property ContactsEMail As String
        Get
            Return _ContactsEMail
        End Get
        Set(value As String)
            SetPropertyValue("ContactsEMail", _ContactsEMail, value)
        End Set
    End Property
    Property JobNumberName As String
        Get
            Return _JobNumberName
        End Get
        Set(value As String)
            SetPropertyValue("JobNumberName", _JobNumberName, value)
        End Set
    End Property
    '//XPCollection
    <Association("OfferAskIn-OfferAskInRows", GetType(OfferAskInRows)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property OfferAskInRows As XPCollection(Of OfferAskInRows)
        Get
            Return GetCollection(Of OfferAskInRows)("OfferAskInRows")
        End Get
    End Property
    <Association("OfferAskIn-OfferAskInDocuments", GetType(OfferAskInDocuments)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property OfferAskInDocuments As XPCollection(Of OfferAskInDocuments)
        Get
            Return GetCollection(Of OfferAskInDocuments)("OfferAskInDocuments")
        End Get
    End Property
End Class
