Files
Nuvolar/Nuvolar.Module/BusinessObjects/Business/Technologies/Technologies.vb
T
2017-03-08 11:21:27 +01:00

221 lines
9.1 KiB
VB.net

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
<DefaultClassOptions()> _
<NavigationItem(False)> _
<CreatableItem(False)> _
Public Class Technologies
Inherits BaseObject
Private _MasterBusinessDirectory As BusinessDirectory
Private _DocumentNumber As String
Private _ShortName As String
Private _Description As String
Private _UserCreated As User
Private _ObjectCreated As Date
Private _TechnologiesParameters As TechnologiesParameters
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
If String.IsNullOrEmpty(DocumentNumber) Then
DocumentNumber = TechnologiesParameters.NumberGenerator.GetNewNumber(TechnologiesParameters.NumberGenerator)
End If
End Sub
Property MasterBusinessDirectory As BusinessDirectory
Get
Return _MasterBusinessDirectory
End Get
Set(value As BusinessDirectory)
SetPropertyValue("MasterBusinessDirectory", _MasterBusinessDirectory, 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
<RuleRequiredField("Technologies - ShortName", DefaultContexts.Save)> _
Property ShortName As String
Get
Return _ShortName
End Get
Set(value As String)
SetPropertyValue("ShortName", _ShortName, value)
End Set
End Property
Property Description As String
Get
Return _Description
End Get
Set(value As String)
SetPropertyValue("Description", _Description, 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
<NonCloneable()> _
Property ObjectCreated As Date
Get
Return _ObjectCreated
End Get
Set(value As Date)
SetPropertyValue("ObjectCreated", _ObjectCreated, value)
End Set
End Property
<RuleRequiredField("Technologies - TechnologiesParameters", DefaultContexts.Save)> _
Property TechnologiesParameters As TechnologiesParameters
Get
Return _TechnologiesParameters
End Get
Set(value As TechnologiesParameters)
SetPropertyValue("TechnologiesParameters", _TechnologiesParameters, value)
End Set
End Property
'---ReadOlny properties
<VisibleInListView(False)> _
ReadOnly Property Products As XPCollection(Of Products)
Get
Dim _Products_Collection As New XPCollection(Of Products)(Session, CriteriaOperator.Parse("1=2"))
Dim _TechnologiesProducts_Collection As New XPCollection(Of TechnologiesProducts)(Session, CriteriaOperator.Parse("Technologies=?", Me))
For Each _TechnologiesProducts As TechnologiesProducts In _TechnologiesProducts_Collection
_Products_Collection.Add(_TechnologiesProducts.Products)
Next
Return _Products_Collection
End Get
End Property
<VisibleInListView(False)> _
ReadOnly Property Services As XPCollection(Of Services)
Get
Dim _Services_Collection As New XPCollection(Of Services)(Session, CriteriaOperator.Parse("1=2"))
Dim _TechnologiesServices_Collection As New XPCollection(Of TechnologiesServices)(Session, CriteriaOperator.Parse("Technologies=?", Me))
For Each _TechnologiesServices As TechnologiesServices In _TechnologiesServices_Collection
_Services_Collection.Add(_TechnologiesServices.Services)
Next
Return _Services_Collection
End Get
End Property
<VisibleInListView(False)> _
ReadOnly Property Customers As XPCollection(Of Customers)
Get
Dim _Customers_Collection As New XPCollection(Of Customers)(Session, CriteriaOperator.Parse("1=2"))
Dim _TechnologiesCustomers_Collection As New XPCollection(Of TechnologiesCustomers)(Session, CriteriaOperator.Parse("Technologies=?", Me))
For Each _TechnologiesCustomers As TechnologiesCustomers In _TechnologiesCustomers_Collection
_Customers_Collection.Add(_TechnologiesCustomers.Customers)
Next
Return _Customers_Collection
End Get
End Property
<VisibleInListView(False)> _
ReadOnly Property Contacts As XPCollection(Of Contacts)
Get
Dim _Contacts_Collection As New XPCollection(Of Contacts)(Session, CriteriaOperator.Parse("1=2"))
Dim _TechnologiesContacts_Collection As New XPCollection(Of TechnologiesContacts)(Session, CriteriaOperator.Parse("Technologies=?", Me))
For Each _TechnologiesContacts As TechnologiesContacts In _TechnologiesContacts_Collection
_Contacts_Collection.Add(_TechnologiesContacts.Contacts)
Next
Return _Contacts_Collection
End Get
End Property
<VisibleInListView(False)> _
ReadOnly Property Technologies_BusinessDirectory As XPCollection(Of BusinessDirectory)
Get
Dim _BusinessDirectory_Collection As New XPCollection(Of BusinessDirectory)(Session, CriteriaOperator.Parse("1=2"))
For Each _ProductsElem As Products In Products
If _ProductsElem.MasterBusinessDirectory IsNot Nothing Then
If _ProductsElem.MasterBusinessDirectory.Children.Count > 0 Then
_BusinessDirectory_Collection.Add(_ProductsElem.MasterBusinessDirectory)
RecursiveBusinessDirectory(_BusinessDirectory_Collection, _ProductsElem.MasterBusinessDirectory.NestedBusinessDirectory)
Else
_BusinessDirectory_Collection.Add(_ProductsElem.MasterBusinessDirectory)
End If
End If
If _ProductsElem.ProductGroups IsNot Nothing Then
If _ProductsElem.ProductGroups.MasterBusinessDirectory IsNot Nothing Then
If _ProductsElem.ProductGroups.MasterBusinessDirectory.Children.Count > 0 Then
_BusinessDirectory_Collection.Add(_ProductsElem.ProductGroups.MasterBusinessDirectory)
RecursiveBusinessDirectory(_BusinessDirectory_Collection, _ProductsElem.ProductGroups.MasterBusinessDirectory.NestedBusinessDirectory)
Else
_BusinessDirectory_Collection.Add(_ProductsElem.ProductGroups.MasterBusinessDirectory)
End If
End If
End If
Next
For Each _ServicesElem As Services In Services
If _ServicesElem.MasterBusinessDirectory IsNot Nothing Then
If _ServicesElem.MasterBusinessDirectory.Children.Count > 0 Then
_BusinessDirectory_Collection.Add(_ServicesElem.MasterBusinessDirectory)
RecursiveBusinessDirectory(_BusinessDirectory_Collection, _ServicesElem.MasterBusinessDirectory.NestedBusinessDirectory)
Else
_BusinessDirectory_Collection.Add(_ServicesElem.MasterBusinessDirectory)
End If
End If
Next
If MasterBusinessDirectory IsNot Nothing Then
If MasterBusinessDirectory.Children.Count > 0 Then
_BusinessDirectory_Collection.Add(MasterBusinessDirectory)
RecursiveBusinessDirectory(_BusinessDirectory_Collection, MasterBusinessDirectory.NestedBusinessDirectory)
Else
_BusinessDirectory_Collection.Add(MasterBusinessDirectory)
End If
End If
Return _BusinessDirectory_Collection
End Get
End Property
#Region "Other subs"
Private Sub RecursiveBusinessDirectory(_BusinessDirectoryList As XPCollection(Of BusinessDirectory), _NestedBusinessDirectory As XPCollection(Of BusinessDirectory))
For Each _BusinessDirectory As BusinessDirectory In _NestedBusinessDirectory
If _BusinessDirectory.Children.Count > 0 Then
_BusinessDirectoryList.Add(_BusinessDirectory)
RecursiveBusinessDirectory(_BusinessDirectoryList, _BusinessDirectory.NestedBusinessDirectory)
Else
_BusinessDirectoryList.Add(_BusinessDirectory)
End If
Next
End Sub
#End Region
End Class