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

📄 dataset11.vb

📁 第五章 家庭财务程序开发
💻 VB
📖 第 1 页 / 共 2 页
字号:
        Public Event OutgoingRowDeleting As OutgoingRowChangeEventHandler
        
        Public Overloads Sub AddOutgoingRow(ByVal row As OutgoingRow)
            Me.Rows.Add(row)
        End Sub
        
        Public Overloads Function AddOutgoingRow(ByVal 单位 As String, ByVal 类型 As String, ByVal 匹配码 As String, ByVal 项目名称 As String) As OutgoingRow
            Dim rowOutgoingRow As OutgoingRow = CType(Me.NewRow,OutgoingRow)
            rowOutgoingRow.ItemArray = New Object() {单位, 类型, 匹配码, 项目名称}
            Me.Rows.Add(rowOutgoingRow)
            Return rowOutgoingRow
        End Function
        
        Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Rows.GetEnumerator
        End Function
        
        Public Overrides Function Clone() As DataTable
            Dim cln As OutgoingDataTable = CType(MyBase.Clone,OutgoingDataTable)
            cln.InitVars
            Return cln
        End Function
        
        Protected Overrides Function CreateInstance() As DataTable
            Return New OutgoingDataTable
        End Function
        
        Friend Sub InitVars()
            Me.column单位 = Me.Columns("单位")
            Me.column类型 = Me.Columns("类型")
            Me.column匹配码 = Me.Columns("匹配码")
            Me.column项目名称 = Me.Columns("项目名称")
        End Sub
        
        Private Sub InitClass()
            Me.column单位 = New DataColumn("单位", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.column单位)
            Me.column类型 = New DataColumn("类型", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.column类型)
            Me.column匹配码 = New DataColumn("匹配码", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.column匹配码)
            Me.column项目名称 = New DataColumn("项目名称", GetType(System.String), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.column项目名称)
        End Sub
        
        Public Function NewOutgoingRow() As OutgoingRow
            Return CType(Me.NewRow,OutgoingRow)
        End Function
        
        Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
            Return New OutgoingRow(builder)
        End Function
        
        Protected Overrides Function GetRowType() As System.Type
            Return GetType(OutgoingRow)
        End Function
        
        Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanged(e)
            If (Not (Me.OutgoingRowChangedEvent) Is Nothing) Then
                RaiseEvent OutgoingRowChanged(Me, New OutgoingRowChangeEvent(CType(e.Row,OutgoingRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanging(e)
            If (Not (Me.OutgoingRowChangingEvent) Is Nothing) Then
                RaiseEvent OutgoingRowChanging(Me, New OutgoingRowChangeEvent(CType(e.Row,OutgoingRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleted(e)
            If (Not (Me.OutgoingRowDeletedEvent) Is Nothing) Then
                RaiseEvent OutgoingRowDeleted(Me, New OutgoingRowChangeEvent(CType(e.Row,OutgoingRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleting(e)
            If (Not (Me.OutgoingRowDeletingEvent) Is Nothing) Then
                RaiseEvent OutgoingRowDeleting(Me, New OutgoingRowChangeEvent(CType(e.Row,OutgoingRow), e.Action))
            End If
        End Sub
        
        Public Sub RemoveOutgoingRow(ByVal row As OutgoingRow)
            Me.Rows.Remove(row)
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class OutgoingRow
        Inherits DataRow
        
        Private tableOutgoing As OutgoingDataTable
        
        Friend Sub New(ByVal rb As DataRowBuilder)
            MyBase.New(rb)
            Me.tableOutgoing = CType(Me.Table,OutgoingDataTable)
        End Sub
        
        Public Property 单位 As String
            Get
                Try 
                    Return CType(Me(Me.tableOutgoing.单位Column),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
                End Try
            End Get
            Set
                Me(Me.tableOutgoing.单位Column) = value
            End Set
        End Property
        
        Public Property 类型 As String
            Get
                Try 
                    Return CType(Me(Me.tableOutgoing.类型Column),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
                End Try
            End Get
            Set
                Me(Me.tableOutgoing.类型Column) = value
            End Set
        End Property
        
        Public Property 匹配码 As String
            Get
                Try 
                    Return CType(Me(Me.tableOutgoing.匹配码Column),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
                End Try
            End Get
            Set
                Me(Me.tableOutgoing.匹配码Column) = value
            End Set
        End Property
        
        Public Property 项目名称 As String
            Get
                Try 
                    Return CType(Me(Me.tableOutgoing.项目名称Column),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
                End Try
            End Get
            Set
                Me(Me.tableOutgoing.项目名称Column) = value
            End Set
        End Property
        
        Public Function Is单位Null() As Boolean
            Return Me.IsNull(Me.tableOutgoing.单位Column)
        End Function
        
        Public Sub Set单位Null()
            Me(Me.tableOutgoing.单位Column) = System.Convert.DBNull
        End Sub
        
        Public Function Is类型Null() As Boolean
            Return Me.IsNull(Me.tableOutgoing.类型Column)
        End Function
        
        Public Sub Set类型Null()
            Me(Me.tableOutgoing.类型Column) = System.Convert.DBNull
        End Sub
        
        Public Function Is匹配码Null() As Boolean
            Return Me.IsNull(Me.tableOutgoing.匹配码Column)
        End Function
        
        Public Sub Set匹配码Null()
            Me(Me.tableOutgoing.匹配码Column) = System.Convert.DBNull
        End Sub
        
        Public Function Is项目名称Null() As Boolean
            Return Me.IsNull(Me.tableOutgoing.项目名称Column)
        End Function
        
        Public Sub Set项目名称Null()
            Me(Me.tableOutgoing.项目名称Column) = System.Convert.DBNull
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class OutgoingRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As OutgoingRow
        
        Private eventAction As DataRowAction
        
        Public Sub New(ByVal row As OutgoingRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As OutgoingRow
            Get
                Return Me.eventRow
            End Get
        End Property
        
        Public ReadOnly Property Action As DataRowAction
            Get
                Return Me.eventAction
            End Get
        End Property
    End Class
End Class

⌨️ 快捷键说明

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