📄 inventoryitem.vb
字号:
Imports dfs.ITracker.Data
Public Class InventoryItem
Protected _id As Integer
Protected _desc As String
Protected _partNum As String
Protected _mfgNum As String
Protected _vendorID As Integer
Protected _notes As String
Protected _reorderPt As Integer
Protected _qty As Integer
Public Property ID() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
Public Property Description() As String
Get
Return _desc
End Get
Set(ByVal value As String)
_desc = value
End Set
End Property
Public Property PartNumber() As String
Get
Return _partNum
End Get
Set(ByVal value As String)
_partNum = value
End Set
End Property
Public Property MFGNumber() As String
Get
Return _mfgNum
End Get
Set(ByVal value As String)
_mfgNum = value
End Set
End Property
Public Property VendorID() As Integer
Get
Return _vendorID
End Get
Set(ByVal value As Integer)
_vendorID = value
End Set
End Property
Public Property Notes() As String
Get
Return _notes
End Get
Set(ByVal value As String)
_notes = value
End Set
End Property
Public Property ReorderPoint() As Integer
Get
Return _reorderPt
End Get
Set(ByVal value As Integer)
_reorderPt = value
End Set
End Property
Public Property Quantity() As Integer
Get
Return _qty
End Get
Set(ByVal value As Integer)
_qty = value
End Set
End Property
Public Shared Function Save(ByVal inventory As InventoryItem) As Boolean
If InventoryDataService.Save(inventory.ID, inventory.Description, inventory.PartNumber, inventory.MFGNumber, inventory.VendorID, inventory.Notes, inventory.ReorderPoint, inventory.Quantity) > 0 Then
Return True
Else
Return False
End If
End Function
Public Shared Function Fetch(ByVal id As Integer) As InventoryItem
Dim ds As DataSet = InventoryDataService.Fetch(id)
If Not ds Is Nothing AndAlso ds.Tables.Count > 0 AndAlso ds.Tables(0).Rows.Count > 0 Then
Return ConvertToObject(ds.Tables(0).Rows(0))
Else
Return Nothing
End If
End Function
Public Shared Function FetchList() As InventoryItemList
Dim ds As DataSet = InventoryDataService.FetchList
Dim inventorylist As InventoryItemList = Nothing
If Not ds Is Nothing AndAlso ds.Tables.Count > 0 Then
For Each dr As DataRow In ds.Tables(0).Rows
inventorylist.Add(ConvertToObject(dr))
Next
End If
Return inventorylist
End Function
Public Shared Function Search(ByVal ID As Integer, ByVal Description As String, ByVal partNumber As String, ByVal mfgNumber As String, ByVal vendorid As Integer) As InventoryItemList
Dim _inventoryItemList As New InventoryItemList
Dim ds As DataSet = InventoryDataService.Search(ID, Description, partNumber, mfgNumber, vendorid)
If Not ds Is Nothing AndAlso ds.Tables.Count > 0 Then
For Each dr As DataRow In ds.Tables(0).Rows
_inventoryItemList.Add(ConvertToObject(dr))
Next
End If
Return _inventoryItemList
End Function
Private Shared Function ConvertToObject(ByVal dr As DataRow) As InventoryItem
Dim _inventory As New InventoryItem
With _inventory
.ID = CInt(dr("inv_id"))
.Description = dr("inv_desc").ToString
.MFGNumber = dr("inv_mfgnum").ToString
.Notes = dr("inv_notes").ToString
.PartNumber = dr("inv_partnum").ToString
.Quantity = CInt(dr("inv_qty"))
.ReorderPoint = CInt(dr("inv_reorderpt"))
.VendorID = CInt(dr("vendor_id"))
End With
Return _inventory
End Function
End Class
Public Class InventoryItemList
Inherits Generic.List(Of InventoryItem)
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -