'------------------------------------------------------------------------------
'
' This code was generated by a tool.
' Runtime Version:4.0.30319.18052
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
'
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
'''
'''Represents a strongly typed in-memory cache of data.
'''
_
Partial Public Class EpsonDataSet
Inherits Global.System.Data.DataSet
Private tableKITTING As KITTINGDataTable
Private _schemaSerializationMode As Global.System.Data.SchemaSerializationMode = Global.System.Data.SchemaSerializationMode.IncludeSchema
_
Public Sub New()
MyBase.New
Me.BeginInit
Me.InitClass
Dim schemaChangedHandler As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler
AddHandler MyBase.Relations.CollectionChanged, schemaChangedHandler
Me.EndInit
End Sub
_
Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext)
MyBase.New(info, context, false)
If (Me.IsBinarySerialized(info, context) = true) Then
Me.InitVars(false)
Dim schemaChangedHandler1 As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler Me.Tables.CollectionChanged, schemaChangedHandler1
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler1
Return
End If
Dim strSchema As String = CType(info.GetValue("XmlSchema", GetType(String)),String)
If (Me.DetermineSchemaSerializationMode(info, context) = Global.System.Data.SchemaSerializationMode.IncludeSchema) Then
Dim ds As Global.System.Data.DataSet = New Global.System.Data.DataSet()
ds.ReadXmlSchema(New Global.System.Xml.XmlTextReader(New Global.System.IO.StringReader(strSchema)))
If (Not (ds.Tables("KITTING")) Is Nothing) Then
MyBase.Tables.Add(New KITTINGDataTable(ds.Tables("KITTING")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, Global.System.Data.MissingSchemaAction.Add)
Me.InitVars
Else
Me.ReadXmlSchema(New Global.System.Xml.XmlTextReader(New Global.System.IO.StringReader(strSchema)))
End If
Me.GetSerializationData(info, context)
Dim schemaChangedHandler As Global.System.ComponentModel.CollectionChangeEventHandler = AddressOf Me.SchemaChanged
AddHandler MyBase.Tables.CollectionChanged, schemaChangedHandler
AddHandler Me.Relations.CollectionChanged, schemaChangedHandler
End Sub
_
Public ReadOnly Property KITTING() As KITTINGDataTable
Get
Return Me.tableKITTING
End Get
End Property
_
Public Overrides Property SchemaSerializationMode() As Global.System.Data.SchemaSerializationMode
Get
Return Me._schemaSerializationMode
End Get
Set
Me._schemaSerializationMode = value
End Set
End Property
_
Public Shadows ReadOnly Property Tables() As Global.System.Data.DataTableCollection
Get
Return MyBase.Tables
End Get
End Property
_
Public Shadows ReadOnly Property Relations() As Global.System.Data.DataRelationCollection
Get
Return MyBase.Relations
End Get
End Property
_
Protected Overrides Sub InitializeDerivedDataSet()
Me.BeginInit
Me.InitClass
Me.EndInit
End Sub
_
Public Overrides Function Clone() As Global.System.Data.DataSet
Dim cln As EpsonDataSet = CType(MyBase.Clone,EpsonDataSet)
cln.InitVars
cln.SchemaSerializationMode = Me.SchemaSerializationMode
Return cln
End Function
_
Protected Overrides Function ShouldSerializeTables() As Boolean
Return false
End Function
_
Protected Overrides Function ShouldSerializeRelations() As Boolean
Return false
End Function
_
Protected Overrides Sub ReadXmlSerializable(ByVal reader As Global.System.Xml.XmlReader)
If (Me.DetermineSchemaSerializationMode(reader) = Global.System.Data.SchemaSerializationMode.IncludeSchema) Then
Me.Reset
Dim ds As Global.System.Data.DataSet = New Global.System.Data.DataSet()
ds.ReadXml(reader)
If (Not (ds.Tables("KITTING")) Is Nothing) Then
MyBase.Tables.Add(New KITTINGDataTable(ds.Tables("KITTING")))
End If
Me.DataSetName = ds.DataSetName
Me.Prefix = ds.Prefix
Me.Namespace = ds.Namespace
Me.Locale = ds.Locale
Me.CaseSensitive = ds.CaseSensitive
Me.EnforceConstraints = ds.EnforceConstraints
Me.Merge(ds, false, Global.System.Data.MissingSchemaAction.Add)
Me.InitVars
Else
Me.ReadXml(reader)
Me.InitVars
End If
End Sub
_
Protected Overrides Function GetSchemaSerializable() As Global.System.Xml.Schema.XmlSchema
Dim stream As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream()
Me.WriteXmlSchema(New Global.System.Xml.XmlTextWriter(stream, Nothing))
stream.Position = 0
Return Global.System.Xml.Schema.XmlSchema.Read(New Global.System.Xml.XmlTextReader(stream), Nothing)
End Function
_
Friend Overloads Sub InitVars()
Me.InitVars(true)
End Sub
_
Friend Overloads Sub InitVars(ByVal initTable As Boolean)
Me.tableKITTING = CType(MyBase.Tables("KITTING"),KITTINGDataTable)
If (initTable = true) Then
If (Not (Me.tableKITTING) Is Nothing) Then
Me.tableKITTING.InitVars
End If
End If
End Sub
_
Private Sub InitClass()
Me.DataSetName = "EpsonDataSet"
Me.Prefix = ""
Me.Namespace = "http://tempuri.org/EpsonDataSet.xsd"
Me.EnforceConstraints = true
Me.SchemaSerializationMode = Global.System.Data.SchemaSerializationMode.IncludeSchema
Me.tableKITTING = New KITTINGDataTable()
MyBase.Tables.Add(Me.tableKITTING)
End Sub
_
Private Function ShouldSerializeKITTING() As Boolean
Return false
End Function
_
Private Sub SchemaChanged(ByVal sender As Object, ByVal e As Global.System.ComponentModel.CollectionChangeEventArgs)
If (e.Action = Global.System.ComponentModel.CollectionChangeAction.Remove) Then
Me.InitVars
End If
End Sub
_
Public Shared Function GetTypedDataSetSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType
Dim ds As EpsonDataSet = New EpsonDataSet()
Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType()
Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence()
Dim any As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny()
any.Namespace = ds.Namespace
sequence.Items.Add(any)
type.Particle = sequence
Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable
If xs.Contains(dsSchema.TargetNamespace) Then
Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream()
Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream()
Try
Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing
dsSchema.Write(s1)
Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator
Do While schemas.MoveNext
schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema)
s2.SetLength(0)
schema.Write(s2)
If (s1.Length = s2.Length) Then
s1.Position = 0
s2.Position = 0
Do While ((s1.Position <> s1.Length) _
AndAlso (s1.ReadByte = s2.ReadByte))
Loop
If (s1.Position = s1.Length) Then
Return type
End If
End If
Loop
Finally
If (Not (s1) Is Nothing) Then
s1.Close
End If
If (Not (s2) Is Nothing) Then
s2.Close
End If
End Try
End If
xs.Add(dsSchema)
Return type
End Function
_
Public Delegate Sub KITTINGRowChangeEventHandler(ByVal sender As Object, ByVal e As KITTINGRowChangeEvent)
'''
'''Represents the strongly named DataTable class.
'''
_
Partial Public Class KITTINGDataTable
Inherits Global.System.Data.DataTable
Implements Global.System.Collections.IEnumerable
Private columnREV As Global.System.Data.DataColumn
Private columnPARTNO As Global.System.Data.DataColumn
Private columnDESC1 As Global.System.Data.DataColumn
Private columnUSAGE As Global.System.Data.DataColumn
Private columnSPQ As Global.System.Data.DataColumn
Private columnOPERATOR As Global.System.Data.DataColumn
Private columnKITTINGDATE As Global.System.Data.DataColumn
Private columnQTY As Global.System.Data.DataColumn
Private columnFEEDER As Global.System.Data.DataColumn
Private columnACCOUNT As Global.System.Data.DataColumn
Private columnMACHINE As Global.System.Data.DataColumn
Private columnMODEL As Global.System.Data.DataColumn
Private columnTYPE As Global.System.Data.DataColumn
Private columnLINE As Global.System.Data.DataColumn
_
Public Sub New()
MyBase.New
Me.TableName = "KITTING"
Me.BeginInit
Me.InitClass
Me.EndInit
End Sub
_
Friend Sub New(ByVal table As Global.System.Data.DataTable)
MyBase.New
Me.TableName = 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
End Sub
_
Protected Sub New(ByVal info As Global.System.Runtime.Serialization.SerializationInfo, ByVal context As Global.System.Runtime.Serialization.StreamingContext)
MyBase.New(info, context)
Me.InitVars
End Sub
_
Public ReadOnly Property REVColumn() As Global.System.Data.DataColumn
Get
Return Me.columnREV
End Get
End Property
_
Public ReadOnly Property PARTNOColumn() As Global.System.Data.DataColumn
Get
Return Me.columnPARTNO
End Get
End Property
_
Public ReadOnly Property DESC1Column() As Global.System.Data.DataColumn
Get
Return Me.columnDESC1
End Get
End Property
_
Public ReadOnly Property USAGEColumn() As Global.System.Data.DataColumn
Get
Return Me.columnUSAGE
End Get
End Property
_
Public ReadOnly Property SPQColumn() As Global.System.Data.DataColumn
Get
Return Me.columnSPQ
End Get
End Property
_
Public ReadOnly Property OPERATORColumn() As Global.System.Data.DataColumn
Get
Return Me.columnOPERATOR
End Get
End Property
_
Public ReadOnly Property KITTINGDATEColumn() As Global.System.Data.DataColumn
Get
Return Me.columnKITTINGDATE
End Get
End Property
_
Public ReadOnly Property QTYColumn() As Global.System.Data.DataColumn
Get
Return Me.columnQTY
End Get
End Property
_
Public ReadOnly Property FEEDERColumn() As Global.System.Data.DataColumn
Get
Return Me.columnFEEDER
End Get
End Property
_
Public ReadOnly Property ACCOUNTColumn() As Global.System.Data.DataColumn
Get
Return Me.columnACCOUNT
End Get
End Property
_
Public ReadOnly Property MACHINEColumn() As Global.System.Data.DataColumn
Get
Return Me.columnMACHINE
End Get
End Property
_
Public ReadOnly Property MODELColumn() As Global.System.Data.DataColumn
Get
Return Me.columnMODEL
End Get
End Property
_
Public ReadOnly Property TYPEColumn() As Global.System.Data.DataColumn
Get
Return Me.columnTYPE
End Get
End Property
_
Public ReadOnly Property LINEColumn() As Global.System.Data.DataColumn
Get
Return Me.columnLINE
End Get
End Property
_
Public ReadOnly Property Count() As Integer
Get
Return Me.Rows.Count
End Get
End Property
_
Public Default ReadOnly Property Item(ByVal index As Integer) As KITTINGRow
Get
Return CType(Me.Rows(index),KITTINGRow)
End Get
End Property
_
Public Event KITTINGRowChanging As KITTINGRowChangeEventHandler
_
Public Event KITTINGRowChanged As KITTINGRowChangeEventHandler
_
Public Event KITTINGRowDeleting As KITTINGRowChangeEventHandler
_
Public Event KITTINGRowDeleted As KITTINGRowChangeEventHandler
_
Public Overloads Sub AddKITTINGRow(ByVal row As KITTINGRow)
Me.Rows.Add(row)
End Sub
_
Public Overloads Function AddKITTINGRow(ByVal REV As String, ByVal PARTNO As String, ByVal DESC1 As String, ByVal USAGE As Double, ByVal SPQ As Double, ByVal _OPERATOR As String, ByVal KITTINGDATE As Date, ByVal QTY As Double, ByVal FEEDER As String, ByVal ACCOUNT As String, ByVal MACHINE As String, ByVal MODEL As String, ByVal TYPE As String, ByVal LINE As String) As KITTINGRow
Dim rowKITTINGRow As KITTINGRow = CType(Me.NewRow,KITTINGRow)
Dim columnValuesArray() As Object = New Object() {REV, PARTNO, DESC1, USAGE, SPQ, _OPERATOR, KITTINGDATE, QTY, FEEDER, ACCOUNT, MACHINE, MODEL, TYPE, LINE}
rowKITTINGRow.ItemArray = columnValuesArray
Me.Rows.Add(rowKITTINGRow)
Return rowKITTINGRow
End Function
_
Public Overridable Function GetEnumerator() As Global.System.Collections.IEnumerator Implements Global.System.Collections.IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
_
Public Overrides Function Clone() As Global.System.Data.DataTable
Dim cln As KITTINGDataTable = CType(MyBase.Clone,KITTINGDataTable)
cln.InitVars
Return cln
End Function
_
Protected Overrides Function CreateInstance() As Global.System.Data.DataTable
Return New KITTINGDataTable()
End Function
_
Friend Sub InitVars()
Me.columnREV = MyBase.Columns("REV")
Me.columnPARTNO = MyBase.Columns("PARTNO")
Me.columnDESC1 = MyBase.Columns("DESC1")
Me.columnUSAGE = MyBase.Columns("USAGE")
Me.columnSPQ = MyBase.Columns("SPQ")
Me.columnOPERATOR = MyBase.Columns("OPERATOR")
Me.columnKITTINGDATE = MyBase.Columns("KITTINGDATE")
Me.columnQTY = MyBase.Columns("QTY")
Me.columnFEEDER = MyBase.Columns("FEEDER")
Me.columnACCOUNT = MyBase.Columns("ACCOUNT")
Me.columnMACHINE = MyBase.Columns("MACHINE")
Me.columnMODEL = MyBase.Columns("MODEL")
Me.columnTYPE = MyBase.Columns("TYPE")
Me.columnLINE = MyBase.Columns("LINE")
End Sub
_
Private Sub InitClass()
Me.columnREV = New Global.System.Data.DataColumn("REV", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnREV)
Me.columnPARTNO = New Global.System.Data.DataColumn("PARTNO", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnPARTNO)
Me.columnDESC1 = New Global.System.Data.DataColumn("DESC1", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnDESC1)
Me.columnUSAGE = New Global.System.Data.DataColumn("USAGE", GetType(Double), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnUSAGE)
Me.columnSPQ = New Global.System.Data.DataColumn("SPQ", GetType(Double), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnSPQ)
Me.columnOPERATOR = New Global.System.Data.DataColumn("OPERATOR", GetType(String), Nothing, Global.System.Data.MappingType.Element)
Me.columnOPERATOR.ExtendedProperties.Add("Generator_ColumnPropNameInTable", "OPERATORColumn")
Me.columnOPERATOR.ExtendedProperties.Add("Generator_ColumnVarNameInTable", "columnOPERATOR")
Me.columnOPERATOR.ExtendedProperties.Add("Generator_UserColumnName", "OPERATOR")
MyBase.Columns.Add(Me.columnOPERATOR)
Me.columnKITTINGDATE = New Global.System.Data.DataColumn("KITTINGDATE", GetType(Date), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnKITTINGDATE)
Me.columnQTY = New Global.System.Data.DataColumn("QTY", GetType(Double), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnQTY)
Me.columnFEEDER = New Global.System.Data.DataColumn("FEEDER", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnFEEDER)
Me.columnACCOUNT = New Global.System.Data.DataColumn("ACCOUNT", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnACCOUNT)
Me.columnMACHINE = New Global.System.Data.DataColumn("MACHINE", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnMACHINE)
Me.columnMODEL = New Global.System.Data.DataColumn("MODEL", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnMODEL)
Me.columnTYPE = New Global.System.Data.DataColumn("TYPE", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnTYPE)
Me.columnLINE = New Global.System.Data.DataColumn("LINE", GetType(String), Nothing, Global.System.Data.MappingType.Element)
MyBase.Columns.Add(Me.columnLINE)
Me.columnREV.AllowDBNull = false
Me.columnREV.MaxLength = 50
Me.columnPARTNO.AllowDBNull = false
Me.columnPARTNO.MaxLength = 50
Me.columnDESC1.AllowDBNull = false
Me.columnDESC1.MaxLength = 2147483647
Me.columnOPERATOR.AllowDBNull = false
Me.columnOPERATOR.MaxLength = 50
Me.columnKITTINGDATE.AllowDBNull = false
Me.columnFEEDER.MaxLength = 50
Me.columnACCOUNT.MaxLength = 50
Me.columnMACHINE.MaxLength = 50
Me.columnMODEL.MaxLength = 50
Me.columnTYPE.MaxLength = 50
Me.columnLINE.MaxLength = 50
End Sub
_
Public Function NewKITTINGRow() As KITTINGRow
Return CType(Me.NewRow,KITTINGRow)
End Function
_
Protected Overrides Function NewRowFromBuilder(ByVal builder As Global.System.Data.DataRowBuilder) As Global.System.Data.DataRow
Return New KITTINGRow(builder)
End Function
_
Protected Overrides Function GetRowType() As Global.System.Type
Return GetType(KITTINGRow)
End Function
_
Protected Overrides Sub OnRowChanged(ByVal e As Global.System.Data.DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.KITTINGRowChangedEvent) Is Nothing) Then
RaiseEvent KITTINGRowChanged(Me, New KITTINGRowChangeEvent(CType(e.Row,KITTINGRow), e.Action))
End If
End Sub
_
Protected Overrides Sub OnRowChanging(ByVal e As Global.System.Data.DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.KITTINGRowChangingEvent) Is Nothing) Then
RaiseEvent KITTINGRowChanging(Me, New KITTINGRowChangeEvent(CType(e.Row,KITTINGRow), e.Action))
End If
End Sub
_
Protected Overrides Sub OnRowDeleted(ByVal e As Global.System.Data.DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.KITTINGRowDeletedEvent) Is Nothing) Then
RaiseEvent KITTINGRowDeleted(Me, New KITTINGRowChangeEvent(CType(e.Row,KITTINGRow), e.Action))
End If
End Sub
_
Protected Overrides Sub OnRowDeleting(ByVal e As Global.System.Data.DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.KITTINGRowDeletingEvent) Is Nothing) Then
RaiseEvent KITTINGRowDeleting(Me, New KITTINGRowChangeEvent(CType(e.Row,KITTINGRow), e.Action))
End If
End Sub
_
Public Sub RemoveKITTINGRow(ByVal row As KITTINGRow)
Me.Rows.Remove(row)
End Sub
_
Public Shared Function GetTypedTableSchema(ByVal xs As Global.System.Xml.Schema.XmlSchemaSet) As Global.System.Xml.Schema.XmlSchemaComplexType
Dim type As Global.System.Xml.Schema.XmlSchemaComplexType = New Global.System.Xml.Schema.XmlSchemaComplexType()
Dim sequence As Global.System.Xml.Schema.XmlSchemaSequence = New Global.System.Xml.Schema.XmlSchemaSequence()
Dim ds As EpsonDataSet = New EpsonDataSet()
Dim any1 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny()
any1.Namespace = "http://www.w3.org/2001/XMLSchema"
any1.MinOccurs = New Decimal(0)
any1.MaxOccurs = Decimal.MaxValue
any1.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax
sequence.Items.Add(any1)
Dim any2 As Global.System.Xml.Schema.XmlSchemaAny = New Global.System.Xml.Schema.XmlSchemaAny()
any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"
any2.MinOccurs = New Decimal(1)
any2.ProcessContents = Global.System.Xml.Schema.XmlSchemaContentProcessing.Lax
sequence.Items.Add(any2)
Dim attribute1 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute()
attribute1.Name = "namespace"
attribute1.FixedValue = ds.Namespace
type.Attributes.Add(attribute1)
Dim attribute2 As Global.System.Xml.Schema.XmlSchemaAttribute = New Global.System.Xml.Schema.XmlSchemaAttribute()
attribute2.Name = "tableTypeName"
attribute2.FixedValue = "KITTINGDataTable"
type.Attributes.Add(attribute2)
type.Particle = sequence
Dim dsSchema As Global.System.Xml.Schema.XmlSchema = ds.GetSchemaSerializable
If xs.Contains(dsSchema.TargetNamespace) Then
Dim s1 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream()
Dim s2 As Global.System.IO.MemoryStream = New Global.System.IO.MemoryStream()
Try
Dim schema As Global.System.Xml.Schema.XmlSchema = Nothing
dsSchema.Write(s1)
Dim schemas As Global.System.Collections.IEnumerator = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator
Do While schemas.MoveNext
schema = CType(schemas.Current,Global.System.Xml.Schema.XmlSchema)
s2.SetLength(0)
schema.Write(s2)
If (s1.Length = s2.Length) Then
s1.Position = 0
s2.Position = 0
Do While ((s1.Position <> s1.Length) _
AndAlso (s1.ReadByte = s2.ReadByte))
Loop
If (s1.Position = s1.Length) Then
Return type
End If
End If
Loop
Finally
If (Not (s1) Is Nothing) Then
s1.Close
End If
If (Not (s2) Is Nothing) Then
s2.Close
End If
End Try
End If
xs.Add(dsSchema)
Return type
End Function
End Class
'''
'''Represents strongly named DataRow class.
'''
Partial Public Class KITTINGRow
Inherits Global.System.Data.DataRow
Private tableKITTING As KITTINGDataTable
_
Friend Sub New(ByVal rb As Global.System.Data.DataRowBuilder)
MyBase.New(rb)
Me.tableKITTING = CType(Me.Table,KITTINGDataTable)
End Sub
_
Public Property REV() As String
Get
Return CType(Me(Me.tableKITTING.REVColumn),String)
End Get
Set
Me(Me.tableKITTING.REVColumn) = value
End Set
End Property
_
Public Property PARTNO() As String
Get
Return CType(Me(Me.tableKITTING.PARTNOColumn),String)
End Get
Set
Me(Me.tableKITTING.PARTNOColumn) = value
End Set
End Property
_
Public Property DESC1() As String
Get
Return CType(Me(Me.tableKITTING.DESC1Column),String)
End Get
Set
Me(Me.tableKITTING.DESC1Column) = value
End Set
End Property
_
Public Property USAGE() As Double
Get
Try
Return CType(Me(Me.tableKITTING.USAGEColumn),Double)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'USAGE' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.USAGEColumn) = value
End Set
End Property
_
Public Property SPQ() As Double
Get
Try
Return CType(Me(Me.tableKITTING.SPQColumn),Double)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'SPQ' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.SPQColumn) = value
End Set
End Property
_
Public Property _OPERATOR() As String
Get
Return CType(Me(Me.tableKITTING.OPERATORColumn),String)
End Get
Set
Me(Me.tableKITTING.OPERATORColumn) = value
End Set
End Property
_
Public Property KITTINGDATE() As Date
Get
Return CType(Me(Me.tableKITTING.KITTINGDATEColumn),Date)
End Get
Set
Me(Me.tableKITTING.KITTINGDATEColumn) = value
End Set
End Property
_
Public Property QTY() As Double
Get
Try
Return CType(Me(Me.tableKITTING.QTYColumn),Double)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'QTY' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.QTYColumn) = value
End Set
End Property
_
Public Property FEEDER() As String
Get
Try
Return CType(Me(Me.tableKITTING.FEEDERColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'FEEDER' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.FEEDERColumn) = value
End Set
End Property
_
Public Property ACCOUNT() As String
Get
Try
Return CType(Me(Me.tableKITTING.ACCOUNTColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'ACCOUNT' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.ACCOUNTColumn) = value
End Set
End Property
_
Public Property MACHINE() As String
Get
Try
Return CType(Me(Me.tableKITTING.MACHINEColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'MACHINE' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.MACHINEColumn) = value
End Set
End Property
_
Public Property MODEL() As String
Get
Try
Return CType(Me(Me.tableKITTING.MODELColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'MODEL' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.MODELColumn) = value
End Set
End Property
_
Public Property TYPE() As String
Get
Try
Return CType(Me(Me.tableKITTING.TYPEColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'TYPE' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.TYPEColumn) = value
End Set
End Property
_
Public Property LINE() As String
Get
Try
Return CType(Me(Me.tableKITTING.LINEColumn),String)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'LINE' in table 'KITTING' is DBNull.", e)
End Try
End Get
Set
Me(Me.tableKITTING.LINEColumn) = value
End Set
End Property
_
Public Function IsUSAGENull() As Boolean
Return Me.IsNull(Me.tableKITTING.USAGEColumn)
End Function
_
Public Sub SetUSAGENull()
Me(Me.tableKITTING.USAGEColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsSPQNull() As Boolean
Return Me.IsNull(Me.tableKITTING.SPQColumn)
End Function
_
Public Sub SetSPQNull()
Me(Me.tableKITTING.SPQColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsQTYNull() As Boolean
Return Me.IsNull(Me.tableKITTING.QTYColumn)
End Function
_
Public Sub SetQTYNull()
Me(Me.tableKITTING.QTYColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsFEEDERNull() As Boolean
Return Me.IsNull(Me.tableKITTING.FEEDERColumn)
End Function
_
Public Sub SetFEEDERNull()
Me(Me.tableKITTING.FEEDERColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsACCOUNTNull() As Boolean
Return Me.IsNull(Me.tableKITTING.ACCOUNTColumn)
End Function
_
Public Sub SetACCOUNTNull()
Me(Me.tableKITTING.ACCOUNTColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsMACHINENull() As Boolean
Return Me.IsNull(Me.tableKITTING.MACHINEColumn)
End Function
_
Public Sub SetMACHINENull()
Me(Me.tableKITTING.MACHINEColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsMODELNull() As Boolean
Return Me.IsNull(Me.tableKITTING.MODELColumn)
End Function
_
Public Sub SetMODELNull()
Me(Me.tableKITTING.MODELColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsTYPENull() As Boolean
Return Me.IsNull(Me.tableKITTING.TYPEColumn)
End Function
_
Public Sub SetTYPENull()
Me(Me.tableKITTING.TYPEColumn) = Global.System.Convert.DBNull
End Sub
_
Public Function IsLINENull() As Boolean
Return Me.IsNull(Me.tableKITTING.LINEColumn)
End Function
_
Public Sub SetLINENull()
Me(Me.tableKITTING.LINEColumn) = Global.System.Convert.DBNull
End Sub
End Class
'''
'''Row event argument class
'''
_
Public Class KITTINGRowChangeEvent
Inherits Global.System.EventArgs
Private eventRow As KITTINGRow
Private eventAction As Global.System.Data.DataRowAction
_
Public Sub New(ByVal row As KITTINGRow, ByVal action As Global.System.Data.DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
_
Public ReadOnly Property Row() As KITTINGRow
Get
Return Me.eventRow
End Get
End Property
_
Public ReadOnly Property Action() As Global.System.Data.DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class
Namespace EpsonDataSetTableAdapters
'''
'''Represents the connection and commands used to retrieve and save data.
'''
_
Partial Public Class KITTINGTableAdapter
Inherits Global.System.ComponentModel.Component
Private WithEvents _adapter As Global.System.Data.SqlClient.SqlDataAdapter
Private _connection As Global.System.Data.SqlClient.SqlConnection
Private _transaction As Global.System.Data.SqlClient.SqlTransaction
Private _commandCollection() As Global.System.Data.SqlClient.SqlCommand
Private _clearBeforeFill As Boolean
_
Public Sub New()
MyBase.New
Me.ClearBeforeFill = true
End Sub
_
Protected Friend ReadOnly Property Adapter() As Global.System.Data.SqlClient.SqlDataAdapter
Get
If (Me._adapter Is Nothing) Then
Me.InitAdapter
End If
Return Me._adapter
End Get
End Property
_
Friend Property Connection() As Global.System.Data.SqlClient.SqlConnection
Get
If (Me._connection Is Nothing) Then
Me.InitConnection
End If
Return Me._connection
End Get
Set
Me._connection = value
If (Not (Me.Adapter.InsertCommand) Is Nothing) Then
Me.Adapter.InsertCommand.Connection = value
End If
If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then
Me.Adapter.DeleteCommand.Connection = value
End If
If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then
Me.Adapter.UpdateCommand.Connection = value
End If
Dim i As Integer = 0
Do While (i < Me.CommandCollection.Length)
If (Not (Me.CommandCollection(i)) Is Nothing) Then
CType(Me.CommandCollection(i),Global.System.Data.SqlClient.SqlCommand).Connection = value
End If
i = (i + 1)
Loop
End Set
End Property
_
Friend Property Transaction() As Global.System.Data.SqlClient.SqlTransaction
Get
Return Me._transaction
End Get
Set
Me._transaction = value
Dim i As Integer = 0
Do While (i < Me.CommandCollection.Length)
Me.CommandCollection(i).Transaction = Me._transaction
i = (i + 1)
Loop
If ((Not (Me.Adapter) Is Nothing) _
AndAlso (Not (Me.Adapter.DeleteCommand) Is Nothing)) Then
Me.Adapter.DeleteCommand.Transaction = Me._transaction
End If
If ((Not (Me.Adapter) Is Nothing) _
AndAlso (Not (Me.Adapter.InsertCommand) Is Nothing)) Then
Me.Adapter.InsertCommand.Transaction = Me._transaction
End If
If ((Not (Me.Adapter) Is Nothing) _
AndAlso (Not (Me.Adapter.UpdateCommand) Is Nothing)) Then
Me.Adapter.UpdateCommand.Transaction = Me._transaction
End If
End Set
End Property
_
Protected ReadOnly Property CommandCollection() As Global.System.Data.SqlClient.SqlCommand()
Get
If (Me._commandCollection Is Nothing) Then
Me.InitCommandCollection
End If
Return Me._commandCollection
End Get
End Property
_
Public Property ClearBeforeFill() As Boolean
Get
Return Me._clearBeforeFill
End Get
Set
Me._clearBeforeFill = value
End Set
End Property
_
Private Sub InitAdapter()
Me._adapter = New Global.System.Data.SqlClient.SqlDataAdapter()
Dim tableMapping As Global.System.Data.Common.DataTableMapping = New Global.System.Data.Common.DataTableMapping()
tableMapping.SourceTable = "Table"
tableMapping.DataSetTable = "KITTING"
tableMapping.ColumnMappings.Add("REV", "REV")
tableMapping.ColumnMappings.Add("PARTNO", "PARTNO")
tableMapping.ColumnMappings.Add("DESC1", "DESC1")
tableMapping.ColumnMappings.Add("USAGE", "USAGE")
tableMapping.ColumnMappings.Add("SPQ", "SPQ")
tableMapping.ColumnMappings.Add("OPERATOR", "OPERATOR")
tableMapping.ColumnMappings.Add("KITTINGDATE", "KITTINGDATE")
tableMapping.ColumnMappings.Add("QTY", "QTY")
tableMapping.ColumnMappings.Add("FEEDER", "FEEDER")
tableMapping.ColumnMappings.Add("ACCOUNT", "ACCOUNT")
tableMapping.ColumnMappings.Add("MACHINE", "MACHINE")
tableMapping.ColumnMappings.Add("MODEL", "MODEL")
tableMapping.ColumnMappings.Add("TYPE", "TYPE")
tableMapping.ColumnMappings.Add("LINE", "LINE")
Me._adapter.TableMappings.Add(tableMapping)
Me._adapter.InsertCommand = New Global.System.Data.SqlClient.SqlCommand()
Me._adapter.InsertCommand.Connection = Me.Connection
Me._adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[KITTING] ([REV], [PARTNO], [DESC1], [USAGE], [SPQ], [OPERATOR]"& _
", [KITTINGDATE], [QTY], [FEEDER], [ACCOUNT], [MACHINE], [MODEL], [TYPE], [LINE])"& _
" VALUES (@REV, @PARTNO, @DESC1, @USAGE, @SPQ, @OPERATOR, @KITTINGDATE, @QTY, @FE"& _
"EDER, @ACCOUNT, @MACHINE, @MODEL, @TYPE, @LINE)"
Me._adapter.InsertCommand.CommandType = Global.System.Data.CommandType.Text
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@REV", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "REV", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PARTNO", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "PARTNO", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@DESC1", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "DESC1", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@USAGE", Global.System.Data.SqlDbType.Float, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "USAGE", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@SPQ", Global.System.Data.SqlDbType.Float, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "SPQ", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@OPERATOR", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "OPERATOR", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@KITTINGDATE", Global.System.Data.SqlDbType.DateTime, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "KITTINGDATE", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@QTY", Global.System.Data.SqlDbType.Float, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "QTY", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@FEEDER", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "FEEDER", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@ACCOUNT", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "ACCOUNT", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@MACHINE", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "MACHINE", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@MODEL", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "MODEL", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@TYPE", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "TYPE", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@LINE", Global.System.Data.SqlDbType.VarChar, 0, Global.System.Data.ParameterDirection.Input, 0, 0, "LINE", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", ""))
End Sub
_
Private Sub InitConnection()
Me._connection = New Global.System.Data.SqlClient.SqlConnection()
Me._connection.ConnectionString = Global.Mounting_Sequence.My.MySettings.Default.EpsonConnectionString
End Sub
_
Private Sub InitCommandCollection()
Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(0) {}
Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand()
Me._commandCollection(0).Connection = Me.Connection
Me._commandCollection(0).CommandText = "SELECT REV, PARTNO, DESC1, USAGE, SPQ, OPERATOR, KITTINGDATE, QTY, FEEDER, ACCOUN"& _
"T, MACHINE, MODEL, TYPE, LINE FROM dbo.KITTING"
Me._commandCollection(0).CommandType = Global.System.Data.CommandType.Text
End Sub
_
Public Overloads Overridable Function Fill(ByVal dataTable As EpsonDataSet.KITTINGDataTable) As Integer
Me.Adapter.SelectCommand = Me.CommandCollection(0)
If (Me.ClearBeforeFill = true) Then
dataTable.Clear
End If
Dim returnValue As Integer = Me.Adapter.Fill(dataTable)
Return returnValue
End Function
_
Public Overloads Overridable Function GetData() As EpsonDataSet.KITTINGDataTable
Me.Adapter.SelectCommand = Me.CommandCollection(0)
Dim dataTable As EpsonDataSet.KITTINGDataTable = New EpsonDataSet.KITTINGDataTable()
Me.Adapter.Fill(dataTable)
Return dataTable
End Function
_
Public Overloads Overridable Function Update(ByVal dataTable As EpsonDataSet.KITTINGDataTable) As Integer
Return Me.Adapter.Update(dataTable)
End Function
_
Public Overloads Overridable Function Update(ByVal dataSet As EpsonDataSet) As Integer
Return Me.Adapter.Update(dataSet, "KITTING")
End Function
_
Public Overloads Overridable Function Update(ByVal dataRow As Global.System.Data.DataRow) As Integer
Return Me.Adapter.Update(New Global.System.Data.DataRow() {dataRow})
End Function
_
Public Overloads Overridable Function Update(ByVal dataRows() As Global.System.Data.DataRow) As Integer
Return Me.Adapter.Update(dataRows)
End Function
_
Public Overloads Overridable Function Insert(ByVal REV As String, ByVal PARTNO As String, ByVal DESC1 As String, ByVal USAGE As Global.System.Nullable(Of Double), ByVal SPQ As Global.System.Nullable(Of Double), ByVal _OPERATOR As String, ByVal KITTINGDATE As Date, ByVal QTY As Global.System.Nullable(Of Double), ByVal FEEDER As String, ByVal ACCOUNT As String, ByVal MACHINE As String, ByVal MODEL As String, ByVal TYPE As String, ByVal LINE As String) As Integer
If (REV Is Nothing) Then
Throw New Global.System.ArgumentNullException("REV")
Else
Me.Adapter.InsertCommand.Parameters(0).Value = CType(REV,String)
End If
If (PARTNO Is Nothing) Then
Throw New Global.System.ArgumentNullException("PARTNO")
Else
Me.Adapter.InsertCommand.Parameters(1).Value = CType(PARTNO,String)
End If
If (DESC1 Is Nothing) Then
Throw New Global.System.ArgumentNullException("DESC1")
Else
Me.Adapter.InsertCommand.Parameters(2).Value = CType(DESC1,String)
End If
If (USAGE.HasValue = true) Then
Me.Adapter.InsertCommand.Parameters(3).Value = CType(USAGE.Value,Double)
Else
Me.Adapter.InsertCommand.Parameters(3).Value = Global.System.DBNull.Value
End If
If (SPQ.HasValue = true) Then
Me.Adapter.InsertCommand.Parameters(4).Value = CType(SPQ.Value,Double)
Else
Me.Adapter.InsertCommand.Parameters(4).Value = Global.System.DBNull.Value
End If
If (_OPERATOR Is Nothing) Then
Throw New Global.System.ArgumentNullException("_OPERATOR")
Else
Me.Adapter.InsertCommand.Parameters(5).Value = CType(_OPERATOR,String)
End If
Me.Adapter.InsertCommand.Parameters(6).Value = CType(KITTINGDATE,Date)
If (QTY.HasValue = true) Then
Me.Adapter.InsertCommand.Parameters(7).Value = CType(QTY.Value,Double)
Else
Me.Adapter.InsertCommand.Parameters(7).Value = Global.System.DBNull.Value
End If
If (FEEDER Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(8).Value = Global.System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(8).Value = CType(FEEDER,String)
End If
If (ACCOUNT Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(9).Value = Global.System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(9).Value = CType(ACCOUNT,String)
End If
If (MACHINE Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(10).Value = Global.System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(10).Value = CType(MACHINE,String)
End If
If (MODEL Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(11).Value = Global.System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(11).Value = CType(MODEL,String)
End If
If (TYPE Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(12).Value = Global.System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(12).Value = CType(TYPE,String)
End If
If (LINE Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(13).Value = Global.System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(13).Value = CType(LINE,String)
End If
Dim previousConnectionState As Global.System.Data.ConnectionState = Me.Adapter.InsertCommand.Connection.State
If ((Me.Adapter.InsertCommand.Connection.State And Global.System.Data.ConnectionState.Open) _
<> Global.System.Data.ConnectionState.Open) Then
Me.Adapter.InsertCommand.Connection.Open
End If
Try
Dim returnValue As Integer = Me.Adapter.InsertCommand.ExecuteNonQuery
Return returnValue
Finally
If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then
Me.Adapter.InsertCommand.Connection.Close
End If
End Try
End Function
End Class
'''
'''TableAdapterManager is used to coordinate TableAdapters in the dataset to enable Hierarchical Update scenarios
'''
_
Partial Public Class TableAdapterManager
Inherits Global.System.ComponentModel.Component
Private _updateOrder As UpdateOrderOption
Private _kITTINGTableAdapter As KITTINGTableAdapter
Private _backupDataSetBeforeUpdate As Boolean
Private _connection As Global.System.Data.IDbConnection
_
Public Property UpdateOrder() As UpdateOrderOption
Get
Return Me._updateOrder
End Get
Set
Me._updateOrder = value
End Set
End Property
_
Public Property KITTINGTableAdapter() As KITTINGTableAdapter
Get
Return Me._kITTINGTableAdapter
End Get
Set
Me._kITTINGTableAdapter = value
End Set
End Property
_
Public Property BackupDataSetBeforeUpdate() As Boolean
Get
Return Me._backupDataSetBeforeUpdate
End Get
Set
Me._backupDataSetBeforeUpdate = value
End Set
End Property
_
Public Property Connection() As Global.System.Data.IDbConnection
Get
If (Not (Me._connection) Is Nothing) Then
Return Me._connection
End If
If ((Not (Me._kITTINGTableAdapter) Is Nothing) _
AndAlso (Not (Me._kITTINGTableAdapter.Connection) Is Nothing)) Then
Return Me._kITTINGTableAdapter.Connection
End If
Return Nothing
End Get
Set
Me._connection = value
End Set
End Property
_
Public ReadOnly Property TableAdapterInstanceCount() As Integer
Get
Dim count As Integer = 0
If (Not (Me._kITTINGTableAdapter) Is Nothing) Then
count = (count + 1)
End If
Return count
End Get
End Property
'''
'''Update rows in top-down order.
'''
_
Private Function UpdateUpdatedRows(ByVal dataSet As EpsonDataSet, ByVal allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow), ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer
Dim result As Integer = 0
If (Not (Me._kITTINGTableAdapter) Is Nothing) Then
Dim updatedRows() As Global.System.Data.DataRow = dataSet.KITTING.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.ModifiedCurrent)
updatedRows = Me.GetRealUpdatedRows(updatedRows, allAddedRows)
If ((Not (updatedRows) Is Nothing) _
AndAlso (0 < updatedRows.Length)) Then
result = (result + Me._kITTINGTableAdapter.Update(updatedRows))
allChangedRows.AddRange(updatedRows)
End If
End If
Return result
End Function
'''
'''Insert rows in top-down order.
'''
_
Private Function UpdateInsertedRows(ByVal dataSet As EpsonDataSet, ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer
Dim result As Integer = 0
If (Not (Me._kITTINGTableAdapter) Is Nothing) Then
Dim addedRows() As Global.System.Data.DataRow = dataSet.KITTING.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Added)
If ((Not (addedRows) Is Nothing) _
AndAlso (0 < addedRows.Length)) Then
result = (result + Me._kITTINGTableAdapter.Update(addedRows))
allAddedRows.AddRange(addedRows)
End If
End If
Return result
End Function
'''
'''Delete rows in bottom-up order.
'''
_
Private Function UpdateDeletedRows(ByVal dataSet As EpsonDataSet, ByVal allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Integer
Dim result As Integer = 0
If (Not (Me._kITTINGTableAdapter) Is Nothing) Then
Dim deletedRows() As Global.System.Data.DataRow = dataSet.KITTING.Select(Nothing, Nothing, Global.System.Data.DataViewRowState.Deleted)
If ((Not (deletedRows) Is Nothing) _
AndAlso (0 < deletedRows.Length)) Then
result = (result + Me._kITTINGTableAdapter.Update(deletedRows))
allChangedRows.AddRange(deletedRows)
End If
End If
Return result
End Function
'''
'''Remove inserted rows that become updated rows after calling TableAdapter.Update(inserted rows) first
'''
_
Private Function GetRealUpdatedRows(ByVal updatedRows() As Global.System.Data.DataRow, ByVal allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)) As Global.System.Data.DataRow()
If ((updatedRows Is Nothing) _
OrElse (updatedRows.Length < 1)) Then
Return updatedRows
End If
If ((allAddedRows Is Nothing) _
OrElse (allAddedRows.Count < 1)) Then
Return updatedRows
End If
Dim realUpdatedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)()
Dim i As Integer = 0
Do While (i < updatedRows.Length)
Dim row As Global.System.Data.DataRow = updatedRows(i)
If (allAddedRows.Contains(row) = false) Then
realUpdatedRows.Add(row)
End If
i = (i + 1)
Loop
Return realUpdatedRows.ToArray
End Function
'''
'''Update all changes to the dataset.
'''
_
Public Overridable Function UpdateAll(ByVal dataSet As EpsonDataSet) As Integer
If (dataSet Is Nothing) Then
Throw New Global.System.ArgumentNullException("dataSet")
End If
If (dataSet.HasChanges = false) Then
Return 0
End If
If ((Not (Me._kITTINGTableAdapter) Is Nothing) _
AndAlso (Me.MatchTableAdapterConnection(Me._kITTINGTableAdapter.Connection) = false)) Then
Throw New Global.System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s"& _
"tring.")
End If
Dim workConnection As Global.System.Data.IDbConnection = Me.Connection
If (workConnection Is Nothing) Then
Throw New Global.System.ApplicationException("TableAdapterManager contains no connection information. Set each TableAdapterMana"& _
"ger TableAdapter property to a valid TableAdapter instance.")
End If
Dim workConnOpened As Boolean = false
If ((workConnection.State And Global.System.Data.ConnectionState.Broken) _
= Global.System.Data.ConnectionState.Broken) Then
workConnection.Close
End If
If (workConnection.State = Global.System.Data.ConnectionState.Closed) Then
workConnection.Open
workConnOpened = true
End If
Dim workTransaction As Global.System.Data.IDbTransaction = workConnection.BeginTransaction
If (workTransaction Is Nothing) Then
Throw New Global.System.ApplicationException("The transaction cannot begin. The current data connection does not support transa"& _
"ctions or the current state is not allowing the transaction to begin.")
End If
Dim allChangedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)()
Dim allAddedRows As Global.System.Collections.Generic.List(Of Global.System.Data.DataRow) = New Global.System.Collections.Generic.List(Of Global.System.Data.DataRow)()
Dim adaptersWithAcceptChangesDuringUpdate As Global.System.Collections.Generic.List(Of Global.System.Data.Common.DataAdapter) = New Global.System.Collections.Generic.List(Of Global.System.Data.Common.DataAdapter)()
Dim revertConnections As Global.System.Collections.Generic.Dictionary(Of Object, Global.System.Data.IDbConnection) = New Global.System.Collections.Generic.Dictionary(Of Object, Global.System.Data.IDbConnection)()
Dim result As Integer = 0
Dim backupDataSet As Global.System.Data.DataSet = Nothing
If Me.BackupDataSetBeforeUpdate Then
backupDataSet = New Global.System.Data.DataSet()
backupDataSet.Merge(dataSet)
End If
Try
'---- Prepare for update -----------
'
If (Not (Me._kITTINGTableAdapter) Is Nothing) Then
revertConnections.Add(Me._kITTINGTableAdapter, Me._kITTINGTableAdapter.Connection)
Me._kITTINGTableAdapter.Connection = CType(workConnection,Global.System.Data.SqlClient.SqlConnection)
Me._kITTINGTableAdapter.Transaction = CType(workTransaction,Global.System.Data.SqlClient.SqlTransaction)
If Me._kITTINGTableAdapter.Adapter.AcceptChangesDuringUpdate Then
Me._kITTINGTableAdapter.Adapter.AcceptChangesDuringUpdate = false
adaptersWithAcceptChangesDuringUpdate.Add(Me._kITTINGTableAdapter.Adapter)
End If
End If
'
'---- Perform updates -----------
'
If (Me.UpdateOrder = UpdateOrderOption.UpdateInsertDelete) Then
result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows))
result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows))
Else
result = (result + Me.UpdateInsertedRows(dataSet, allAddedRows))
result = (result + Me.UpdateUpdatedRows(dataSet, allChangedRows, allAddedRows))
End If
result = (result + Me.UpdateDeletedRows(dataSet, allChangedRows))
'
'---- Commit updates -----------
'
workTransaction.Commit
If (0 < allAddedRows.Count) Then
Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow
allAddedRows.CopyTo(rows)
Dim i As Integer = 0
Do While (i < rows.Length)
Dim row As Global.System.Data.DataRow = rows(i)
row.AcceptChanges
i = (i + 1)
Loop
End If
If (0 < allChangedRows.Count) Then
Dim rows((allChangedRows.Count) - 1) As Global.System.Data.DataRow
allChangedRows.CopyTo(rows)
Dim i As Integer = 0
Do While (i < rows.Length)
Dim row As Global.System.Data.DataRow = rows(i)
row.AcceptChanges
i = (i + 1)
Loop
End If
Catch ex As Global.System.Exception
workTransaction.Rollback
'---- Restore the dataset -----------
If Me.BackupDataSetBeforeUpdate Then
Global.System.Diagnostics.Debug.Assert((Not (backupDataSet) Is Nothing))
dataSet.Clear
dataSet.Merge(backupDataSet)
Else
If (0 < allAddedRows.Count) Then
Dim rows((allAddedRows.Count) - 1) As Global.System.Data.DataRow
allAddedRows.CopyTo(rows)
Dim i As Integer = 0
Do While (i < rows.Length)
Dim row As Global.System.Data.DataRow = rows(i)
row.AcceptChanges
row.SetAdded
i = (i + 1)
Loop
End If
End If
Throw ex
Finally
If workConnOpened Then
workConnection.Close
End If
If (Not (Me._kITTINGTableAdapter) Is Nothing) Then
Me._kITTINGTableAdapter.Connection = CType(revertConnections(Me._kITTINGTableAdapter),Global.System.Data.SqlClient.SqlConnection)
Me._kITTINGTableAdapter.Transaction = Nothing
End If
If (0 < adaptersWithAcceptChangesDuringUpdate.Count) Then
Dim adapters((adaptersWithAcceptChangesDuringUpdate.Count) - 1) As Global.System.Data.Common.DataAdapter
adaptersWithAcceptChangesDuringUpdate.CopyTo(adapters)
Dim i As Integer = 0
Do While (i < adapters.Length)
Dim adapter As Global.System.Data.Common.DataAdapter = adapters(i)
adapter.AcceptChangesDuringUpdate = true
i = (i + 1)
Loop
End If
End Try
Return result
End Function
_
Protected Overridable Sub SortSelfReferenceRows(ByVal rows() As Global.System.Data.DataRow, ByVal relation As Global.System.Data.DataRelation, ByVal childFirst As Boolean)
Global.System.Array.Sort(Of Global.System.Data.DataRow)(rows, New SelfReferenceComparer(relation, childFirst))
End Sub
_
Protected Overridable Function MatchTableAdapterConnection(ByVal inputConnection As Global.System.Data.IDbConnection) As Boolean
If (Not (Me._connection) Is Nothing) Then
Return true
End If
If ((Me.Connection Is Nothing) _
OrElse (inputConnection Is Nothing)) Then
Return true
End If
If String.Equals(Me.Connection.ConnectionString, inputConnection.ConnectionString, Global.System.StringComparison.Ordinal) Then
Return true
End If
Return false
End Function
'''
'''Update Order Option
'''
_
Public Enum UpdateOrderOption
InsertUpdateDelete = 0
UpdateInsertDelete = 1
End Enum
'''
'''Used to sort self-referenced table's rows
'''
_
Private Class SelfReferenceComparer
Inherits Object
Implements Global.System.Collections.Generic.IComparer(Of Global.System.Data.DataRow)
Private _relation As Global.System.Data.DataRelation
Private _childFirst As Integer
_
Friend Sub New(ByVal relation As Global.System.Data.DataRelation, ByVal childFirst As Boolean)
MyBase.New
Me._relation = relation
If childFirst Then
Me._childFirst = -1
Else
Me._childFirst = 1
End If
End Sub
_
Private Function GetRoot(ByVal row As Global.System.Data.DataRow, ByRef distance As Integer) As Global.System.Data.DataRow
Global.System.Diagnostics.Debug.Assert((Not (row) Is Nothing))
Dim root As Global.System.Data.DataRow = row
distance = 0
Dim traversedRows As Global.System.Collections.Generic.IDictionary(Of Global.System.Data.DataRow, Global.System.Data.DataRow) = New Global.System.Collections.Generic.Dictionary(Of Global.System.Data.DataRow, Global.System.Data.DataRow)()
traversedRows(row) = row
Dim parent As Global.System.Data.DataRow = row.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.[Default])
Do While ((Not (parent) Is Nothing) _
AndAlso (traversedRows.ContainsKey(parent) = false))
distance = (distance + 1)
root = parent
traversedRows(parent) = parent
parent = parent.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.[Default])
Loop
If (distance = 0) Then
traversedRows.Clear
traversedRows(row) = row
parent = row.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.Original)
Do While ((Not (parent) Is Nothing) _
AndAlso (traversedRows.ContainsKey(parent) = false))
distance = (distance + 1)
root = parent
traversedRows(parent) = parent
parent = parent.GetParentRow(Me._relation, Global.System.Data.DataRowVersion.Original)
Loop
End If
Return root
End Function
_
Public Function Compare(ByVal row1 As Global.System.Data.DataRow, ByVal row2 As Global.System.Data.DataRow) As Integer Implements Global.System.Collections.Generic.IComparer(Of Global.System.Data.DataRow).Compare
If Object.ReferenceEquals(row1, row2) Then
Return 0
End If
If (row1 Is Nothing) Then
Return -1
End If
If (row2 Is Nothing) Then
Return 1
End If
Dim distance1 As Integer = 0
Dim root1 As Global.System.Data.DataRow = Me.GetRoot(row1, distance1)
Dim distance2 As Integer = 0
Dim root2 As Global.System.Data.DataRow = Me.GetRoot(row2, distance2)
If Object.ReferenceEquals(root1, root2) Then
Return (Me._childFirst * distance1.CompareTo(distance2))
Else
Global.System.Diagnostics.Debug.Assert(((Not (root1.Table) Is Nothing) _
AndAlso (Not (root2.Table) Is Nothing)))
If (root1.Table.Rows.IndexOf(root1) < root2.Table.Rows.IndexOf(root2)) Then
Return -1
Else
Return 1
End If
End If
End Function
End Class
End Class
End Namespace