northwinddataset.designer.vb
来自「wrox出版社的另一套经典的VB2005数据库编程学习书籍,收集了书中源码,郑重」· VB 代码 · 共 1,373 行 · 第 1/5 页
VB
1,373 行
If (Not (Me.ReorderLevelChangedEvent) Is Nothing) Then
RaiseEvent ReorderLevelChanged(Me, New ReorderLevelChangeEventArg(e))
End If
Else
If (e.Column.ColumnName Is "Discontinued") Then
If (Not (Me.DiscontinuedChangedEvent) Is Nothing) Then
RaiseEvent DiscontinuedChanged(Me, New DiscontinuedChangeEventArg(e))
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Public Overloads Sub AddProductsRow(ByVal row As ProductsRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddProductsRow(ByVal ProductName As String, ByVal SupplierID As Integer, ByVal CategoryID As Integer, ByVal QuantityPerUnit As String, ByVal UnitPrice As Decimal, ByVal UnitsInStock As Short, ByVal UnitsOnOrder As Short, ByVal ReorderLevel As Short, ByVal Discontinued As Boolean) As ProductsRow
Dim rowProductsRow As ProductsRow = CType(Me.NewRow,ProductsRow)
rowProductsRow.ItemArray = New Object() {Nothing, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued}
Me.Rows.Add(rowProductsRow)
Return rowProductsRow
End Function
Public Function FindByProductID(ByVal ProductID As Integer) As ProductsRow
Return CType(Me.Rows.Find(New Object() {ProductID}),ProductsRow)
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 System.Data.DataTable
Dim cln As ProductsDataTable = CType(MyBase.Clone,ProductsDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As System.Data.DataTable
Return New ProductsDataTable
End Function
Friend Sub InitVars()
Me.columnProductID = MyBase.Columns("ProductID")
Me.columnProductName = MyBase.Columns("ProductName")
Me.columnSupplierID = MyBase.Columns("SupplierID")
Me.columnCategoryID = MyBase.Columns("CategoryID")
Me.columnQuantityPerUnit = MyBase.Columns("QuantityPerUnit")
Me.columnUnitPrice = MyBase.Columns("UnitPrice")
Me.columnUnitsInStock = MyBase.Columns("UnitsInStock")
Me.columnUnitsOnOrder = MyBase.Columns("UnitsOnOrder")
Me.columnReorderLevel = MyBase.Columns("ReorderLevel")
Me.columnDiscontinued = MyBase.Columns("Discontinued")
End Sub
Private Sub InitClass()
Me.columnProductID = New System.Data.DataColumn("ProductID", GetType(Integer), Nothing, System.Data.MappingType.Element)
Me.columnProductID.ExtendedProperties.Add("Generator_ChangedEventName", "ProductIDChanged")
Me.columnProductID.ExtendedProperties.Add("Generator_ChangingEventName", "ProductIDChanging")
Me.columnProductID.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "ProductID")
Me.columnProductID.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "ProductIDColumn")
Me.columnProductID.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnProductID")
Me.columnProductID.ExtendedProperties.Add("Generator_DelegateName", "ProductIDChangeEventHandler")
Me.columnProductID.ExtendedProperties.Add("Generator_EventArgName", "ProductIDChangeEventArg")
Me.columnProductID.ExtendedProperties.Add("User_ColumnName", "ProductID")
MyBase.Columns.Add(Me.columnProductID)
Me.columnProductName = New System.Data.DataColumn("ProductName", GetType(String), Nothing, System.Data.MappingType.Element)
Me.columnProductName.ExtendedProperties.Add("Generator_ChangedEventName", "ProductNameChanged")
Me.columnProductName.ExtendedProperties.Add("Generator_ChangingEventName", "ProductNameChanging")
Me.columnProductName.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "ProductName")
Me.columnProductName.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "ProductNameColumn")
Me.columnProductName.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnProductName")
Me.columnProductName.ExtendedProperties.Add("Generator_DelegateName", "ProductNameChangeEventHandler")
Me.columnProductName.ExtendedProperties.Add("Generator_EventArgName", "ProductNameChangeEventArg")
Me.columnProductName.ExtendedProperties.Add("User_ColumnName", "ProductName")
MyBase.Columns.Add(Me.columnProductName)
Me.columnSupplierID = New System.Data.DataColumn("SupplierID", GetType(Integer), Nothing, System.Data.MappingType.Element)
Me.columnSupplierID.ExtendedProperties.Add("Generator_ChangedEventName", "SupplierIDChanged")
Me.columnSupplierID.ExtendedProperties.Add("Generator_ChangingEventName", "SupplierIDChanging")
Me.columnSupplierID.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "SupplierID")
Me.columnSupplierID.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "SupplierIDColumn")
Me.columnSupplierID.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnSupplierID")
Me.columnSupplierID.ExtendedProperties.Add("Generator_DelegateName", "SupplierIDChangeEventHandler")
Me.columnSupplierID.ExtendedProperties.Add("Generator_EventArgName", "SupplierIDChangeEventArg")
Me.columnSupplierID.ExtendedProperties.Add("User_ColumnName", "SupplierID")
MyBase.Columns.Add(Me.columnSupplierID)
Me.columnCategoryID = New System.Data.DataColumn("CategoryID", GetType(Integer), Nothing, System.Data.MappingType.Element)
Me.columnCategoryID.ExtendedProperties.Add("Generator_ChangedEventName", "CategoryIDChanged")
Me.columnCategoryID.ExtendedProperties.Add("Generator_ChangingEventName", "CategoryIDChanging")
Me.columnCategoryID.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "CategoryID")
Me.columnCategoryID.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "CategoryIDColumn")
Me.columnCategoryID.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnCategoryID")
Me.columnCategoryID.ExtendedProperties.Add("Generator_DelegateName", "CategoryIDChangeEventHandler")
Me.columnCategoryID.ExtendedProperties.Add("Generator_EventArgName", "CategoryIDChangeEventArg")
Me.columnCategoryID.ExtendedProperties.Add("User_ColumnName", "CategoryID")
MyBase.Columns.Add(Me.columnCategoryID)
Me.columnQuantityPerUnit = New System.Data.DataColumn("QuantityPerUnit", GetType(String), Nothing, System.Data.MappingType.Element)
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_ChangedEventName", "QuantityPerUnitChanged")
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_ChangingEventName", "QuantityPerUnitChanging")
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "QuantityPerUnit")
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "QuantityPerUnitColumn")
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnQuantityPerUnit")
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_DelegateName", "QuantityPerUnitChangeEventHandler")
Me.columnQuantityPerUnit.ExtendedProperties.Add("Generator_EventArgName", "QuantityPerUnitChangeEventArg")
Me.columnQuantityPerUnit.ExtendedProperties.Add("User_ColumnName", "QuantityPerUnit")
MyBase.Columns.Add(Me.columnQuantityPerUnit)
Me.columnUnitPrice = New System.Data.DataColumn("UnitPrice", GetType(Decimal), Nothing, System.Data.MappingType.Element)
Me.columnUnitPrice.ExtendedProperties.Add("Generator_ChangedEventName", "UnitPriceChanged")
Me.columnUnitPrice.ExtendedProperties.Add("Generator_ChangingEventName", "UnitPriceChanging")
Me.columnUnitPrice.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "UnitPrice")
Me.columnUnitPrice.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "UnitPriceColumn")
Me.columnUnitPrice.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnUnitPrice")
Me.columnUnitPrice.ExtendedProperties.Add("Generator_DelegateName", "UnitPriceChangeEventHandler")
Me.columnUnitPrice.ExtendedProperties.Add("Generator_EventArgName", "UnitPriceChangeEventArg")
Me.columnUnitPrice.ExtendedProperties.Add("User_ColumnName", "UnitPrice")
MyBase.Columns.Add(Me.columnUnitPrice)
Me.columnUnitsInStock = New System.Data.DataColumn("UnitsInStock", GetType(Short), Nothing, System.Data.MappingType.Element)
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_ChangedEventName", "UnitsInStockChanged")
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_ChangingEventName", "UnitsInStockChanging")
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "UnitsInStock")
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "UnitsInStockColumn")
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnUnitsInStock")
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_DelegateName", "UnitsInStockChangeEventHandler")
Me.columnUnitsInStock.ExtendedProperties.Add("Generator_EventArgName", "UnitsInStockChangeEventArg")
Me.columnUnitsInStock.ExtendedProperties.Add("User_ColumnName", "UnitsInStock")
MyBase.Columns.Add(Me.columnUnitsInStock)
Me.columnUnitsOnOrder = New System.Data.DataColumn("UnitsOnOrder", GetType(Short), Nothing, System.Data.MappingType.Element)
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_ChangedEventName", "UnitsOnOrderChanged")
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_ChangingEventName", "UnitsOnOrderChanging")
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "UnitsOnOrder")
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "UnitsOnOrderColumn")
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnUnitsOnOrder")
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_DelegateName", "UnitsOnOrderChangeEventHandler")
Me.columnUnitsOnOrder.ExtendedProperties.Add("Generator_EventArgName", "UnitsOnOrderChangeEventArg")
Me.columnUnitsOnOrder.ExtendedProperties.Add("User_ColumnName", "UnitsOnOrder")
MyBase.Columns.Add(Me.columnUnitsOnOrder)
Me.columnReorderLevel = New System.Data.DataColumn("ReorderLevel", GetType(Short), Nothing, System.Data.MappingType.Element)
Me.columnReorderLevel.ExtendedProperties.Add("Generator_ChangedEventName", "ReorderLevelChanged")
Me.columnReorderLevel.ExtendedProperties.Add("Generator_ChangingEventName", "ReorderLevelChanging")
Me.columnReorderLevel.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "ReorderLevel")
Me.columnReorderLevel.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "ReorderLevelColumn")
Me.columnReorderLevel.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnReorderLevel")
Me.columnReorderLevel.ExtendedProperties.Add("Generator_DelegateName", "ReorderLevelChangeEventHandler")
Me.columnReorderLevel.ExtendedProperties.Add("Generator_EventArgName", "ReorderLevelChangeEventArg")
Me.columnReorderLevel.ExtendedProperties.Add("User_ColumnName", "ReorderLevel")
MyBase.Columns.Add(Me.columnReorderLevel)
Me.columnDiscontinued = New System.Data.DataColumn("Discontinued", GetType(Boolean), Nothing, System.Data.MappingType.Element)
Me.columnDiscontinued.ExtendedProperties.Add("Generator_ChangedEventName", "DiscontinuedChanged")
Me.columnDiscontinued.ExtendedProperties.Add("Generator_ChangingEventName", "DiscontinuedChanging")
Me.columnDiscontinued.ExtendedProperties.Add("Generator_ColumnPropNameInRow", "Discontinued")
Me.columnDiscontinued.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "DiscontinuedColumn")
Me.columnDiscontinued.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnDiscontinued")
Me.columnDiscontinued.ExtendedProperties.Add("Generator_DelegateName", "DiscontinuedChangeEventHandler")
Me.columnDiscontinued.ExtendedProperties.Add("Generator_EventArgName", "DiscontinuedChangeEventArg")
Me.columnDiscontinued.ExtendedProperties.Add("User_ColumnName", "Discontinued")
MyBase.Columns.Add(Me.columnDiscontinued)
Me.Constraints.Add(New System.Data.UniqueConstraint("Constraint1", New System.Data.DataColumn() {Me.columnProductID}, true))
Me.columnProductID.AutoIncrement = true
Me.columnProductID.AllowDBNull = false
Me.columnProductID.ReadOnly = true
Me.columnProductID.Unique = true
Me.columnProductName.AllowDBNull = false
Me.columnProductName.MaxLength = 40
Me.columnQuantityPerUnit.MaxLength = 20
Me.columnDiscontinued.AllowDBNull = false
Me.ExtendedProperties.Add("Generator_RowClassName", "ProductsRow")
Me.ExtendedProperties.Add("Generator_RowEvArgName", "ProductsRowChangeEvent")
Me.ExtendedProperties.Add("Generator_RowEvHandlerName", "ProductsRowChangeEventHandler")
Me.ExtendedProperties.Add("Generator_SuspendValidationPropName", "SuspendValidation")
Me.ExtendedProperties.Add("Generator_SuspendValidationVarName", "m_suspendValidation")
Me.ExtendedProperties.Add("Generator_TableClassName", "ProductsDataTable")
Me.ExtendedProperties.Add("Generator_TablePropName", "Products")
Me.ExtendedProperties.Add("Generator_TableVarName", "tableProducts")
Me.ExtendedProperties.Add("User_TableName", "Products")
End Sub
Public Function NewProductsRow() As ProductsRow
Return CType(Me.NewRow,ProductsRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As System.Data.DataRowBuilder) As System.Data.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 System.Data.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 System.Data.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 System.Data.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 System.Data.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
Public Shared Function GetTypedTableSchema(ByVal xs As System.Xml.Schema.XmlSchemaSet) As System.Xml.Schema.XmlSchemaComplexType
Dim type As System.Xml.Schema.XmlSchemaComplexType = New System.Xml.Schema.XmlSchemaComplexType
Dim sequence As System.Xml.Schema.XmlSchemaSequence = New System.Xml.Schema.XmlSchemaSequence
Dim ds As NorthwindDataSet = New NorthwindDataSet
xs.Add(ds.GetSchemaSerializable)
Dim any1 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
any1.Namespace = "http://www.w3.org/2001/XMLSchema"
any1.MinOccurs = New Decimal(0)
any1.MaxOccurs = Decimal.MaxValue
any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
sequence.Items.Add(any1)
Dim any2 As System.Xml.Schema.XmlSchemaAny = New System.Xml.Schema.XmlSchemaAny
any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"
any2.MinOccurs = New Decimal(1)
any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax
sequence.Items.Add(any2)
Dim attribute1 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
attribute1.Name = "namespace"
attribute1.FixedValue = ds.Namespace
type.Attributes.Add(attribute1)
Dim attribute2 As System.Xml.Schema.XmlSchemaAttribute = New System.Xml.Schema.XmlSchemaAttribute
attribute2.Name = "tableTypeName"
attribute2.FixedValue = "ProductsDataTable"
type.Attributes.Add(attribute2)
type.Particle = sequence
Return type
End Function
Public Delegate Sub ProductIDChangeEventHandler(ByVal sender As ProductsDataTable, ByVal e As ProductIDChangeEventArg)
Public Class ProductIDChangeEventArg
Inherits System.EventArgs
Private evArgs As System.Data.DataColumnChangeEventArgs
Public Sub New(ByVal args As System.Data.DataColumnChangeEventArgs)
MyBase.New
Me.evArgs = args
End Sub
Public ReadOnly Property Row() As ProductsRow
Get
Return CType(Me.evArgs.Row,ProductsRow)
End Get
End Property
Public ReadOnly Property ProductIDColumn() As System.Data.DataColumn
Get
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?