📄 dsproduct.vb
字号:
End Function
Public Overrides Function Clone() As DataTable
Dim cln As ProductsDataTable = CType(MyBase.Clone, ProductsDataTable)
cln.InitVars()
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New ProductsDataTable()
End Function
Public Sub InitVars()
Me.columnProductID = Me.Columns("ProductID")
Me.columnSKU = Me.Columns("SKU")
Me.columnProductType = Me.Columns("ProductType")
Me.columnProductDate = Me.Columns("ProductDate")
Me.columnProductName = Me.Columns("ProductName")
Me.columnDescription = Me.Columns("Description")
Me.columnProductSize = Me.Columns("ProductSize")
Me.columnImageURL = Me.Columns("ImageURL")
Me.columnUnitPrice = Me.Columns("UnitPrice")
Me.columnOnSale = Me.Columns("OnSale")
End Sub
Private Sub InitClass()
Me.columnProductID = New DataColumn("ProductID", GetType(System.Guid), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnProductID)
Me.columnSKU = New DataColumn("SKU", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnSKU)
Me.columnProductType = New DataColumn("ProductType", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnProductType)
Me.columnProductDate = New DataColumn("ProductDate", GetType(System.DateTime), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnProductDate)
Me.columnProductName = New DataColumn("ProductName", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnProductName)
Me.columnDescription = New DataColumn("Description", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnDescription)
Me.columnProductSize = New DataColumn("ProductSize", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnProductSize)
Me.columnImageURL = New DataColumn("ImageURL", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnImageURL)
Me.columnUnitPrice = New DataColumn("UnitPrice", GetType(System.Decimal), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnUnitPrice)
Me.columnOnSale = New DataColumn("OnSale", GetType(System.Boolean), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnOnSale)
Me.Constraints.Add(New UniqueConstraint("dsProductKey1", New DataColumn() {Me.columnProductID}, True))
Me.columnProductID.AllowDBNull = False
Me.columnProductID.Unique = True
Me.columnSKU.AllowDBNull = False
Me.columnProductName.AllowDBNull = False
Me.columnDescription.AllowDBNull = False
Me.columnUnitPrice.AllowDBNull = False
Me.columnOnSale.AllowDBNull = False
End Sub
Public Function NewProductsRow() As ProductsRow
Return CType(Me.NewRow, ProductsRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New ProductsRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(ProductsRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.ProductsRowChangedEvent) Is Nothing) Then
RaiseEvent ProductsRowChanged(Me, New ProductsRowChangeEvent(CType(e.Row, ProductsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.ProductsRowChangingEvent) Is Nothing) Then
RaiseEvent ProductsRowChanging(Me, New ProductsRowChangeEvent(CType(e.Row, ProductsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.ProductsRowDeletedEvent) Is Nothing) Then
RaiseEvent ProductsRowDeleted(Me, New ProductsRowChangeEvent(CType(e.Row, ProductsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.ProductsRowDeletingEvent) Is Nothing) Then
RaiseEvent ProductsRowDeleting(Me, New ProductsRowChangeEvent(CType(e.Row, ProductsRow), e.Action))
End If
End Sub
Public Sub RemoveProductsRow(ByVal row As ProductsRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class ProductsRow
Inherits DataRow
Private tableProducts As ProductsDataTable
Public Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tableProducts = CType(Me.Table, ProductsDataTable)
End Sub
Public Property ProductID() As System.Guid
Get
Return CType(Me(Me.tableProducts.ProductIDColumn), System.Guid)
End Get
Set(ByVal Value As System.Guid)
Me(Me.tableProducts.ProductIDColumn) = Value
End Set
End Property
Public Property SKU() As String
Get
Return CType(Me(Me.tableProducts.SKUColumn), String)
End Get
Set(ByVal Value As String)
Me(Me.tableProducts.SKUColumn) = Value
End Set
End Property
Public Property ProductType() As String
Get
Try
Return CType(Me(Me.tableProducts.ProductTypeColumn), String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set(ByVal Value As String)
Me(Me.tableProducts.ProductTypeColumn) = Value
End Set
End Property
Public Property ProductDate() As Date
Get
Try
Return CType(Me(Me.tableProducts.ProductDateColumn), Date)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set(ByVal Value As Date)
Me(Me.tableProducts.ProductDateColumn) = Value
End Set
End Property
Public Property ProductName() As String
Get
Return CType(Me(Me.tableProducts.ProductNameColumn), String)
End Get
Set(ByVal Value As String)
Me(Me.tableProducts.ProductNameColumn) = Value
End Set
End Property
Public Property Description() As String
Get
Return CType(Me(Me.tableProducts.DescriptionColumn), String)
End Get
Set(ByVal Value As String)
Me(Me.tableProducts.DescriptionColumn) = Value
End Set
End Property
Public Property ProductSize() As String
Get
Try
Return CType(Me(Me.tableProducts.ProductSizeColumn), String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set(ByVal Value As String)
Me(Me.tableProducts.ProductSizeColumn) = Value
End Set
End Property
Public Property ImageURL() As String
Get
Try
Return CType(Me(Me.tableProducts.ImageURLColumn), String)
Catch e As InvalidCastException
Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
End Try
End Get
Set(ByVal Value As String)
Me(Me.tableProducts.ImageURLColumn) = Value
End Set
End Property
Public Property UnitPrice() As Decimal
Get
Return CType(Me(Me.tableProducts.UnitPriceColumn), Decimal)
End Get
Set(ByVal Value As Decimal)
Me(Me.tableProducts.UnitPriceColumn) = Value
End Set
End Property
Public Property OnSale() As Boolean
Get
Return CType(Me(Me.tableProducts.OnSaleColumn), Boolean)
End Get
Set(ByVal Value As Boolean)
Me(Me.tableProducts.OnSaleColumn) = Value
End Set
End Property
Public Function IsProductTypeNull() As Boolean
Return Me.IsNull(Me.tableProducts.ProductTypeColumn)
End Function
Public Sub SetProductTypeNull()
Me(Me.tableProducts.ProductTypeColumn) = System.Convert.DBNull
End Sub
Public Function IsProductDateNull() As Boolean
Return Me.IsNull(Me.tableProducts.ProductDateColumn)
End Function
Public Sub SetProductDateNull()
Me(Me.tableProducts.ProductDateColumn) = System.Convert.DBNull
End Sub
Public Function IsProductSizeNull() As Boolean
Return Me.IsNull(Me.tableProducts.ProductSizeColumn)
End Function
Public Sub SetProductSizeNull()
Me(Me.tableProducts.ProductSizeColumn) = System.Convert.DBNull
End Sub
Public Function IsImageURLNull() As Boolean
Return Me.IsNull(Me.tableProducts.ImageURLColumn)
End Function
Public Sub SetImageURLNull()
Me(Me.tableProducts.ImageURLColumn) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class ProductsRowChangeEvent
Inherits EventArgs
Private eventRow As ProductsRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As ProductsRow, ByVal action As DataRowAction)
MyBase.New()
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row() As ProductsRow
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 + -