⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsinventory.vb

📁 采用Visual Bacis.NET开发的电子商务系统.
💻 VB
📖 第 1 页 / 共 2 页
字号:
        End Property
        
        Public Default ReadOnly Property Item(ByVal index As Integer) As InventoryRow
            Get
                Return CType(Me.Rows(index),InventoryRow)
            End Get
        End Property
        
        Public Event InventoryRowChanged As InventoryRowChangeEventHandler
        
        Public Event InventoryRowChanging As InventoryRowChangeEventHandler
        
        Public Event InventoryRowDeleted As InventoryRowChangeEventHandler
        
        Public Event InventoryRowDeleting As InventoryRowChangeEventHandler
        
        Public Overloads Sub AddInventoryRow(ByVal row As InventoryRow)
            Me.Rows.Add(row)
        End Sub
        
        Public Overloads Function AddInventoryRow(ByVal InventoryID As System.Guid, ByVal ProductID As System.Guid, ByVal QuantityInStock As Integer, ByVal AvailableForReorder As Boolean, ByVal QuantityAvailable As Integer) As InventoryRow
            Dim rowInventoryRow As InventoryRow = CType(Me.NewRow,InventoryRow)
            rowInventoryRow.ItemArray = New Object() {InventoryID, ProductID, QuantityInStock, AvailableForReorder, QuantityAvailable}
            Me.Rows.Add(rowInventoryRow)
            Return rowInventoryRow
        End Function
        
        Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
            Return Me.Rows.GetEnumerator
        End Function
        
        Public Overrides Function Clone() As DataTable
            Dim cln As InventoryDataTable = CType(MyBase.Clone,InventoryDataTable)
            cln.InitVars
            Return cln
        End Function
        
        Protected Overrides Function CreateInstance() As DataTable
            Return New InventoryDataTable
        End Function
        
        Friend Sub InitVars()
            Me.columnInventoryID = Me.Columns("InventoryID")
            Me.columnProductID = Me.Columns("ProductID")
            Me.columnQuantityInStock = Me.Columns("QuantityInStock")
            Me.columnAvailableForReorder = Me.Columns("AvailableForReorder")
            Me.columnQuantityAvailable = Me.Columns("QuantityAvailable")
        End Sub
        
        Private Sub InitClass()
            Me.columnInventoryID = New DataColumn("InventoryID", GetType(System.Guid), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnInventoryID)
            Me.columnProductID = New DataColumn("ProductID", GetType(System.Guid), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnProductID)
            Me.columnQuantityInStock = New DataColumn("QuantityInStock", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnQuantityInStock)
            Me.columnAvailableForReorder = New DataColumn("AvailableForReorder", GetType(System.Boolean), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnAvailableForReorder)
            Me.columnQuantityAvailable = New DataColumn("QuantityAvailable", GetType(System.Int32), Nothing, System.Data.MappingType.Element)
            Me.Columns.Add(Me.columnQuantityAvailable)
            Me.columnInventoryID.AllowDBNull = false
            Me.columnProductID.AllowDBNull = false
            Me.columnQuantityInStock.AllowDBNull = false
            Me.columnAvailableForReorder.AllowDBNull = false
        End Sub
        
        Public Function NewInventoryRow() As InventoryRow
            Return CType(Me.NewRow,InventoryRow)
        End Function
        
        Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
            Return New InventoryRow(builder)
        End Function
        
        Protected Overrides Function GetRowType() As System.Type
            Return GetType(InventoryRow)
        End Function
        
        Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanged(e)
            If (Not (Me.InventoryRowChangedEvent) Is Nothing) Then
                RaiseEvent InventoryRowChanged(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowChanging(e)
            If (Not (Me.InventoryRowChangingEvent) Is Nothing) Then
                RaiseEvent InventoryRowChanging(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleted(e)
            If (Not (Me.InventoryRowDeletedEvent) Is Nothing) Then
                RaiseEvent InventoryRowDeleted(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action))
            End If
        End Sub
        
        Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
            MyBase.OnRowDeleting(e)
            If (Not (Me.InventoryRowDeletingEvent) Is Nothing) Then
                RaiseEvent InventoryRowDeleting(Me, New InventoryRowChangeEvent(CType(e.Row,InventoryRow), e.Action))
            End If
        End Sub
        
        Public Sub RemoveInventoryRow(ByVal row As InventoryRow)
            Me.Rows.Remove(row)
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class InventoryRow
        Inherits DataRow
        
        Private tableInventory As InventoryDataTable
        
        Friend Sub New(ByVal rb As DataRowBuilder)
            MyBase.New(rb)
            Me.tableInventory = CType(Me.Table,InventoryDataTable)
        End Sub
        
        Public Property InventoryID As System.Guid
            Get
                Return CType(Me(Me.tableInventory.InventoryIDColumn),System.Guid)
            End Get
            Set
                Me(Me.tableInventory.InventoryIDColumn) = value
            End Set
        End Property
        
        Public Property ProductID As System.Guid
            Get
                Return CType(Me(Me.tableInventory.ProductIDColumn),System.Guid)
            End Get
            Set
                Me(Me.tableInventory.ProductIDColumn) = value
            End Set
        End Property
        
        Public Property QuantityInStock As Integer
            Get
                Return CType(Me(Me.tableInventory.QuantityInStockColumn),Integer)
            End Get
            Set
                Me(Me.tableInventory.QuantityInStockColumn) = value
            End Set
        End Property
        
        Public Property AvailableForReorder As Boolean
            Get
                Return CType(Me(Me.tableInventory.AvailableForReorderColumn),Boolean)
            End Get
            Set
                Me(Me.tableInventory.AvailableForReorderColumn) = value
            End Set
        End Property
        
        Public Property QuantityAvailable As Integer
            Get
                Try 
                    Return CType(Me(Me.tableInventory.QuantityAvailableColumn),Integer)
                Catch e As InvalidCastException
                    Throw New StrongTypingException("无法获取值,因为它是 DBNull。", e)
                End Try
            End Get
            Set
                Me(Me.tableInventory.QuantityAvailableColumn) = value
            End Set
        End Property
        
        Public Function IsQuantityAvailableNull() As Boolean
            Return Me.IsNull(Me.tableInventory.QuantityAvailableColumn)
        End Function
        
        Public Sub SetQuantityAvailableNull()
            Me(Me.tableInventory.QuantityAvailableColumn) = System.Convert.DBNull
        End Sub
    End Class
    
    <System.Diagnostics.DebuggerStepThrough()>  _
    Public Class InventoryRowChangeEvent
        Inherits EventArgs
        
        Private eventRow As InventoryRow
        
        Private eventAction As DataRowAction
        
        Public Sub New(ByVal row As InventoryRow, ByVal action As DataRowAction)
            MyBase.New
            Me.eventRow = row
            Me.eventAction = action
        End Sub
        
        Public ReadOnly Property Row As InventoryRow
            Get
                Return Me.eventRow
            End Get
        End Property
        
        Public ReadOnly Property Action As DataRowAction
            Get
                Return Me.eventAction
            End Get
        End Property
    End Class
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -