⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 entityobject.cls

📁 VB财务软件系统下载源代码提供自由下载使用学习
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "EntityObject"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'--------------------------------
'时间:2001.11.12
'版权:北京用友软件股份有限公司
'设计:章景峰
'编码:章景峰
'说明:U8资金管理---实体对象
'--------------------------------
Option Explicit

Private m_iID               As Long
Private m_sName             As String               '实体对象的状态
Private m_sCaption          As String               '实体对象的状态
Private m_Fields            As Fields               '实体对象的状态
Private m_iState            As EntityStateEnum      '实体对象的状态
Private m_iBIType           As Long
Private m_sHelpContextID    As String
Private m_sTaskID           As String
Private m_sDescription      As String
Private m_iSheetID          As Long
Private m_iRows             As Long
Private m_iCols             As Long
Private m_OID               As OIDObject
Private m_EOs               As Entities
Private m_sSourceTable      As String
Private m_sSourceOIDField   As String
Private m_ParentOID         As OIDObject
Private m_sParentField      As String
Private m_sPzSign           As String
Private m_bIsUsed           As Boolean
Private m_iVchType          As Long                 '实体对象的单据类型
Private m_iDeriveBIType     As Long
Private m_iWidth            As Double
Private m_iHeight           As Double
Private m_bAutoAlarm        As Boolean
Private m_iAlarmDays        As Long

Public Property Set Fields(ByVal vData As Object)
'当把对象赋值给属性时在 Set 语句左边使用。
'Syntax: Set x.Fields = Form1
    Set m_Fields = vData
End Property

Public Property Get Fields() As Fields
Attribute Fields.VB_UserMemId = 0
'当检索属性值时在参数右边使用。
'Syntax: Debug.Print X.Fields
    Set Fields = m_Fields
End Property

Public Property Let Caption(ByVal vData As String)
'当给属性赋值时在参数左边使用。
'Syntax: X.Caption = 5
    m_sCaption = vData
End Property

Public Property Get Caption() As String
'当检索属性值时在参数右边使用。
'Syntax: Debug.Print X.Caption
    Caption = m_sCaption
End Property

Public Property Let Name(ByVal vData As String)
'当给属性赋值时在参数左边使用。
'Syntax: X.Name = 5
    m_sName = vData
End Property

Public Property Get Name() As String
'当检索属性值时在参数右边使用。
'Syntax: Debug.Print X.Name
    Name = m_sName
End Property

Private Sub Class_Initialize()
    Set m_Fields = New Fields
    Set m_OID = New OIDObject
    Set m_EOs = New Entities
    Set m_ParentOID = New OIDObject
End Sub

Private Sub Class_Terminate()
    Set m_Fields = Nothing
    Set m_OID = Nothing
    Set m_EOs = Nothing
    Set m_ParentOID = Nothing
End Sub

Public Property Get State() As EntityStateEnum
    State = m_iState
End Property

Public Property Let State(ByVal vData As EntityStateEnum)
    m_iState = vData
End Property

'校验实体对象各元素值是否合法
Public Function Validate() As Boolean
    Dim oFO As FieldObject
    Dim i   As Integer
    
    'For Each oFO In Fields
    For i = 1 To Fields.Count
        Set oFO = Fields.Item(i)
        '----已使用并可持久化
        If oFO.IsUsed And oFO.Persistent Then
            '----设置值为默认值
            If IsEmpty(oFO.Value) Or IsNull(oFO.Value) Then
                oFO.Value = oFO.DefaultValue
            End If
            
            '----检查不允许为空的域对象是否为空
            If Not oFO.AllowNull Then
                If IsNull(oFO.Value) Then
                    Err.Raise vbObjectError + 3000, oFO.Name, oFO.Caption & "不能为空!"
                End If
            End If
        End If
    Next

    Validate = True
End Function

Public Property Get ID() As Long
    ID = m_iID
End Property

Public Property Let ID(ByVal vData As Long)
    m_iID = vData
End Property

Public Property Get BIType() As Long
    BIType = m_iBIType
End Property

Public Property Let BIType(ByVal vData As Long)
    m_iBIType = vData
End Property

Public Property Get HelpContextID() As String
    HelpContextID = m_sHelpContextID
End Property

Public Property Let HelpContextID(ByVal vData As String)
    m_sHelpContextID = vData
End Property

Public Property Get TaskID() As String
    TaskID = m_sTaskID
End Property

Public Property Let TaskID(ByVal vData As String)
    m_sTaskID = vData
End Property

Public Property Get Description() As String
    Description = m_sDescription
End Property

Public Property Let Description(ByVal vData As String)
    m_sDescription = vData
End Property

Public Function Clone(Optional Mode As CloneModeEnum = 0) As EntityObject
    Dim oEO As New EntityObject
    Dim oFO As FieldObject
    Dim i   As Integer
    
    With oEO
        .ID = Me.ID
        .Name = Me.Name
        .Caption = Me.Caption
        If Mode = esoStructureOnly Then
            .State = esoInitialized
        Else
            .State = Me.State
        End If
        .BIType = Me.BIType
        .SourceOIDField = Me.SourceOIDField
        .SourceTable = Me.SourceTable
        .ParentField = Me.ParentField
        .ParentOID = Me.ParentOID
        .OID = Me.OID
        .TaskID = Me.TaskID
        .HelpContextID = Me.HelpContextID
        .Description = Me.Description
        .SheetID = Me.SheetID
        .Rows = Me.Rows
        .Cols = Me.Cols
        .IsUsed = Me.IsUsed
        .PzSign = Me.PzSign
        .VchType = Me.VchType
        .DeriveBIType = Me.DeriveBIType
        
        For i = 1 To Fields.Count
            Set oFO = Fields.Item(i)
            .Fields.AppendEx oFO.Clone(Mode)
        Next
        
        If Mode = esoStructureAndData Then
            For i = 1 To Me.EOs.Count
                .EOs.Append Me.EOs(i), "K" & Me.EOs(i)(Me.EOs(i).SourceOIDField)
            Next
        End If
        
        If Not Me.EOs.EOMetaData Is Nothing Then
            Set .EOs.EOMetaData = Me.EOs.EOMetaData.Clone
        End If
    End With
    
    Set Clone = oEO
End Function

Public Property Get SheetID() As Long
    SheetID = m_iSheetID
End Property

Public Property Let SheetID(ByVal vData As Long)
    m_iSheetID = vData
End Property

Public Property Get Rows() As Long
    Rows = m_iRows
End Property

Public Property Let Rows(ByVal vData As Long)
    m_iRows = vData
End Property

Public Property Get Cols() As Long
    Cols = m_iCols
End Property

Public Property Let Cols(ByVal vData As Long)
    m_iCols = vData
End Property

Public Property Get EOs() As Entities
    Set EOs = m_EOs
End Property

Public Property Set EOs(ByVal vData As Entities)
    Set m_EOs = vData
End Property

Public Property Let SourceTable(ByVal vData As String)
'当给属性赋值时在参数左边使用。
'Syntax: X.SourceTable = 5
    m_sSourceTable = vData
End Property

Public Property Get SourceTable() As String
'当检索属性值时在参数右边使用。
'Syntax: Debug.Print X.SourceTable
    SourceTable = m_sSourceTable
End Property

Public Property Get ParentOID() As OIDObject
    Set ParentOID = m_ParentOID
End Property

Public Property Let ParentOID(ByVal vData As OIDObject)
    Set m_ParentOID = vData
End Property

Public Property Get OID() As OIDObject
    Set OID = m_OID
End Property

Public Property Set OID(ByVal vData As OIDObject)
    Set m_OID = vData
    Me.Fields.Item(Me.SourceOIDField) = m_OID '这条语句是为字段sOID赋值,如果取消,就需要在各个BI中逐个赋值
End Property

Public Property Get ParentField() As String
    ParentField = m_sParentField
End Property

Public Property Let ParentField(ByVal vData As String)
    m_sParentField = vData
End Property

Public Property Get SourceOIDField() As String
    SourceOIDField = m_sSourceOIDField
End Property

Public Property Let SourceOIDField(ByVal vData As String)
    m_sSourceOIDField = vData
End Property

Public Property Get PzSign() As String
    PzSign = m_sPzSign
End Property

Public Property Let PzSign(ByVal vData As String)
    m_sPzSign = vData
End Property

Public Property Get IsUsed() As Boolean
    IsUsed = m_bIsUsed
End Property

Public Property Let IsUsed(ByVal vData As Boolean)
    m_bIsUsed = vData
End Property

Public Property Get VchType() As Integer
    VchType = m_iVchType
End Property

Public Property Let VchType(ByVal vData As Integer)
    m_iVchType = vData
End Property

Public Property Get DeriveBIType() As Integer
    DeriveBIType = m_iDeriveBIType
End Property

Public Property Let DeriveBIType(ByVal vData As Integer)
    m_iDeriveBIType = vData
End Property

Public Property Get Width() As Double
    Width = m_iWidth
End Property

Public Property Let Width(ByVal vData As Double)
    m_iWidth = vData
End Property

Public Property Get Height() As Double
    Height = m_iHeight
End Property

Public Property Let Height(ByVal vData As Double)
    m_iHeight = vData
End Property

Public Property Get IsAutoAlarm() As Boolean
    IsAutoAlarm = m_bAutoAlarm
End Property

Public Property Let IsAutoAlarm(ByVal vData As Boolean)
    m_bAutoAlarm = vData
End Property

Public Property Get AlarmDays() As Integer
    AlarmDays = m_iAlarmDays
End Property

Public Property Let AlarmDays(ByVal vData As Integer)
    m_iAlarmDays = vData
End Property

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -