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.Net.Mail

Public Enum eInvoiceState
    eNoState = 0
    eInvoiceReadyState = 1 'Számlázható
    eNOInvoiceState = 2 ' NEM számlázható
End Enum
<DefaultClassOptions()> _
<NavigationItem("BusinessTransactions")> _
<Appearance("Disable WorkSheet_Header-ObjectCreated", AppearanceItemType.ViewItem, "1=1", TargetItems:="ObjectCreated", Enabled:=False)> _
<Appearance("Disable WorkSheet_Header-UserCreated", AppearanceItemType.ViewItem, "1=1", TargetItems:="UserCreated", Enabled:=False)> _
<Appearance("Disable WorkSheet_Header-DocumentNumber", AppearanceItemType.ViewItem, "1=1", TargetItems:="DocumentNumber", Enabled:=False)> _
<Appearance("Disable WorkSheet_Header-WorkSheetState", AppearanceItemType.ViewItem, "1=1", TargetItems:="WorkSheetState", Enabled:=False)> _
<Appearance("Disable WorkSheet_Header-CustomersFrom, when is not nothing", AppearanceItemType.ViewItem, "IsNull(CustomersFrom)=False", TargetItems:="CustomersFrom", Enabled:=False)> _
<Appearance("Disable WorkSheet_Header-Customers, when is not nothing", AppearanceItemType.ViewItem, "IsNull(Customers)=False", TargetItems:="Customers", Enabled:=False)> _
<Appearance("Disable WorkSheet_Header-WorkSheetType, when is not nothing", AppearanceItemType.ViewItem, "IsNull(WorkSheetType)=False", TargetItems:="WorkSheetType", Enabled:=False)> _
<Appearance("Hide ExcelTab WorkSheet_Header", AppearanceItemType.LayoutItem, "IsNull(WorkSheetType) Or IsNull(DocumentNumber) Or IsNull(CustomersFrom) Or IsNull(Customers)", TargetItems:="ExcelTab", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide RowsTab WorkSheet_Header", AppearanceItemType.LayoutItem, "IsNull(WorkSheetType) Or IsNull(DocumentNumber) Or IsNull(CustomersFrom) Or IsNull(Customers)", TargetItems:="RowsTab", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide CostTab WorkSheet_Header", AppearanceItemType.LayoutItem, "IsNull(WorkSheetType) Or IsNull(DocumentNumber) Or IsNull(CustomersFrom) Or IsNull(Customers)", TargetItems:="CostTab", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide StorageOutTab WorkSheet_Header", AppearanceItemType.LayoutItem, "IsNull(WorkSheetType) Or IsNull(DocumentNumber) Or IsNull(CustomersFrom) Or IsNull(Customers)", TargetItems:="StorageOutTab", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide ReopenTab WorkSheet_Header", AppearanceItemType.LayoutItem, "IsNull(WorkSheetType) Or IsNull(DocumentNumber) Or IsNull(CustomersFrom) Or IsNull(Customers)", TargetItems:="ReopenTab", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Disable WorkSheet_Header-all prop, when WorkSheetState=eWorkSheetState.eClosed", AppearanceItemType.ViewItem, "WorkSheetState=1", TargetItems:="*", Enabled:=False)> _
<Appearance("Hide WorkSheet_Header-row properties, when WorkRowType=0 ", AppearanceItemType.ViewItem, "row_WorkRowType=0", TargetItems:="row_Units;row_RowGroup1;row_RowGroup2;row_Description;row_ShortName", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-aToTableWSR", AppearanceItemType.Action, "WorkSheetState = 1", TargetItems:="aToTableWSR", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-aToTableWSR_D", AppearanceItemType.Action, "WorkSheetState = 1", TargetItems:="aToTableWSR_D", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-aCreateWorksheetCostRows", AppearanceItemType.Action, "WorkSheetState = 1", TargetItems:="aCreateWorksheetCostRows", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-aRefreshWorksheetCostRows", AppearanceItemType.Action, "WorkSheetState = 1", TargetItems:="aRefreshWorksheetCostRows", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-aCreateInvoiceFromWorksheetCost", AppearanceItemType.Action, "WorkSheetState = 1", TargetItems:="aCreateInvoiceFromWorksheetCost", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Disable WorkSheet_Header-row_Services, when WorkRowType=1 ", AppearanceItemType.ViewItem, "row_WorkRowType=1", TargetItems:="row_Services", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-DateClosed, when WorkSheetState<>1 ", AppearanceItemType.ViewItem, " WorkSheetState<>'eClosed'", TargetItems:="DateClosed", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("WorkSheet_Header-JobNumberObjects-Visible", AppearanceItemType.ViewItem, "WorkSheetType.Rule5DMatrix.VisibleJobNumberObjects=True", TargetItems:="JobNumberObjects", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("WorkSheet_Header-UniqueObjects-Visible", AppearanceItemType.ViewItem, "WorkSheetType.Rule5DMatrix.VisibleUniqueObjects=True", TargetItems:="UniqueObjects", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("WorkSheet_Header-CostPlace-Visible", AppearanceItemType.ViewItem, "WorkSheetType.Rule5DMatrix.VisibleCostPlace=True", TargetItems:="CostPlace", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("WorkSheet_Header-CostHolder-Visible", AppearanceItemType.ViewItem, "WorkSheetType.Rule5DMatrix.VisibleCostHolder=True", TargetItems:="CostHolder", visibility:=Editors.ViewItemVisibility.Hide)> _
<Appearance("Hide WorkSheet_Header-all row properties, when WorkSheetState = 1", AppearanceItemType.ViewItem, "WorkSheetState = 1", TargetItems:="row_RowGroup1;row_RowGroup2;row_ShortName;row_Description;row_Quantity;row_Units;row_WorkType;row_WorkRowType;row_Services", visibility:=Editors.ViewItemVisibility.Hide)> _
Public Class WorkSheet_Header
    Inherits BaseObject
    Private _WorkSheetType As WorkSheetType 'Munkalap tipusa
    Private _WorkSheetState As eWorkSheetState ' munkalap állapota
    Private _WorkPlace As WorkPlace 'Munkahely
    Private _WorkState As WorkState 'Munkafolyamat
    Private _InvoiceState As eInvoiceState 'Számlázási állapot
    Private _Question As Question ' Internetes hibabejelentés
    Private _CustomersFrom As CustomersFrom 'Saját cég
    Private _Customers As Customers ' Partner, akire a munkalapot nyitották
    Private _Contacts As Contacts 'Kapcsolattartó
    Private _CurrencyName As CurrencyName 'Pénznem
    Private _DocumentNumber As String 'Munkalap száma
    Private _DateCreated As Date 'Létrehozás dátuma
    Private _DateExecution As Date 'Teljesítés dátuma
    Private _ExcelProperty As String ' Excel
    Private _ExcelFile As FileData 'Excel file
    Private _ObjectCreated As Date ' Létrehozva
    Private _UserCreated As User 'Létrehozó
    Private _Recipe As Recipe 'Milyen recept alapján kell gyártani
    Private _WorkSheetFile_Original As FileData 'Generált pdf, amit letölt az alvállalkozó
    Private _WorkSheetFile As FileData 'Csatolt alvállalkozói munkalap
    Private _SubcontractorInvoice As FileData 'Csatolt alvállalkozói számla
    Private _IsSubcontractor As Boolean 'Alvállalkozóhoz tartozik-e?
    Private _SubcontractorCustomers As Customers 'Alvállalkozó aki nyitotta
    Private _Description As String 'Belső megjeygszés alvállalkozói lezáráshoz
    Private _DateClosed As Date 'Lezárás dátuma

    Private _WorkHour As Double 'Munkaóra amit megadhat, nem kötelező (WEB)
    Private _WorkDescription As String 'Elvégzett munka leírása (nem kötelező WEB)
    Private _WorkUsedMaterialDescription As String 'Felhasznált anyag leírása (nem kötelező WEB)
    Private _WorkDescriptionOther As String 'Egyéb az alvállalkozó által megadott megjegyzés (nem kötelező WEB)
    Private _WorkTravelKm As Long 'Mennyit utaztak (nem kötelező WEB)
    Private _RegistryHeader As RegistryHeader 'Iktatáshoz kapcsolódó munkalap

    '-- Jelölő adatok !!!
    Private _JobNumberObjects As JobNumberObjects
    Private _UniqueObjects As UniqueObjects
    Private _CostPlace As CostPlace
    Private _CostHolder As CostHolder

    '-- Nonpersistent propertyk !!!
    Private _row_RowGroup1 As String 'Csoportosító sor1
    Private _row_RowGroup2 As String 'Csoportosító sor2
    Private _row_ShortName As String 'Megnevezés
    Private _row_Description As String 'Leírás
    Private _row_Quantity As Double 'Mennyiség
    Private _row_Units As Units 'Mennyiségi egység
    Private _row_WorkType As eWorkType 'A sor milyen (Fizetős, garancia vagy vegyes)
    Private _row_WorkRowType As eWorkRowType 'Az adott sor mit tartalmaz
    Private _row_Services As Services 'Szolgáltatás törzsből

    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    Public Overrides Sub AfterConstruction()
        MyBase.AfterConstruction()
        Me.WorkSheetState = eWorkSheetState.eOpened
        Me.CurrencyName = Session.FindObject(Of CurrencyName)(CriteriaOperator.Parse("ShortName='HUF'"))
    End Sub
    Protected Overrides Sub OnSaving()
        MyBase.OnSaving()
        If DocumentNumber = "" Then
            DocumentNumber = Me.WorkSheetType.NumberGenerator.GetNewNumber(Me.WorkSheetType.NumberGenerator)
        End If
        If Session.IsNewObject(Me) Then
            ObjectCreated = GetSQLTime(Session)
            UserCreated = Session.GetObjectByKey(Of User)(Session.GetKeyValue(SecuritySystem.CurrentUser))

            Try
                Dim _WebParameters As WebParameters = Session.FindObject(Of WebParameters)(CriteriaOperator.Parse("1=1"))
                If _WebParameters Is Nothing Then Throw New Exception("*Nincsnek e-mail paraméterek beállítva!")
                If _WebParameters.SMTPHost Is Nothing Then Throw New Exception("*Nincs SMTP server beállítva!")
                If _WebParameters.SMTPUserName = "" Then Throw New Exception("*Nincs felhasználói név beállítva!")
                If _WebParameters.SMTPPort = 0 Then Throw New Exception("*Nincs SMTP port beállítva!")

                Dim _MailMessage As New MailMessage
                Dim _SmtpClient As SmtpClient = New SmtpClient(_WebParameters.SMTPHost)
                _MailMessage.From = New MailAddress(_WebParameters.Email_SupportAdmin)
                If Customers.Contacts.Count > 0 Then
                    For Each _Contacts As Contacts In Customers.Contacts
                        If Not String.IsNullOrEmpty(_Contacts.Email) Then _MailMessage.To.Add(_Contacts.Email)
                    Next
                ElseIf Not String.IsNullOrEmpty(Customers.Email) Then
                    _MailMessage.To.Add(Customers.Email)
                Else
                    'Throw New Exception("*Nincs email cím beállítva!")
                End If

                _MailMessage.Subject = "Új munkalap készült"
                _MailMessage.IsBodyHtml = True
                _MailMessage.Body = String.Format("{0} számmal új munkalap készült az Ön(ök) részére.", DocumentNumber)

                _SmtpClient.Port = _WebParameters.SMTPPort
                _SmtpClient.Credentials = New System.Net.NetworkCredential(_WebParameters.SMTPUserName, _WebParameters.SMTPPassword)
                _SmtpClient.EnableSsl = _WebParameters.EnableSsl

                _SmtpClient.Send(_MailMessage)

                If UserCreated IsNot Nothing Then
                    If Not String.IsNullOrEmpty(UserCreated.Email) Then
                        _MailMessage.To.Clear()
                        _MailMessage.To.Add(UserCreated.Email)
                        _MailMessage.Body = String.Format("Ön {0} számmal új munkalapot hozott létre a(z) {1} ügyfél részére.", DocumentNumber, Customers.FullName)

                        _SmtpClient.Send(_MailMessage)
                    End If
                End If
            Catch ex As Exception
                Dim sf As StackFrame = New StackFrame()
                Dim _uow As New UnitOfWork(Session.DataLayer)
                Dim _ErrorLog As New ErrorLog(_uow)
                _ErrorLog.Description = ex.Message
                _ErrorLog.SubName = TryCast(sf.GetMethod(), System.Reflection.MethodBase).Name
                _uow.CommitTransaction()
            End Try

            '-------------IsOperationalLog-------------
            If WorkSheetType.IsOperationalLog Then
                Dim _OperationalLogParameters As OperationalLogParameters = Session.FindObject(Of OperationalLogParameters)(CriteriaOperator.Parse("WorkPlace=? AND CustomersFrom=?", WorkPlace, CustomersFrom))
                If _OperationalLogParameters IsNot Nothing Then
                    Dim _OperationalLog As New OperationalLog(Session)
                    With _OperationalLog
                        .CustomersFrom = CustomersFrom
                        .Customers = Customers
                        .OperationalLogParameters = _OperationalLogParameters
                        .WorkState = WorkState
                        .WorkPlace = WorkPlace
                        .Description = String.Format(WorkSheetType.OperationalLogDescription, DocumentNumber, ObjectCreated.ToString, UserCreated.UserName)
                    End With

                    _OperationalLog.Save()
                    ' Session.CommitTransaction()
                End If
            End If
        End If
    End Sub
    Property WorkSheetState() As eWorkSheetState
        Get
            Return _WorkSheetState
        End Get
        Set(ByVal value As eWorkSheetState)
            SetPropertyValue("WorkSheetState", _WorkSheetState, value)
        End Set
    End Property
    <RuleRequiredField("WorkSheet_Header-WorkSheetType", DefaultContexts.Save)>
    <ImmediatePostData(True), DataSourceCriteria("CustomersFrom = '@This.CustomersFrom'")>
    Property WorkSheetType() As WorkSheetType
        Get
            Return _WorkSheetType
        End Get
        Set(ByVal value As WorkSheetType)
            SetPropertyValue("WorkSheetType", _WorkSheetType, value)
            If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then
                If Session.IsNewObject(Me) = True Then
                    Me.ExcelProperty = value.ExcelProperty
                    Me.ExcelFile = value.ExcelFile
                End If
            End If
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("CustomersFrom='@This.CustomersFrom' and Customers='@This.Customers'")>
    Property WorkPlace As WorkPlace
        Get
            Return _WorkPlace
        End Get
        Set(value As WorkPlace)
            SetPropertyValue("WorkPlace", _WorkPlace, value)
        End Set
    End Property
    Property WorkState As WorkState
        Get
            Return _WorkState
        End Get
        Set(value As WorkState)
            SetPropertyValue("WorkState", _WorkState, value)
        End Set
    End Property
    Property InvoiceState As eInvoiceState
        Get
            Return _InvoiceState
        End Get
        Set(value As eInvoiceState)
            SetPropertyValue("InvoiceState", _InvoiceState, value)
        End Set
    End Property
    Property Question() As Question
        Get
            Return _Question
        End Get
        Set(ByVal value As Question)
            SetPropertyValue("Question", _Question, value)
        End Set
    End Property
    <ImmediatePostData(True)>
    <RuleRequiredField("WorkSheet_Header-CustomersFrom", DefaultContexts.Save)>
    Property CustomersFrom() As CustomersFrom
        Get
            Return _CustomersFrom
        End Get
        Set(ByVal value As CustomersFrom)
            SetPropertyValue("CustomersFrom", _CustomersFrom, value)
        End Set
    End Property
    <RuleRequiredField("WorkSheet_Header-Customers", DefaultContexts.Save)>
    Property Customers As Customers
        Get
            Return _Customers
        End Get
        Set(value As Customers)
            SetPropertyValue("Customers", _Customers, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("Customers = '@This.Customers'")>
    Property Contacts As Contacts
        Get
            Return _Contacts
        End Get
        Set(value As Contacts)
            SetPropertyValue("Contacts", _Contacts, value)
        End Set
    End Property
    Property CurrencyName As CurrencyName
        Get
            Return _CurrencyName
        End Get
        Set(value As CurrencyName)
            SetPropertyValue("CurrencyName", _CurrencyName, value)
        End Set
    End Property
    Property DocumentNumber() As String
        Get
            Return _DocumentNumber
        End Get
        Set(ByVal value As String)
            SetPropertyValue("DocumentNumber", _DocumentNumber, value)
        End Set
    End Property
    Property DateCreated() As Date
        Get
            Return _DateCreated
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateCreated", _DateCreated, value)
        End Set
    End Property
    Property DateExecution() As Date
        Get
            Return _DateExecution
        End Get
        Set(ByVal value As Date)
            SetPropertyValue("DateExecution", _DateExecution, value)
        End Set
    End Property
    <Size(-1)>
    <ImmediatePostData(True)>
    Property ExcelProperty As String
        Get
            Return _ExcelProperty
        End Get
        Set(value As String)
            SetPropertyValue("ExcelProperty", _ExcelProperty, value)
        End Set
    End Property
    <DevExpress.Xpo.Size(SizeAttribute.Unlimited)>
    Property ExcelFile As FileData
        Get
            Return _ExcelFile
        End Get
        Set(value As FileData)
            SetPropertyValue("ExcelFile", _ExcelFile, 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 Recipe As Recipe
        Get
            Return _Recipe
        End Get
        Set(value As Recipe)
            SetPropertyValue("Recipe", _Recipe, value)
        End Set
    End Property
    Property WorkSheetFile_Original As FileData
        Get
            Return _WorkSheetFile_Original
        End Get
        Set(value As FileData)
            SetPropertyValue("WorkSheetFile_Original", _WorkSheetFile_Original, value)
        End Set
    End Property
    Property WorkSheetFile As FileData
        Get
            Return _WorkSheetFile
        End Get
        Set(value As FileData)
            SetPropertyValue("WorkSheetFile", _WorkSheetFile, value)
        End Set
    End Property
    Property SubcontractorInvoice As FileData
        Get
            Return _SubcontractorInvoice
        End Get
        Set(value As FileData)
            SetPropertyValue("SubcontractorInvoice", _SubcontractorInvoice, value)
        End Set
    End Property
    Property IsSubcontractor As Boolean
        Get
            Return _IsSubcontractor
        End Get
        Set(value As Boolean)
            SetPropertyValue("IsSubcontractor", _IsSubcontractor, value)
        End Set
    End Property
    Property SubcontractorCustomers As Customers
        Get
            Return _SubcontractorCustomers
        End Get
        Set(value As Customers)
            SetPropertyValue("SubcontractorCustomers", _SubcontractorCustomers, value)
        End Set
    End Property
    <Size(-1)>
    <RuleRequiredField("WorkSheet_Header-Description", DefaultContexts.Save)>
    Property Description As String
        Get
            Return _Description
        End Get
        Set(value As String)
            SetPropertyValue("Description", _Description, value)
        End Set
    End Property
    Property DateClosed As Date
        Get
            Return _DateClosed
        End Get
        Set(value As Date)
            SetPropertyValue("DateClosed", _DateClosed, value)
        End Set
    End Property

    Property WorkHour As Double
        Get
            Return _WorkHour
        End Get
        Set(value As Double)
            SetPropertyValue("WorkHour", _WorkHour, value)
        End Set
    End Property
    <Size(-1)>
    Property WorkDescription As String
        Get
            Return _WorkDescription
        End Get
        Set(value As String)
            SetPropertyValue("WorkDescription", _WorkDescription, value)
        End Set
    End Property
    <Size(-1)>
    Property WorkUsedMaterialDescription As String
        Get
            Return _WorkUsedMaterialDescription
        End Get
        Set(value As String)
            SetPropertyValue("WorkUsedMaterialDescription", _WorkUsedMaterialDescription, value)
        End Set
    End Property
    <Size(-1)>
    Property WorkDescriptionOther As String
        Get
            Return _WorkDescriptionOther
        End Get
        Set(value As String)
            SetPropertyValue("WorkDescriptionOther", _WorkDescriptionOther, value)
        End Set
    End Property
    Property WorkTravelKm As Long
        Get
            Return _WorkTravelKm
        End Get
        Set(value As Long)
            SetPropertyValue("WorkTravelKm", _WorkTravelKm, value)
        End Set
    End Property
    <ImmediatePostData(True), DataSourceCriteria("RegistryType='@This.WorkSheetType.RegistryType'")>
    Property RegistryHeader As RegistryHeader
        Get
            Return _RegistryHeader
        End Get
        Set(value As RegistryHeader)
            SetPropertyValue("RegistryHeader", _RegistryHeader, value)
            If Session.IsObjectsLoading = False And Session.IsObjectsSaving = False Then
                Me.Customers = value.Customers
                Me.Description = value.ShortName
            End If
        End Set
    End Property

    '-- Jelölő adatok !!!
    <RuleRequiredField("WorkSheet_Header-JobNumberObjects-Require", DefaultContexts.Save, TargetCriteria:="WorkSheetType.Rule5DMatrix.RequireJobNumberObjects=True")> _
    Property JobNumberObjects As JobNumberObjects
        Get
            Return _JobNumberObjects
        End Get
        Set(value As JobNumberObjects)
            SetPropertyValue("JobNumberObjects", _JobNumberObjects, value)
        End Set
    End Property
    <RuleRequiredField("WorkSheet_Header-UniqueObjects-Require", DefaultContexts.Save, TargetCriteria:="WorkSheetType.Rule5DMatrix.RequireUniqueObjects=True")> _
    Property UniqueObjects As UniqueObjects
        Get
            Return _UniqueObjects
        End Get
        Set(value As UniqueObjects)
            SetPropertyValue("UniqueObjects", _UniqueObjects, value)
        End Set
    End Property
    <RuleRequiredField("WorkSheet_Header-CostPlace-Require", DefaultContexts.Save, TargetCriteria:="WorkSheetType.Rule5DMatrix.RequireCostPlace=True")> _
    Property CostPlace As CostPlace
        Get
            Return _CostPlace
        End Get
        Set(value As CostPlace)
            SetPropertyValue("CostPlace", _CostPlace, value)
        End Set
    End Property
    <RuleRequiredField("WorkSheet_Header-CostHolder-Require", DefaultContexts.Save, TargetCriteria:="WorkSheetType.Rule5DMatrix.RequireCostHolder=True")> _
    Property CostHolder As CostHolder
        Get
            Return _CostHolder
        End Get
        Set(value As CostHolder)
            SetPropertyValue("CostHolder", _CostHolder, value)
        End Set
    End Property

    '----------Nonpersistent propertyk !!!
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_RowGroup1 As String
        Get
            Return _row_RowGroup1
        End Get
        Set(value As String)
            SetPropertyValue("row_RowGroup1", _row_RowGroup1, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_RowGroup2 As String
        Get
            Return _row_RowGroup2
        End Get
        Set(value As String)
            SetPropertyValue("row_RowGroup2", _row_RowGroup2, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_ShortName As String
        Get
            Return _row_ShortName
        End Get
        Set(value As String)
            SetPropertyValue("row_ShortName", _row_ShortName, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_Description As String
        Get
            Return _row_Description
        End Get
        Set(value As String)
            SetPropertyValue("row_Description", _row_Description, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_Quantity As Double
        Get
            Return _row_Quantity
        End Get
        Set(value As Double)
            SetPropertyValue("row_Quantity", _row_Quantity, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_Units As Units
        Get
            Return _row_Units
        End Get
        Set(value As Units)
            SetPropertyValue("row_Units", _row_Units, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    <ImmediatePostData(True)> _
    Property row_WorkType() As eWorkType
        Get
            Return _row_WorkType
        End Get
        Set(ByVal value As eWorkType)
            SetPropertyValue("row_WorkType", _row_WorkType, value)
        End Set
    End Property
    <NonPersistent()> _
    <VisibleInListView(False)> _
    <ImmediatePostData(True)> _
    Property row_WorkRowType As eWorkRowType
        Get
            Return _row_WorkRowType
        End Get
        Set(value As eWorkRowType)
            SetPropertyValue("row_WorkRowType", _row_WorkRowType, value)
        End Set
    End Property
    <ImmediatePostData(True)> _
    <NonPersistent()> _
    <VisibleInListView(False)> _
    Property row_Services As Services
        Get
            Return _row_Services
        End Get
        Set(value As Services)
            SetPropertyValue("row_Services", _row_Services, value)
        End Set
    End Property

    '--------------------ReadOnly--------------------
    <VisibleInListView(False)> _
    <Association("WorkSheet_Header-WorkSheet_Rows", GetType(WorkSheet_Rows))> _
    ReadOnly Property WorkSheet_Rows() As XPCollection(Of WorkSheet_Rows)
        Get
            Return GetCollection(Of WorkSheet_Rows)("WorkSheet_Rows")
        End Get
    End Property
    <VisibleInListView(False)> _
    <Association("Worksheet_Documets-WorkSheet_Header", GetType(Worksheet_Documets))> _
    ReadOnly Property Worksheet_Documets As XPCollection(Of Worksheet_Documets)
        Get
            Return GetCollection(Of Worksheet_Documets)("Worksheet_Documets")
        End Get
    End Property
    <VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property StorageOutRows As XPCollection(Of StorageOutRows)
        Get
            Return New XPCollection(Of StorageOutRows)(Session, CriteriaOperator.Parse("StorageOutHeader.WorkSheet_Header=?", Me))
        End Get
    End Property
    <Association("WorkSheet_Header-Worksheet_CostRows", GetType(Worksheet_CostRows)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property Worksheet_CostRows As XPCollection(Of Worksheet_CostRows)
        Get
            Return GetCollection(Of Worksheet_CostRows)("Worksheet_CostRows")
        End Get
    End Property
    <Association("WorkSheet_Header-WorkSheet_ReopenReason", GetType(WorkSheet_ReopenReason)), VisibleInListView(False), VisibleInLookupListView(False)> _
    ReadOnly Property WorkSheet_ReopenReason As XPCollection(Of WorkSheet_ReopenReason)
        Get
            Return GetCollection(Of WorkSheet_ReopenReason)("WorkSheet_ReopenReason")
        End Get
    End Property
    <VisibleInListView(False)> _
    <VisibleInLookupListView(False)> _
    <Association("WorkSheet_Header-WorkSheet_Header_HRPerson", GetType(WorkSheet_Header_HRPerson))> _
    ReadOnly Property WorkSheet_Header_HRPerson As XPCollection(Of WorkSheet_Header_HRPerson)
        Get
            Return GetCollection(Of WorkSheet_Header_HRPerson)("WorkSheet_Header_HRPerson")
        End Get
    End Property
End Class
