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

📄 dsmaster.vb

📁 东软内部材料(六)ado .net相关
💻 VB
📖 第 1 页 / 共 3 页
字号:
        End Property
        
        Public Property Subtotal As Decimal
            Get
                Try 
                    Return CType(Me(Me.tableOrderTotals.SubtotalColumn),Decimal)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableOrderTotals.SubtotalColumn) = value
            End Set
        End Property
        
        Public Function IsEmployeeIDNull() As Boolean
            Return Me.IsNull(Me.tableOrderTotals.EmployeeIDColumn)
        End Function
        
        Public Sub SetEmployeeIDNull()
            Me(Me.tableOrderTotals.EmployeeIDColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsCustomerIDNull() As Boolean
            Return Me.IsNull(Me.tableOrderTotals.CustomerIDColumn)
        End Function
        
        Public Sub SetCustomerIDNull()
            Me(Me.tableOrderTotals.CustomerIDColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsOrderDateNull() As Boolean
            Return Me.IsNull(Me.tableOrderTotals.OrderDateColumn)
        End Function
        
        Public Sub SetOrderDateNull()
            Me(Me.tableOrderTotals.OrderDateColumn) = System.Convert.DBNull
        End Sub
        
        Public Function IsSubtotalNull() As Boolean
            Return Me.IsNull(Me.tableOrderTotals.SubtotalColumn)
        End Function
        
        Public Sub SetSubtotalNull()
            Me(Me.tableOrderTotals.SubtotalColumn) = System.Convert.DBNull
        End Sub
    End Class
    
    Public Class OrderTotalsRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As OrderTotalsRow
        
        Private eventAction As System.Data.DataRowAction
        
        Public Sub New(ByVal row As OrderTotalsRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As OrderTotalsRow
            Get
                Return Me.eventRow
            End Get
        End Property
        
        Public ReadOnly Property Action As DataRowAction
            Get
                Return Me.eventAction
            End Get
        End Property
    End Class
    
    Public Class EmployeeListDataTable
        Inherits DataTable
        Implements System.Collections.IEnumerable
        
        Private columnEmployeeID As DataColumn
        
        Private columnFirstName As DataColumn
        
        Private columnLastName As DataColumn
        
        Private columnFullName As DataColumn
        
        Friend Sub New()
            MyBase.New("EmployeeList")
            Me.InitClass
        End Sub
        
        <System.ComponentModel.Browsable(false)>  _
        Public ReadOnly Property Count As Integer
            Get
                Return Me.Rows.Count
            End Get
        End Property
        
        Friend ReadOnly Property EmployeeIDColumn As DataColumn
            Get
                Return Me.columnEmployeeID
            End Get
        End Property
        
        Friend ReadOnly Property FirstNameColumn As DataColumn
            Get
                Return Me.columnFirstName
            End Get
        End Property
        
        Friend ReadOnly Property LastNameColumn As DataColumn
            Get
                Return Me.columnLastName
            End Get
        End Property
        
        Friend ReadOnly Property FullNameColumn As DataColumn
            Get
                Return Me.columnFullName
            End Get
        End Property
        
        Public Default ReadOnly Property Item(ByVal index As Integer) As EmployeeListRow
            Get
                Return CType(Me.Rows(index),EmployeeListRow)
            End Get
        End Property
        
        Public Event EmployeeListRowChanged As EmployeeListRowChangeEventHandler
        
        Public Event EmployeeListRowChanging As EmployeeListRowChangeEventHandler
        
        Public Event EmployeeListRowDeleted As EmployeeListRowChangeEventHandler
        
        Public Event EmployeeListRowDeleting As EmployeeListRowChangeEventHandler
        
        Public Overloads Sub AddEmployeeListRow(ByVal row As EmployeeListRow)
            Me.Rows.Add(row)
        End Sub
        
        Public Overloads Function AddEmployeeListRow(ByVal FirstName As String, ByVal LastName As String, ByVal FullName As String) As EmployeeListRow
            Dim rowEmployeeListRow As EmployeeListRow = CType(Me.NewRow,EmployeeListRow)
            rowEmployeeListRow.ItemArray = New Object() {Nothing, FirstName, LastName, FullName}
            Me.Rows.Add(rowEmployeeListRow)
            Return rowEmployeeListRow
        End Function
        
        Public Function FindByEmployeeID(ByVal EmployeeID As Integer) As EmployeeListRow
            Return CType(Me.Rows.Find(New Object() {EmployeeID}),EmployeeListRow)
        End Function
        
        Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Rows.GetEnumerator
        End Function
        
        Private Sub InitClass()
            Me.columnEmployeeID = New DataColumn("EmployeeID", GetType(System.Int32), "", System.Data.MappingType.Element)
            Me.columnEmployeeID.AutoIncrement = true
            Me.columnEmployeeID.AllowDBNull = false
            Me.columnEmployeeID.ReadOnly = true
            Me.columnEmployeeID.Unique = true
            Me.Columns.Add(Me.columnEmployeeID)
            Me.columnFirstName = New DataColumn("FirstName", GetType(System.String), "", System.Data.MappingType.Element)
            Me.columnFirstName.AllowDBNull = false
            Me.Columns.Add(Me.columnFirstName)
            Me.columnLastName = New DataColumn("LastName", GetType(System.String), "", System.Data.MappingType.Element)
            Me.columnLastName.AllowDBNull = false
            Me.Columns.Add(Me.columnLastName)
            Me.columnFullName = New DataColumn("FullName", GetType(System.String), "FirstName + ' ' + LastName", System.Data.MappingType.Element)
            Me.columnFullName.Expression = "FirstName + ' ' + LastName"
            Me.columnFullName.ReadOnly = true
            Me.Columns.Add(Me.columnFullName)
            Me.PrimaryKey = New DataColumn() {Me.columnEmployeeID}
        End Sub
        
        Public Function NewEmployeeListRow() As EmployeeListRow
            Return CType(Me.NewRow,EmployeeListRow)
        End Function
        
        Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
            'We need to ensure that all Rows in the tabled are typed rows.
            'Table calls newRow whenever it needs to create a row.
            'So the following conditions are covered by Row newRow(Record record)
            '* Cursor calls table.addRecord(record) 
            '* table.addRow(object[] values) calls newRow(record)    
            Return New EmployeeListRow(builder)
        End Function
        
        Protected Overrides Function GetRowType() As System.Type
            Return GetType(EmployeeListRow)
        End Function
        
        Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanged(e)
            If (Not (Me.EmployeeListRowChangedEvent) Is Nothing) Then
                RaiseEvent EmployeeListRowChanged(Me, New EmployeeListRowChangeEvent(CType(e.Row,EmployeeListRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanging(e)
            If (Not (Me.EmployeeListRowChangingEvent) Is Nothing) Then
                RaiseEvent EmployeeListRowChanging(Me, New EmployeeListRowChangeEvent(CType(e.Row,EmployeeListRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleted(e)
            If (Not (Me.EmployeeListRowDeletedEvent) Is Nothing) Then
                RaiseEvent EmployeeListRowDeleted(Me, New EmployeeListRowChangeEvent(CType(e.Row,EmployeeListRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleting(e)
            If (Not (Me.EmployeeListRowDeletingEvent) Is Nothing) Then
                RaiseEvent EmployeeListRowDeleting(Me, New EmployeeListRowChangeEvent(CType(e.Row,EmployeeListRow), e.Action))
            End If
        End Sub
        
        Public Sub RemoveEmployeeListRow(ByVal row As EmployeeListRow)
            Me.Rows.Remove(row)
        End Sub
    End Class
    
    Public Class EmployeeListRow
        Inherits DataRow
        
        Private tableEmployeeList As EmployeeListDataTable
        
        Friend Sub New(ByVal rb As DataRowBuilder)
            MyBase.New(rb)
            Me.tableEmployeeList = CType(Me.Table,EmployeeListDataTable)
        End Sub
        
        Public Property EmployeeID As Integer
            Get
                Return CType(Me(Me.tableEmployeeList.EmployeeIDColumn),Integer)
            End Get
            Set
                Me(Me.tableEmployeeList.EmployeeIDColumn) = value
            End Set
        End Property
        
        Public Property FirstName As String
            Get
                Return CType(Me(Me.tableEmployeeList.FirstNameColumn),String)
            End Get
            Set
                Me(Me.tableEmployeeList.FirstNameColumn) = value
            End Set
        End Property
        
        Public Property LastName As String
            Get
                Return CType(Me(Me.tableEmployeeList.LastNameColumn),String)
            End Get
            Set
                Me(Me.tableEmployeeList.LastNameColumn) = value
            End Set
        End Property
        
        Public Property FullName As String
            Get
                Try 
                    Return CType(Me(Me.tableEmployeeList.FullNameColumn),String)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
                End Try
            End Get
            Set
                Me(Me.tableEmployeeList.FullNameColumn) = value
            End Set
        End Property
        
        Public Function IsFullNameNull() As Boolean
            Return Me.IsNull(Me.tableEmployeeList.FullNameColumn)
        End Function
        
        Public Sub SetFullNameNull()
            Me(Me.tableEmployeeList.FullNameColumn) = System.Convert.DBNull
        End Sub
    End Class
    
    Public Class EmployeeListRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As EmployeeListRow
        
        Private eventAction As System.Data.DataRowAction
        
        Public Sub New(ByVal row As EmployeeListRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As EmployeeListRow
            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 + -