📄 dataset4.vb
字号:
Get
Return Me.columnprice
End Get
End Property
Friend ReadOnly Property standColumn As DataColumn
Get
Return Me.columnstand
End Get
End Property
Friend ReadOnly Property anountColumn As DataColumn
Get
Return Me.columnanount
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As storeRow
Get
Return CType(Me.Rows(index),storeRow)
End Get
End Property
Public Event storeRowChanged As storeRowChangeEventHandler
Public Event storeRowChanging As storeRowChangeEventHandler
Public Event storeRowDeleted As storeRowChangeEventHandler
Public Event storeRowDeleting As storeRowChangeEventHandler
Public Overloads Sub AddstoreRow(ByVal row As storeRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddstoreRow(ByVal aname As String, ByVal ano As String, ByVal descript As String, ByVal price As Decimal, ByVal stand As String, ByVal anount As Integer) As storeRow
Dim rowstoreRow As storeRow = CType(Me.NewRow,storeRow)
rowstoreRow.ItemArray = New Object() {aname, ano, descript, price, stand, anount}
Me.Rows.Add(rowstoreRow)
Return rowstoreRow
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 storeDataTable = CType(MyBase.Clone,storeDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New storeDataTable
End Function
Friend Sub InitVars()
Me.columnaname = Me.Columns("aname")
Me.columnano = Me.Columns("ano")
Me.columndescript = Me.Columns("descript")
Me.columnprice = Me.Columns("price")
Me.columnstand = Me.Columns("stand")
Me.columnanount = Me.Columns("anount")
End Sub
Private Sub InitClass()
Me.columnaname = New DataColumn("aname", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnaname)
Me.columnano = New DataColumn("ano", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnano)
Me.columndescript = New DataColumn("descript", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columndescript)
Me.columnprice = New DataColumn("price", GetType(System.Decimal), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnprice)
Me.columnstand = New DataColumn("stand", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnstand)
Me.columnanount = New DataColumn("anount", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnanount)
End Sub
Public Function NewstoreRow() As storeRow
Return CType(Me.NewRow,storeRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New storeRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(storeRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.storeRowChangedEvent) Is Nothing) Then
RaiseEvent storeRowChanged(Me, New storeRowChangeEvent(CType(e.Row,storeRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.storeRowChangingEvent) Is Nothing) Then
RaiseEvent storeRowChanging(Me, New storeRowChangeEvent(CType(e.Row,storeRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.storeRowDeletedEvent) Is Nothing) Then
RaiseEvent storeRowDeleted(Me, New storeRowChangeEvent(CType(e.Row,storeRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.storeRowDeletingEvent) Is Nothing) Then
RaiseEvent storeRowDeleting(Me, New storeRowChangeEvent(CType(e.Row,storeRow), e.Action))
End If
End Sub
Public Sub RemovestoreRow(ByVal row As storeRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class storeRow
Inherits DataRow
Private tablestore As storeDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tablestore = CType(Me.Table,storeDataTable)
End Sub
Public Property aname As String
Get
Try
Return CType(Me(Me.tablestore.anameColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablestore.anameColumn) = value
End Set
End Property
Public Property ano As String
Get
Try
Return CType(Me(Me.tablestore.anoColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablestore.anoColumn) = value
End Set
End Property
Public Property descript As String
Get
Try
Return CType(Me(Me.tablestore.descriptColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablestore.descriptColumn) = value
End Set
End Property
Public Property price As Decimal
Get
Try
Return CType(Me(Me.tablestore.priceColumn),Decimal)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablestore.priceColumn) = value
End Set
End Property
Public Property stand As String
Get
Try
Return CType(Me(Me.tablestore.standColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablestore.standColumn) = value
End Set
End Property
Public Property anount As Integer
Get
Try
Return CType(Me(Me.tablestore.anountColumn),Integer)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablestore.anountColumn) = value
End Set
End Property
Public Function IsanameNull() As Boolean
Return Me.IsNull(Me.tablestore.anameColumn)
End Function
Public Sub SetanameNull()
Me(Me.tablestore.anameColumn) = System.Convert.DBNull
End Sub
Public Function IsanoNull() As Boolean
Return Me.IsNull(Me.tablestore.anoColumn)
End Function
Public Sub SetanoNull()
Me(Me.tablestore.anoColumn) = System.Convert.DBNull
End Sub
Public Function IsdescriptNull() As Boolean
Return Me.IsNull(Me.tablestore.descriptColumn)
End Function
Public Sub SetdescriptNull()
Me(Me.tablestore.descriptColumn) = System.Convert.DBNull
End Sub
Public Function IspriceNull() As Boolean
Return Me.IsNull(Me.tablestore.priceColumn)
End Function
Public Sub SetpriceNull()
Me(Me.tablestore.priceColumn) = System.Convert.DBNull
End Sub
Public Function IsstandNull() As Boolean
Return Me.IsNull(Me.tablestore.standColumn)
End Function
Public Sub SetstandNull()
Me(Me.tablestore.standColumn) = System.Convert.DBNull
End Sub
Public Function IsanountNull() As Boolean
Return Me.IsNull(Me.tablestore.anountColumn)
End Function
Public Sub SetanountNull()
Me(Me.tablestore.anountColumn) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class storeRowChangeEvent
Inherits EventArgs
Private eventRow As storeRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As storeRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As storeRow
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 + -