📄 dataset1.vb
字号:
Public Sub New(ByVal row As jcclRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As jcclRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class xsysDataTable
Inherits DataTable
Implements System.Collections.IEnumerable
Private column书名 As DataColumn
Private column姓名 As DataColumn
Private column数量 As DataColumn
Private column书号 As DataColumn
Private column单价 As DataColumn
Private column总价 As DataColumn
Friend Sub New()
MyBase.New("xsys")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName)
If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
<System.ComponentModel.Browsable(false)> _
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property 书名Column As DataColumn
Get
Return Me.column书名
End Get
End Property
Friend ReadOnly Property 姓名Column As DataColumn
Get
Return Me.column姓名
End Get
End Property
Friend ReadOnly Property 数量Column As DataColumn
Get
Return Me.column数量
End Get
End Property
Friend ReadOnly Property 书号Column As DataColumn
Get
Return Me.column书号
End Get
End Property
Friend ReadOnly Property 单价Column As DataColumn
Get
Return Me.column单价
End Get
End Property
Friend ReadOnly Property 总价Column As DataColumn
Get
Return Me.column总价
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As xsysRow
Get
Return CType(Me.Rows(index),xsysRow)
End Get
End Property
Public Event xsysRowChanged As xsysRowChangeEventHandler
Public Event xsysRowChanging As xsysRowChangeEventHandler
Public Event xsysRowDeleted As xsysRowChangeEventHandler
Public Event xsysRowDeleting As xsysRowChangeEventHandler
Public Overloads Sub AddxsysRow(ByVal row As xsysRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddxsysRow(ByVal 书名 As String, ByVal 姓名 As String, ByVal 数量 As Integer, ByVal 书号 As String, ByVal 单价 As Decimal, ByVal 总价 As Decimal) As xsysRow
Dim rowxsysRow As xsysRow = CType(Me.NewRow,xsysRow)
rowxsysRow.ItemArray = New Object() {书名, 姓名, 数量, 书号, 单价, 总价}
Me.Rows.Add(rowxsysRow)
Return rowxsysRow
End Function
Public Function FindBy书号(ByVal 书号 As String) As xsysRow
Return CType(Me.Rows.Find(New Object() {书号}),xsysRow)
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 xsysDataTable = CType(MyBase.Clone,xsysDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New xsysDataTable
End Function
Friend Sub InitVars()
Me.column书名 = Me.Columns("书名")
Me.column姓名 = Me.Columns("姓名")
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.Int32), 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.Decimal), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.column单价)
Me.column总价 = New DataColumn("总价", GetType(System.Decimal), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.column总价)
Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.column书号}, true))
Me.column书号.AllowDBNull = false
Me.column书号.Unique = true
End Sub
Public Function NewxsysRow() As xsysRow
Return CType(Me.NewRow,xsysRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New xsysRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(xsysRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.xsysRowChangedEvent) Is Nothing) Then
RaiseEvent xsysRowChanged(Me, New xsysRowChangeEvent(CType(e.Row,xsysRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.xsysRowChangingEvent) Is Nothing) Then
RaiseEvent xsysRowChanging(Me, New xsysRowChangeEvent(CType(e.Row,xsysRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.xsysRowDeletedEvent) Is Nothing) Then
RaiseEvent xsysRowDeleted(Me, New xsysRowChangeEvent(CType(e.Row,xsysRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.xsysRowDeletingEvent) Is Nothing) Then
RaiseEvent xsysRowDeleting(Me, New xsysRowChangeEvent(CType(e.Row,xsysRow), e.Action))
End If
End Sub
Public Sub RemovexsysRow(ByVal row As xsysRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class xsysRow
Inherits DataRow
Private tablexsys As xsysDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tablexsys = CType(Me.Table,xsysDataTable)
End Sub
Public Property 书名 As String
Get
Try
Return CType(Me(Me.tablexsys.书名Column),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablexsys.书名Column) = value
End Set
End Property
Public Property 姓名 As String
Get
Try
Return CType(Me(Me.tablexsys.姓名Column),String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablexsys.姓名Column) = value
End Set
End Property
Public Property 数量 As Integer
Get
Try
Return CType(Me(Me.tablexsys.数量Column),Integer)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablexsys.数量Column) = value
End Set
End Property
Public Property 书号 As String
Get
Return CType(Me(Me.tablexsys.书号Column),String)
End Get
Set
Me(Me.tablexsys.书号Column) = value
End Set
End Property
Public Property 单价 As Decimal
Get
Try
Return CType(Me(Me.tablexsys.单价Column),Decimal)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablexsys.单价Column) = value
End Set
End Property
Public Property 总价 As Decimal
Get
Try
Return CType(Me(Me.tablexsys.总价Column),Decimal)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set
Me(Me.tablexsys.总价Column) = value
End Set
End Property
Public Function Is书名Null() As Boolean
Return Me.IsNull(Me.tablexsys.书名Column)
End Function
Public Sub Set书名Null()
Me(Me.tablexsys.书名Column) = System.Convert.DBNull
End Sub
Public Function Is姓名Null() As Boolean
Return Me.IsNull(Me.tablexsys.姓名Column)
End Function
Public Sub Set姓名Null()
Me(Me.tablexsys.姓名Column) = System.Convert.DBNull
End Sub
Public Function Is数量Null() As Boolean
Return Me.IsNull(Me.tablexsys.数量Column)
End Function
Public Sub Set数量Null()
Me(Me.tablexsys.数量Column) = System.Convert.DBNull
End Sub
Public Function Is单价Null() As Boolean
Return Me.IsNull(Me.tablexsys.单价Column)
End Function
Public Sub Set单价Null()
Me(Me.tablexsys.单价Column) = System.Convert.DBNull
End Sub
Public Function Is总价Null() As Boolean
Return Me.IsNull(Me.tablexsys.总价Column)
End Function
Public Sub Set总价Null()
Me(Me.tablexsys.总价Column) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class xsysRowChangeEvent
Inherits EventArgs
Private eventRow As xsysRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As xsysRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As xsysRow
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 + -