home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic .NET - Read Less - Learn More / Visual_Basic.NET_Read_Less_Learn_More_Richard_Bowman_Visual_2002.iso / Resources / Code / Ch9-CreateDataRelation / DsNorthwind.vb < prev    next >
Text File  |  2001-08-23  |  44KB  |  1,140 lines

  1. '------------------------------------------------------------------------------
  2. ' <autogenerated>
  3. '     This code was generated by a tool.
  4. '     Runtime Version: 1.0.2914.16
  5. '
  6. '     Changes to this file may cause incorrect behavior and will be lost if 
  7. '     the code is regenerated.
  8. ' </autogenerated>
  9. '------------------------------------------------------------------------------
  10.  
  11. Option Strict Off
  12. Option Explicit On
  13.  
  14. Imports System
  15. Imports System.Data
  16. Imports System.Runtime.Serialization
  17. Imports System.Xml
  18.  
  19.  
  20. <Serializable(),  _
  21.  System.ComponentModel.DesignerCategoryAttribute("code")>  _
  22. Public Class DsNorthwind
  23.     Inherits System.Data.DataSet
  24.     
  25.     Private tableCustomers As CustomersDataTable
  26.     
  27.     Private tableOrders As OrdersDataTable
  28.     
  29.     Private relationCustomersOrders As DataRelation
  30.     
  31.     Public Sub New()
  32.         MyBase.New
  33.         Me.InitClass
  34.     End Sub
  35.     
  36.     Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
  37.         MyBase.New
  38.         Me.InitClass
  39.         Me.GetSerializationData(info, context)
  40.     End Sub
  41.     
  42.     <System.ComponentModel.Browsable(false),  _
  43.      System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)>  _
  44.     Public ReadOnly Property Customers As CustomersDataTable
  45.         Get
  46.             Return Me.tableCustomers
  47.         End Get
  48.     End Property
  49.     
  50.     <System.ComponentModel.Browsable(false),  _
  51.      System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)>  _
  52.     Public ReadOnly Property Orders As OrdersDataTable
  53.         Get
  54.             Return Me.tableOrders
  55.         End Get
  56.     End Property
  57.     
  58.     Protected Overrides Function ShouldSerializeTables() As Boolean
  59.         Return false
  60.     End Function
  61.     
  62.     Protected Overrides Function ShouldSerializeRelations() As Boolean
  63.         Return false
  64.     End Function
  65.     
  66.     Protected Overrides Sub ReadXmlSerializable(ByVal reader As XmlReader)
  67.         Me.ReadXml(reader, XmlReadMode.IgnoreSchema)
  68.     End Sub
  69.     
  70.     Protected Overrides Function GetSchemaSerializable() As System.Xml.Schema.XmlSchema
  71.         Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream
  72.         Me.WriteXmlSchema(New XmlTextWriter(stream, Nothing))
  73.         stream.Position = 0
  74.         Return System.Xml.Schema.XmlSchema.Read(New XmlTextReader(stream), Nothing)
  75.     End Function
  76.     
  77.     Private Sub InitClass()
  78.         Me.DataSetName = "DsNorthwind"
  79.         Me.Namespace = "http://www.tempuri.org/DsNorthwind.xsd"
  80.         Me.tableCustomers = New CustomersDataTable
  81.         Me.Tables.Add(Me.tableCustomers)
  82.         Me.tableOrders = New OrdersDataTable
  83.         Me.Tables.Add(Me.tableOrders)
  84.         Me.tableOrders.Constraints.Add(New System.Data.ForeignKeyConstraint("CustomersOrders", New DataColumn() {Me.tableCustomers.CustomerIDColumn}, New DataColumn() {Me.tableOrders.CustomerIDColumn}))
  85.         Me.relationCustomersOrders = New DataRelation("CustomersOrders", New DataColumn() {Me.tableCustomers.CustomerIDColumn}, New DataColumn() {Me.tableOrders.CustomerIDColumn}, false)
  86.         Me.Relations.Add(Me.relationCustomersOrders)
  87.     End Sub
  88.     
  89.     Private Function ShouldSerializeCustomers() As Boolean
  90.         Return false
  91.     End Function
  92.     
  93.     Private Function ShouldSerializeOrders() As Boolean
  94.         Return false
  95.     End Function
  96.     
  97.     Public Delegate Sub CustomersRowChangeEventHandler(ByVal sender As Object, ByVal e As CustomersRowChangeEvent)
  98.     
  99.     Public Delegate Sub OrdersRowChangeEventHandler(ByVal sender As Object, ByVal e As OrdersRowChangeEvent)
  100.     
  101.     Public Class CustomersDataTable
  102.         Inherits DataTable
  103.         Implements System.Collections.IEnumerable
  104.         
  105.         Private columnCustomerID As DataColumn
  106.         
  107.         Private columnCompanyName As DataColumn
  108.         
  109.         Private columnContactName As DataColumn
  110.         
  111.         Private columnContactTitle As DataColumn
  112.         
  113.         Private columnAddress As DataColumn
  114.         
  115.         Private columnCity As DataColumn
  116.         
  117.         Private column_Region As DataColumn
  118.         
  119.         Private columnPostalCode As DataColumn
  120.         
  121.         Private columnCountry As DataColumn
  122.         
  123.         Private columnPhone As DataColumn
  124.         
  125.         Private columnFax As DataColumn
  126.         
  127.         Friend Sub New()
  128.             MyBase.New("Customers")
  129.             Me.InitClass
  130.         End Sub
  131.         
  132.         <System.ComponentModel.Browsable(false)>  _
  133.         Public ReadOnly Property Count As Integer
  134.             Get
  135.                 Return Me.Rows.Count
  136.             End Get
  137.         End Property
  138.         
  139.         Friend ReadOnly Property CustomerIDColumn As DataColumn
  140.             Get
  141.                 Return Me.columnCustomerID
  142.             End Get
  143.         End Property
  144.         
  145.         Friend ReadOnly Property CompanyNameColumn As DataColumn
  146.             Get
  147.                 Return Me.columnCompanyName
  148.             End Get
  149.         End Property
  150.         
  151.         Friend ReadOnly Property ContactNameColumn As DataColumn
  152.             Get
  153.                 Return Me.columnContactName
  154.             End Get
  155.         End Property
  156.         
  157.         Friend ReadOnly Property ContactTitleColumn As DataColumn
  158.             Get
  159.                 Return Me.columnContactTitle
  160.             End Get
  161.         End Property
  162.         
  163.         Friend ReadOnly Property AddressColumn As DataColumn
  164.             Get
  165.                 Return Me.columnAddress
  166.             End Get
  167.         End Property
  168.         
  169.         Friend ReadOnly Property CityColumn As DataColumn
  170.             Get
  171.                 Return Me.columnCity
  172.             End Get
  173.         End Property
  174.         
  175.         Friend ReadOnly Property _RegionColumn As DataColumn
  176.             Get
  177.                 Return Me.column_Region
  178.             End Get
  179.         End Property
  180.         
  181.         Friend ReadOnly Property PostalCodeColumn As DataColumn
  182.             Get
  183.                 Return Me.columnPostalCode
  184.             End Get
  185.         End Property
  186.         
  187.         Friend ReadOnly Property CountryColumn As DataColumn
  188.             Get
  189.                 Return Me.columnCountry
  190.             End Get
  191.         End Property
  192.         
  193.         Friend ReadOnly Property PhoneColumn As DataColumn
  194.             Get
  195.                 Return Me.columnPhone
  196.             End Get
  197.         End Property
  198.         
  199.         Friend ReadOnly Property FaxColumn As DataColumn
  200.             Get
  201.                 Return Me.columnFax
  202.             End Get
  203.         End Property
  204.         
  205.         Public Default ReadOnly Property Item(ByVal index As Integer) As CustomersRow
  206.             Get
  207.                 Return CType(Me.Rows(index),CustomersRow)
  208.             End Get
  209.         End Property
  210.         
  211.         Public Event CustomersRowChanged As CustomersRowChangeEventHandler
  212.         
  213.         Public Event CustomersRowChanging As CustomersRowChangeEventHandler
  214.         
  215.         Public Event CustomersRowDeleted As CustomersRowChangeEventHandler
  216.         
  217.         Public Event CustomersRowDeleting As CustomersRowChangeEventHandler
  218.         
  219.         Public Overloads Sub AddCustomersRow(ByVal row As CustomersRow)
  220.             Me.Rows.Add(row)
  221.         End Sub
  222.         
  223.         Public Overloads Function AddCustomersRow(ByVal CustomerID As String, ByVal CompanyName As String, ByVal ContactName As String, ByVal ContactTitle As String, ByVal Address As String, ByVal City As String, ByVal _Region As String, ByVal PostalCode As String, ByVal Country As String, ByVal Phone As String, ByVal Fax As String) As CustomersRow
  224.             Dim rowCustomersRow As CustomersRow = CType(Me.NewRow,CustomersRow)
  225.             rowCustomersRow.ItemArray = New Object() {CustomerID, CompanyName, ContactName, ContactTitle, Address, City, _Region, PostalCode, Country, Phone, Fax}
  226.             Me.Rows.Add(rowCustomersRow)
  227.             Return rowCustomersRow
  228.         End Function
  229.         
  230.         Public Function FindByCustomerID(ByVal CustomerID As String) As CustomersRow
  231.             Return CType(Me.Rows.Find(New Object() {CustomerID}),CustomersRow)
  232.         End Function
  233.         
  234.         Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
  235.             Return Me.Rows.GetEnumerator
  236.         End Function
  237.         
  238.         Private Sub InitClass()
  239.             Me.columnCustomerID = New DataColumn("CustomerID", GetType(System.String), "", System.Data.MappingType.Element)
  240.             Me.columnCustomerID.AllowDBNull = false
  241.             Me.columnCustomerID.Unique = true
  242.             Me.Columns.Add(Me.columnCustomerID)
  243.             Me.columnCompanyName = New DataColumn("CompanyName", GetType(System.String), "", System.Data.MappingType.Element)
  244.             Me.columnCompanyName.AllowDBNull = false
  245.             Me.Columns.Add(Me.columnCompanyName)
  246.             Me.columnContactName = New DataColumn("ContactName", GetType(System.String), "", System.Data.MappingType.Element)
  247.             Me.Columns.Add(Me.columnContactName)
  248.             Me.columnContactTitle = New DataColumn("ContactTitle", GetType(System.String), "", System.Data.MappingType.Element)
  249.             Me.Columns.Add(Me.columnContactTitle)
  250.             Me.columnAddress = New DataColumn("Address", GetType(System.String), "", System.Data.MappingType.Element)
  251.             Me.Columns.Add(Me.columnAddress)
  252.             Me.columnCity = New DataColumn("City", GetType(System.String), "", System.Data.MappingType.Element)
  253.             Me.Columns.Add(Me.columnCity)
  254.             Me.column_Region = New DataColumn("Region", GetType(System.String), "", System.Data.MappingType.Element)
  255.             Me.Columns.Add(Me.column_Region)
  256.             Me.columnPostalCode = New DataColumn("PostalCode", GetType(System.String), "", System.Data.MappingType.Element)
  257.             Me.Columns.Add(Me.columnPostalCode)
  258.             Me.columnCountry = New DataColumn("Country", GetType(System.String), "", System.Data.MappingType.Element)
  259.             Me.Columns.Add(Me.columnCountry)
  260.             Me.columnPhone = New DataColumn("Phone", GetType(System.String), "", System.Data.MappingType.Element)
  261.             Me.Columns.Add(Me.columnPhone)
  262.             Me.columnFax = New DataColumn("Fax", GetType(System.String), "", System.Data.MappingType.Element)
  263.             Me.Columns.Add(Me.columnFax)
  264.             Me.PrimaryKey = New DataColumn() {Me.columnCustomerID}
  265.         End Sub
  266.         
  267.         Public Function NewCustomersRow() As CustomersRow
  268.             Return CType(Me.NewRow,CustomersRow)
  269.         End Function
  270.         
  271.         Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
  272.             'We need to ensure that all Rows in the tabled are typed rows.
  273.             'Table calls newRow whenever it needs to create a row.
  274.             'So the following conditions are covered by Row newRow(Record record)
  275.             '* Cursor calls table.addRecord(record) 
  276.             '* table.addRow(object[] values) calls newRow(record)    
  277.             Return New CustomersRow(builder)
  278.         End Function
  279.         
  280.         Protected Overrides Function GetRowType() As System.Type
  281.             Return GetType(CustomersRow)
  282.         End Function
  283.         
  284.         Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
  285.             MyBase.OnRowChanged(e)
  286.             If (Not (Me.CustomersRowChangedEvent) Is Nothing) Then
  287.                 RaiseEvent CustomersRowChanged(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
  288.             End If
  289.         End Sub
  290.         
  291.         Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
  292.             MyBase.OnRowChanging(e)
  293.             If (Not (Me.CustomersRowChangingEvent) Is Nothing) Then
  294.                 RaiseEvent CustomersRowChanging(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
  295.             End If
  296.         End Sub
  297.         
  298.         Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
  299.             MyBase.OnRowDeleted(e)
  300.             If (Not (Me.CustomersRowDeletedEvent) Is Nothing) Then
  301.                 RaiseEvent CustomersRowDeleted(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
  302.             End If
  303.         End Sub
  304.         
  305.         Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
  306.             MyBase.OnRowDeleting(e)
  307.             If (Not (Me.CustomersRowDeletingEvent) Is Nothing) Then
  308.                 RaiseEvent CustomersRowDeleting(Me, New CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
  309.             End If
  310.         End Sub
  311.         
  312.         Public Sub RemoveCustomersRow(ByVal row As CustomersRow)
  313.             Me.Rows.Remove(row)
  314.         End Sub
  315.     End Class
  316.     
  317.     Public Class CustomersRow
  318.         Inherits DataRow
  319.         
  320.         Private tableCustomers As CustomersDataTable
  321.         
  322.         Friend Sub New(ByVal rb As DataRowBuilder)
  323.             MyBase.New(rb)
  324.             Me.tableCustomers = CType(Me.Table,CustomersDataTable)
  325.         End Sub
  326.         
  327.         Public Property CustomerID As String
  328.             Get
  329.                 Return CType(Me(Me.tableCustomers.CustomerIDColumn),String)
  330.             End Get
  331.             Set
  332.                 Me(Me.tableCustomers.CustomerIDColumn) = value
  333.             End Set
  334.         End Property
  335.         
  336.         Public Property CompanyName As String
  337.             Get
  338.                 Return CType(Me(Me.tableCustomers.CompanyNameColumn),String)
  339.             End Get
  340.             Set
  341.                 Me(Me.tableCustomers.CompanyNameColumn) = value
  342.             End Set
  343.         End Property
  344.         
  345.         Public Property ContactName As String
  346.             Get
  347.                 Try 
  348.                     Return CType(Me(Me.tableCustomers.ContactNameColumn),String)
  349.                 Catch e As InvalidCastException
  350.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  351.                 End Try
  352.             End Get
  353.             Set
  354.                 Me(Me.tableCustomers.ContactNameColumn) = value
  355.             End Set
  356.         End Property
  357.         
  358.         Public Property ContactTitle As String
  359.             Get
  360.                 Try 
  361.                     Return CType(Me(Me.tableCustomers.ContactTitleColumn),String)
  362.                 Catch e As InvalidCastException
  363.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  364.                 End Try
  365.             End Get
  366.             Set
  367.                 Me(Me.tableCustomers.ContactTitleColumn) = value
  368.             End Set
  369.         End Property
  370.         
  371.         Public Property Address As String
  372.             Get
  373.                 Try 
  374.                     Return CType(Me(Me.tableCustomers.AddressColumn),String)
  375.                 Catch e As InvalidCastException
  376.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  377.                 End Try
  378.             End Get
  379.             Set
  380.                 Me(Me.tableCustomers.AddressColumn) = value
  381.             End Set
  382.         End Property
  383.         
  384.         Public Property City As String
  385.             Get
  386.                 Try 
  387.                     Return CType(Me(Me.tableCustomers.CityColumn),String)
  388.                 Catch e As InvalidCastException
  389.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  390.                 End Try
  391.             End Get
  392.             Set
  393.                 Me(Me.tableCustomers.CityColumn) = value
  394.             End Set
  395.         End Property
  396.         
  397.         Public Property _Region As String
  398.             Get
  399.                 Try 
  400.                     Return CType(Me(Me.tableCustomers._RegionColumn),String)
  401.                 Catch e As InvalidCastException
  402.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  403.                 End Try
  404.             End Get
  405.             Set
  406.                 Me(Me.tableCustomers._RegionColumn) = value
  407.             End Set
  408.         End Property
  409.         
  410.         Public Property PostalCode As String
  411.             Get
  412.                 Try 
  413.                     Return CType(Me(Me.tableCustomers.PostalCodeColumn),String)
  414.                 Catch e As InvalidCastException
  415.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  416.                 End Try
  417.             End Get
  418.             Set
  419.                 Me(Me.tableCustomers.PostalCodeColumn) = value
  420.             End Set
  421.         End Property
  422.         
  423.         Public Property Country As String
  424.             Get
  425.                 Try 
  426.                     Return CType(Me(Me.tableCustomers.CountryColumn),String)
  427.                 Catch e As InvalidCastException
  428.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  429.                 End Try
  430.             End Get
  431.             Set
  432.                 Me(Me.tableCustomers.CountryColumn) = value
  433.             End Set
  434.         End Property
  435.         
  436.         Public Property Phone As String
  437.             Get
  438.                 Try 
  439.                     Return CType(Me(Me.tableCustomers.PhoneColumn),String)
  440.                 Catch e As InvalidCastException
  441.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  442.                 End Try
  443.             End Get
  444.             Set
  445.                 Me(Me.tableCustomers.PhoneColumn) = value
  446.             End Set
  447.         End Property
  448.         
  449.         Public Property Fax As String
  450.             Get
  451.                 Try 
  452.                     Return CType(Me(Me.tableCustomers.FaxColumn),String)
  453.                 Catch e As InvalidCastException
  454.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  455.                 End Try
  456.             End Get
  457.             Set
  458.                 Me(Me.tableCustomers.FaxColumn) = value
  459.             End Set
  460.         End Property
  461.         
  462.         Public Function IsContactNameNull() As Boolean
  463.             Return Me.IsNull(Me.tableCustomers.ContactNameColumn)
  464.         End Function
  465.         
  466.         Public Sub SetContactNameNull()
  467.             Me(Me.tableCustomers.ContactNameColumn) = System.Convert.DBNull
  468.         End Sub
  469.         
  470.         Public Function IsContactTitleNull() As Boolean
  471.             Return Me.IsNull(Me.tableCustomers.ContactTitleColumn)
  472.         End Function
  473.         
  474.         Public Sub SetContactTitleNull()
  475.             Me(Me.tableCustomers.ContactTitleColumn) = System.Convert.DBNull
  476.         End Sub
  477.         
  478.         Public Function IsAddressNull() As Boolean
  479.             Return Me.IsNull(Me.tableCustomers.AddressColumn)
  480.         End Function
  481.         
  482.         Public Sub SetAddressNull()
  483.             Me(Me.tableCustomers.AddressColumn) = System.Convert.DBNull
  484.         End Sub
  485.         
  486.         Public Function IsCityNull() As Boolean
  487.             Return Me.IsNull(Me.tableCustomers.CityColumn)
  488.         End Function
  489.         
  490.         Public Sub SetCityNull()
  491.             Me(Me.tableCustomers.CityColumn) = System.Convert.DBNull
  492.         End Sub
  493.         
  494.         Public Function Is_RegionNull() As Boolean
  495.             Return Me.IsNull(Me.tableCustomers._RegionColumn)
  496.         End Function
  497.         
  498.         Public Sub Set_RegionNull()
  499.             Me(Me.tableCustomers._RegionColumn) = System.Convert.DBNull
  500.         End Sub
  501.         
  502.         Public Function IsPostalCodeNull() As Boolean
  503.             Return Me.IsNull(Me.tableCustomers.PostalCodeColumn)
  504.         End Function
  505.         
  506.         Public Sub SetPostalCodeNull()
  507.             Me(Me.tableCustomers.PostalCodeColumn) = System.Convert.DBNull
  508.         End Sub
  509.         
  510.         Public Function IsCountryNull() As Boolean
  511.             Return Me.IsNull(Me.tableCustomers.CountryColumn)
  512.         End Function
  513.         
  514.         Public Sub SetCountryNull()
  515.             Me(Me.tableCustomers.CountryColumn) = System.Convert.DBNull
  516.         End Sub
  517.         
  518.         Public Function IsPhoneNull() As Boolean
  519.             Return Me.IsNull(Me.tableCustomers.PhoneColumn)
  520.         End Function
  521.         
  522.         Public Sub SetPhoneNull()
  523.             Me(Me.tableCustomers.PhoneColumn) = System.Convert.DBNull
  524.         End Sub
  525.         
  526.         Public Function IsFaxNull() As Boolean
  527.             Return Me.IsNull(Me.tableCustomers.FaxColumn)
  528.         End Function
  529.         
  530.         Public Sub SetFaxNull()
  531.             Me(Me.tableCustomers.FaxColumn) = System.Convert.DBNull
  532.         End Sub
  533.         
  534.         Public Function GetOrdersRows() As OrdersRow()
  535.             Return CType(Me.GetChildRows(Me.Table.ChildRelations("CustomersOrders")),OrdersRow())
  536.         End Function
  537.     End Class
  538.     
  539.     Public Class CustomersRowChangeEvent
  540.         Inherits EventArgs
  541.         
  542.         Private eventRow As CustomersRow
  543.         
  544.         Private eventAction As System.Data.DataRowAction
  545.         
  546.         Public Sub New(ByVal row As CustomersRow, ByVal action As DataRowAction)
  547.             MyBase.New
  548.             Me.eventRow = row
  549.             Me.eventAction = action
  550.         End Sub
  551.         
  552.         Public ReadOnly Property Row As CustomersRow
  553.             Get
  554.                 Return Me.eventRow
  555.             End Get
  556.         End Property
  557.         
  558.         Public ReadOnly Property Action As DataRowAction
  559.             Get
  560.                 Return Me.eventAction
  561.             End Get
  562.         End Property
  563.     End Class
  564.     
  565.     Public Class OrdersDataTable
  566.         Inherits DataTable
  567.         Implements System.Collections.IEnumerable
  568.         
  569.         Private columnOrderID As DataColumn
  570.         
  571.         Private columnCustomerID As DataColumn
  572.         
  573.         Private columnEmployeeID As DataColumn
  574.         
  575.         Private columnOrderDate As DataColumn
  576.         
  577.         Private columnRequiredDate As DataColumn
  578.         
  579.         Private columnShippedDate As DataColumn
  580.         
  581.         Private columnShipVia As DataColumn
  582.         
  583.         Private columnFreight As DataColumn
  584.         
  585.         Private columnShipName As DataColumn
  586.         
  587.         Private columnShipAddress As DataColumn
  588.         
  589.         Private columnShipCity As DataColumn
  590.         
  591.         Private columnShipRegion As DataColumn
  592.         
  593.         Private columnShipPostalCode As DataColumn
  594.         
  595.         Private columnShipCountry As DataColumn
  596.         
  597.         Friend Sub New()
  598.             MyBase.New("Orders")
  599.             Me.InitClass
  600.         End Sub
  601.         
  602.         <System.ComponentModel.Browsable(false)>  _
  603.         Public ReadOnly Property Count As Integer
  604.             Get
  605.                 Return Me.Rows.Count
  606.             End Get
  607.         End Property
  608.         
  609.         Friend ReadOnly Property OrderIDColumn As DataColumn
  610.             Get
  611.                 Return Me.columnOrderID
  612.             End Get
  613.         End Property
  614.         
  615.         Friend ReadOnly Property CustomerIDColumn As DataColumn
  616.             Get
  617.                 Return Me.columnCustomerID
  618.             End Get
  619.         End Property
  620.         
  621.         Friend ReadOnly Property EmployeeIDColumn As DataColumn
  622.             Get
  623.                 Return Me.columnEmployeeID
  624.             End Get
  625.         End Property
  626.         
  627.         Friend ReadOnly Property OrderDateColumn As DataColumn
  628.             Get
  629.                 Return Me.columnOrderDate
  630.             End Get
  631.         End Property
  632.         
  633.         Friend ReadOnly Property RequiredDateColumn As DataColumn
  634.             Get
  635.                 Return Me.columnRequiredDate
  636.             End Get
  637.         End Property
  638.         
  639.         Friend ReadOnly Property ShippedDateColumn As DataColumn
  640.             Get
  641.                 Return Me.columnShippedDate
  642.             End Get
  643.         End Property
  644.         
  645.         Friend ReadOnly Property ShipViaColumn As DataColumn
  646.             Get
  647.                 Return Me.columnShipVia
  648.             End Get
  649.         End Property
  650.         
  651.         Friend ReadOnly Property FreightColumn As DataColumn
  652.             Get
  653.                 Return Me.columnFreight
  654.             End Get
  655.         End Property
  656.         
  657.         Friend ReadOnly Property ShipNameColumn As DataColumn
  658.             Get
  659.                 Return Me.columnShipName
  660.             End Get
  661.         End Property
  662.         
  663.         Friend ReadOnly Property ShipAddressColumn As DataColumn
  664.             Get
  665.                 Return Me.columnShipAddress
  666.             End Get
  667.         End Property
  668.         
  669.         Friend ReadOnly Property ShipCityColumn As DataColumn
  670.             Get
  671.                 Return Me.columnShipCity
  672.             End Get
  673.         End Property
  674.         
  675.         Friend ReadOnly Property ShipRegionColumn As DataColumn
  676.             Get
  677.                 Return Me.columnShipRegion
  678.             End Get
  679.         End Property
  680.         
  681.         Friend ReadOnly Property ShipPostalCodeColumn As DataColumn
  682.             Get
  683.                 Return Me.columnShipPostalCode
  684.             End Get
  685.         End Property
  686.         
  687.         Friend ReadOnly Property ShipCountryColumn As DataColumn
  688.             Get
  689.                 Return Me.columnShipCountry
  690.             End Get
  691.         End Property
  692.         
  693.         Public Default ReadOnly Property Item(ByVal index As Integer) As OrdersRow
  694.             Get
  695.                 Return CType(Me.Rows(index),OrdersRow)
  696.             End Get
  697.         End Property
  698.         
  699.         Public Event OrdersRowChanged As OrdersRowChangeEventHandler
  700.         
  701.         Public Event OrdersRowChanging As OrdersRowChangeEventHandler
  702.         
  703.         Public Event OrdersRowDeleted As OrdersRowChangeEventHandler
  704.         
  705.         Public Event OrdersRowDeleting As OrdersRowChangeEventHandler
  706.         
  707.         Public Overloads Sub AddOrdersRow(ByVal row As OrdersRow)
  708.             Me.Rows.Add(row)
  709.         End Sub
  710.         
  711.         Public Overloads Function AddOrdersRow(ByVal parentCustomersRowByCustomersOrders As CustomersRow, ByVal EmployeeID As Integer, ByVal OrderDate As Date, ByVal RequiredDate As Date, ByVal ShippedDate As Date, ByVal ShipVia As Integer, ByVal Freight As Decimal, ByVal ShipName As String, ByVal ShipAddress As String, ByVal ShipCity As String, ByVal ShipRegion As String, ByVal ShipPostalCode As String, ByVal ShipCountry As String) As OrdersRow
  712.             Dim rowOrdersRow As OrdersRow = CType(Me.NewRow,OrdersRow)
  713.             rowOrdersRow.ItemArray = New Object() {Nothing, parentCustomersRowByCustomersOrders(0), EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry}
  714.             Me.Rows.Add(rowOrdersRow)
  715.             Return rowOrdersRow
  716.         End Function
  717.         
  718.         Public Function FindByOrderID(ByVal OrderID As Integer) As OrdersRow
  719.             Return CType(Me.Rows.Find(New Object() {OrderID}),OrdersRow)
  720.         End Function
  721.         
  722.         Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
  723.             Return Me.Rows.GetEnumerator
  724.         End Function
  725.         
  726.         Private Sub InitClass()
  727.             Me.columnOrderID = New DataColumn("OrderID", GetType(System.Int32), "", System.Data.MappingType.Element)
  728.             Me.columnOrderID.AutoIncrement = true
  729.             Me.columnOrderID.AllowDBNull = false
  730.             Me.columnOrderID.ReadOnly = true
  731.             Me.columnOrderID.Unique = true
  732.             Me.Columns.Add(Me.columnOrderID)
  733.             Me.columnCustomerID = New DataColumn("CustomerID", GetType(System.String), "", System.Data.MappingType.Element)
  734.             Me.Columns.Add(Me.columnCustomerID)
  735.             Me.columnEmployeeID = New DataColumn("EmployeeID", GetType(System.Int32), "", System.Data.MappingType.Element)
  736.             Me.Columns.Add(Me.columnEmployeeID)
  737.             Me.columnOrderDate = New DataColumn("OrderDate", GetType(System.DateTime), "", System.Data.MappingType.Element)
  738.             Me.Columns.Add(Me.columnOrderDate)
  739.             Me.columnRequiredDate = New DataColumn("RequiredDate", GetType(System.DateTime), "", System.Data.MappingType.Element)
  740.             Me.Columns.Add(Me.columnRequiredDate)
  741.             Me.columnShippedDate = New DataColumn("ShippedDate", GetType(System.DateTime), "", System.Data.MappingType.Element)
  742.             Me.Columns.Add(Me.columnShippedDate)
  743.             Me.columnShipVia = New DataColumn("ShipVia", GetType(System.Int32), "", System.Data.MappingType.Element)
  744.             Me.Columns.Add(Me.columnShipVia)
  745.             Me.columnFreight = New DataColumn("Freight", GetType(System.Decimal), "", System.Data.MappingType.Element)
  746.             Me.Columns.Add(Me.columnFreight)
  747.             Me.columnShipName = New DataColumn("ShipName", GetType(System.String), "", System.Data.MappingType.Element)
  748.             Me.Columns.Add(Me.columnShipName)
  749.             Me.columnShipAddress = New DataColumn("ShipAddress", GetType(System.String), "", System.Data.MappingType.Element)
  750.             Me.Columns.Add(Me.columnShipAddress)
  751.             Me.columnShipCity = New DataColumn("ShipCity", GetType(System.String), "", System.Data.MappingType.Element)
  752.             Me.Columns.Add(Me.columnShipCity)
  753.             Me.columnShipRegion = New DataColumn("ShipRegion", GetType(System.String), "", System.Data.MappingType.Element)
  754.             Me.Columns.Add(Me.columnShipRegion)
  755.             Me.columnShipPostalCode = New DataColumn("ShipPostalCode", GetType(System.String), "", System.Data.MappingType.Element)
  756.             Me.Columns.Add(Me.columnShipPostalCode)
  757.             Me.columnShipCountry = New DataColumn("ShipCountry", GetType(System.String), "", System.Data.MappingType.Element)
  758.             Me.Columns.Add(Me.columnShipCountry)
  759.             Me.PrimaryKey = New DataColumn() {Me.columnOrderID}
  760.         End Sub
  761.         
  762.         Public Function NewOrdersRow() As OrdersRow
  763.             Return CType(Me.NewRow,OrdersRow)
  764.         End Function
  765.         
  766.         Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
  767.             'We need to ensure that all Rows in the tabled are typed rows.
  768.             'Table calls newRow whenever it needs to create a row.
  769.             'So the following conditions are covered by Row newRow(Record record)
  770.             '* Cursor calls table.addRecord(record) 
  771.             '* table.addRow(object[] values) calls newRow(record)    
  772.             Return New OrdersRow(builder)
  773.         End Function
  774.         
  775.         Protected Overrides Function GetRowType() As System.Type
  776.             Return GetType(OrdersRow)
  777.         End Function
  778.         
  779.         Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
  780.             MyBase.OnRowChanged(e)
  781.             If (Not (Me.OrdersRowChangedEvent) Is Nothing) Then
  782.                 RaiseEvent OrdersRowChanged(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action))
  783.             End If
  784.         End Sub
  785.         
  786.         Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
  787.             MyBase.OnRowChanging(e)
  788.             If (Not (Me.OrdersRowChangingEvent) Is Nothing) Then
  789.                 RaiseEvent OrdersRowChanging(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action))
  790.             End If
  791.         End Sub
  792.         
  793.         Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
  794.             MyBase.OnRowDeleted(e)
  795.             If (Not (Me.OrdersRowDeletedEvent) Is Nothing) Then
  796.                 RaiseEvent OrdersRowDeleted(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action))
  797.             End If
  798.         End Sub
  799.         
  800.         Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
  801.             MyBase.OnRowDeleting(e)
  802.             If (Not (Me.OrdersRowDeletingEvent) Is Nothing) Then
  803.                 RaiseEvent OrdersRowDeleting(Me, New OrdersRowChangeEvent(CType(e.Row,OrdersRow), e.Action))
  804.             End If
  805.         End Sub
  806.         
  807.         Public Sub RemoveOrdersRow(ByVal row As OrdersRow)
  808.             Me.Rows.Remove(row)
  809.         End Sub
  810.     End Class
  811.     
  812.     Public Class OrdersRow
  813.         Inherits DataRow
  814.         
  815.         Private tableOrders As OrdersDataTable
  816.         
  817.         Friend Sub New(ByVal rb As DataRowBuilder)
  818.             MyBase.New(rb)
  819.             Me.tableOrders = CType(Me.Table,OrdersDataTable)
  820.         End Sub
  821.         
  822.         Public Property OrderID As Integer
  823.             Get
  824.                 Return CType(Me(Me.tableOrders.OrderIDColumn),Integer)
  825.             End Get
  826.             Set
  827.                 Me(Me.tableOrders.OrderIDColumn) = value
  828.             End Set
  829.         End Property
  830.         
  831.         Public Property CustomerID As String
  832.             Get
  833.                 Try 
  834.                     Return CType(Me(Me.tableOrders.CustomerIDColumn),String)
  835.                 Catch e As InvalidCastException
  836.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  837.                 End Try
  838.             End Get
  839.             Set
  840.                 Me(Me.tableOrders.CustomerIDColumn) = value
  841.             End Set
  842.         End Property
  843.         
  844.         Public Property EmployeeID As Integer
  845.             Get
  846.                 Try 
  847.                     Return CType(Me(Me.tableOrders.EmployeeIDColumn),Integer)
  848.                 Catch e As InvalidCastException
  849.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  850.                 End Try
  851.             End Get
  852.             Set
  853.                 Me(Me.tableOrders.EmployeeIDColumn) = value
  854.             End Set
  855.         End Property
  856.         
  857.         Public Property OrderDate As Date
  858.             Get
  859.                 Try 
  860.                     Return CType(Me(Me.tableOrders.OrderDateColumn),Date)
  861.                 Catch e As InvalidCastException
  862.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  863.                 End Try
  864.             End Get
  865.             Set
  866.                 Me(Me.tableOrders.OrderDateColumn) = value
  867.             End Set
  868.         End Property
  869.         
  870.         Public Property RequiredDate As Date
  871.             Get
  872.                 Try 
  873.                     Return CType(Me(Me.tableOrders.RequiredDateColumn),Date)
  874.                 Catch e As InvalidCastException
  875.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  876.                 End Try
  877.             End Get
  878.             Set
  879.                 Me(Me.tableOrders.RequiredDateColumn) = value
  880.             End Set
  881.         End Property
  882.         
  883.         Public Property ShippedDate As Date
  884.             Get
  885.                 Try 
  886.                     Return CType(Me(Me.tableOrders.ShippedDateColumn),Date)
  887.                 Catch e As InvalidCastException
  888.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  889.                 End Try
  890.             End Get
  891.             Set
  892.                 Me(Me.tableOrders.ShippedDateColumn) = value
  893.             End Set
  894.         End Property
  895.         
  896.         Public Property ShipVia As Integer
  897.             Get
  898.                 Try 
  899.                     Return CType(Me(Me.tableOrders.ShipViaColumn),Integer)
  900.                 Catch e As InvalidCastException
  901.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  902.                 End Try
  903.             End Get
  904.             Set
  905.                 Me(Me.tableOrders.ShipViaColumn) = value
  906.             End Set
  907.         End Property
  908.         
  909.         Public Property Freight As Decimal
  910.             Get
  911.                 Try 
  912.                     Return CType(Me(Me.tableOrders.FreightColumn),Decimal)
  913.                 Catch e As InvalidCastException
  914.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  915.                 End Try
  916.             End Get
  917.             Set
  918.                 Me(Me.tableOrders.FreightColumn) = value
  919.             End Set
  920.         End Property
  921.         
  922.         Public Property ShipName As String
  923.             Get
  924.                 Try 
  925.                     Return CType(Me(Me.tableOrders.ShipNameColumn),String)
  926.                 Catch e As InvalidCastException
  927.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  928.                 End Try
  929.             End Get
  930.             Set
  931.                 Me(Me.tableOrders.ShipNameColumn) = value
  932.             End Set
  933.         End Property
  934.         
  935.         Public Property ShipAddress As String
  936.             Get
  937.                 Try 
  938.                     Return CType(Me(Me.tableOrders.ShipAddressColumn),String)
  939.                 Catch e As InvalidCastException
  940.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  941.                 End Try
  942.             End Get
  943.             Set
  944.                 Me(Me.tableOrders.ShipAddressColumn) = value
  945.             End Set
  946.         End Property
  947.         
  948.         Public Property ShipCity As String
  949.             Get
  950.                 Try 
  951.                     Return CType(Me(Me.tableOrders.ShipCityColumn),String)
  952.                 Catch e As InvalidCastException
  953.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  954.                 End Try
  955.             End Get
  956.             Set
  957.                 Me(Me.tableOrders.ShipCityColumn) = value
  958.             End Set
  959.         End Property
  960.         
  961.         Public Property ShipRegion As String
  962.             Get
  963.                 Try 
  964.                     Return CType(Me(Me.tableOrders.ShipRegionColumn),String)
  965.                 Catch e As InvalidCastException
  966.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  967.                 End Try
  968.             End Get
  969.             Set
  970.                 Me(Me.tableOrders.ShipRegionColumn) = value
  971.             End Set
  972.         End Property
  973.         
  974.         Public Property ShipPostalCode As String
  975.             Get
  976.                 Try 
  977.                     Return CType(Me(Me.tableOrders.ShipPostalCodeColumn),String)
  978.                 Catch e As InvalidCastException
  979.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  980.                 End Try
  981.             End Get
  982.             Set
  983.                 Me(Me.tableOrders.ShipPostalCodeColumn) = value
  984.             End Set
  985.         End Property
  986.         
  987.         Public Property ShipCountry As String
  988.             Get
  989.                 Try 
  990.                     Return CType(Me(Me.tableOrders.ShipCountryColumn),String)
  991.                 Catch e As InvalidCastException
  992.                     Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
  993.                 End Try
  994.             End Get
  995.             Set
  996.                 Me(Me.tableOrders.ShipCountryColumn) = value
  997.             End Set
  998.         End Property
  999.         
  1000.         Public Property CustomersRow As CustomersRow
  1001.             Get
  1002.                 Return CType(Me.GetParentRow(Me.Table.ParentRelations("CustomersOrders")),CustomersRow)
  1003.             End Get
  1004.             Set
  1005.                 Me.SetParentRow(value, Me.Table.ParentRelations("CustomersOrders"))
  1006.             End Set
  1007.         End Property
  1008.         
  1009.         Public Function IsCustomerIDNull() As Boolean
  1010.             Return Me.IsNull(Me.tableOrders.CustomerIDColumn)
  1011.         End Function
  1012.         
  1013.         Public Sub SetCustomerIDNull()
  1014.             Me(Me.tableOrders.CustomerIDColumn) = System.Convert.DBNull
  1015.         End Sub
  1016.         
  1017.         Public Function IsEmployeeIDNull() As Boolean
  1018.             Return Me.IsNull(Me.tableOrders.EmployeeIDColumn)
  1019.         End Function
  1020.         
  1021.         Public Sub SetEmployeeIDNull()
  1022.             Me(Me.tableOrders.EmployeeIDColumn) = System.Convert.DBNull
  1023.         End Sub
  1024.         
  1025.         Public Function IsOrderDateNull() As Boolean
  1026.             Return Me.IsNull(Me.tableOrders.OrderDateColumn)
  1027.         End Function
  1028.         
  1029.         Public Sub SetOrderDateNull()
  1030.             Me(Me.tableOrders.OrderDateColumn) = System.Convert.DBNull
  1031.         End Sub
  1032.         
  1033.         Public Function IsRequiredDateNull() As Boolean
  1034.             Return Me.IsNull(Me.tableOrders.RequiredDateColumn)
  1035.         End Function
  1036.         
  1037.         Public Sub SetRequiredDateNull()
  1038.             Me(Me.tableOrders.RequiredDateColumn) = System.Convert.DBNull
  1039.         End Sub
  1040.         
  1041.         Public Function IsShippedDateNull() As Boolean
  1042.             Return Me.IsNull(Me.tableOrders.ShippedDateColumn)
  1043.         End Function
  1044.         
  1045.         Public Sub SetShippedDateNull()
  1046.             Me(Me.tableOrders.ShippedDateColumn) = System.Convert.DBNull
  1047.         End Sub
  1048.         
  1049.         Public Function IsShipViaNull() As Boolean
  1050.             Return Me.IsNull(Me.tableOrders.ShipViaColumn)
  1051.         End Function
  1052.         
  1053.         Public Sub SetShipViaNull()
  1054.             Me(Me.tableOrders.ShipViaColumn) = System.Convert.DBNull
  1055.         End Sub
  1056.         
  1057.         Public Function IsFreightNull() As Boolean
  1058.             Return Me.IsNull(Me.tableOrders.FreightColumn)
  1059.         End Function
  1060.         
  1061.         Public Sub SetFreightNull()
  1062.             Me(Me.tableOrders.FreightColumn) = System.Convert.DBNull
  1063.         End Sub
  1064.         
  1065.         Public Function IsShipNameNull() As Boolean
  1066.             Return Me.IsNull(Me.tableOrders.ShipNameColumn)
  1067.         End Function
  1068.         
  1069.         Public Sub SetShipNameNull()
  1070.             Me(Me.tableOrders.ShipNameColumn) = System.Convert.DBNull
  1071.         End Sub
  1072.         
  1073.         Public Function IsShipAddressNull() As Boolean
  1074.             Return Me.IsNull(Me.tableOrders.ShipAddressColumn)
  1075.         End Function
  1076.         
  1077.         Public Sub SetShipAddressNull()
  1078.             Me(Me.tableOrders.ShipAddressColumn) = System.Convert.DBNull
  1079.         End Sub
  1080.         
  1081.         Public Function IsShipCityNull() As Boolean
  1082.             Return Me.IsNull(Me.tableOrders.ShipCityColumn)
  1083.         End Function
  1084.         
  1085.         Public Sub SetShipCityNull()
  1086.             Me(Me.tableOrders.ShipCityColumn) = System.Convert.DBNull
  1087.         End Sub
  1088.         
  1089.         Public Function IsShipRegionNull() As Boolean
  1090.             Return Me.IsNull(Me.tableOrders.ShipRegionColumn)
  1091.         End Function
  1092.         
  1093.         Public Sub SetShipRegionNull()
  1094.             Me(Me.tableOrders.ShipRegionColumn) = System.Convert.DBNull
  1095.         End Sub
  1096.         
  1097.         Public Function IsShipPostalCodeNull() As Boolean
  1098.             Return Me.IsNull(Me.tableOrders.ShipPostalCodeColumn)
  1099.         End Function
  1100.         
  1101.         Public Sub SetShipPostalCodeNull()
  1102.             Me(Me.tableOrders.ShipPostalCodeColumn) = System.Convert.DBNull
  1103.         End Sub
  1104.         
  1105.         Public Function IsShipCountryNull() As Boolean
  1106.             Return Me.IsNull(Me.tableOrders.ShipCountryColumn)
  1107.         End Function
  1108.         
  1109.         Public Sub SetShipCountryNull()
  1110.             Me(Me.tableOrders.ShipCountryColumn) = System.Convert.DBNull
  1111.         End Sub
  1112.     End Class
  1113.     
  1114.     Public Class OrdersRowChangeEvent
  1115.         Inherits EventArgs
  1116.         
  1117.         Private eventRow As OrdersRow
  1118.         
  1119.         Private eventAction As System.Data.DataRowAction
  1120.         
  1121.         Public Sub New(ByVal row As OrdersRow, ByVal action As DataRowAction)
  1122.             MyBase.New
  1123.             Me.eventRow = row
  1124.             Me.eventAction = action
  1125.         End Sub
  1126.         
  1127.         Public ReadOnly Property Row As OrdersRow
  1128.             Get
  1129.                 Return Me.eventRow
  1130.             End Get
  1131.         End Property
  1132.         
  1133.         Public ReadOnly Property Action As DataRowAction
  1134.             Get
  1135.                 Return Me.eventAction
  1136.             End Get
  1137.         End Property
  1138.     End Class
  1139. End Class
  1140.