Add initial implementation of BOM management classes and data structure
- Created clsBOMManager for managing BOM data - Added clsCategory and clsMaterialItem for category and material representation - Implemented methods for loading and organizing BOM data from Excel - Introduced .gitignore to exclude unnecessary files - Added metadata JSON for module tracking
This commit is contained in:
40
VBA/ClassModules/clsCategory.cls
Normal file
40
VBA/ClassModules/clsCategory.cls
Normal file
@@ -0,0 +1,40 @@
|
||||
' ========================================
|
||||
' 类模块: clsCategory
|
||||
' 用途: 表示物料类别及其层级关系
|
||||
' ========================================
|
||||
Option Explicit
|
||||
|
||||
Public categoryName As String
|
||||
Public ParentCategoryName As String
|
||||
Public Materials As Collection ' 存储 clsMaterialItem 对象
|
||||
Public SubCategories As Collection ' 存储子类别 clsCategory 对象
|
||||
Public IsLeafCategory As Boolean ' 是否叶子类别(无子类别)
|
||||
|
||||
Private Sub Class_Initialize()
|
||||
Set Materials = New Collection
|
||||
Set SubCategories = New Collection
|
||||
IsLeafCategory = True
|
||||
End Sub
|
||||
|
||||
' 添加物料
|
||||
Public Sub AddMaterial(mat As clsMaterialItem)
|
||||
Materials.Add mat, mat.code
|
||||
End Sub
|
||||
|
||||
' 添加子类别
|
||||
Public Sub AddSubCategory(cat As clsCategory)
|
||||
SubCategories.Add cat, cat.categoryName
|
||||
IsLeafCategory = False
|
||||
End Sub
|
||||
|
||||
' 获取物料(按代号)
|
||||
Public Function GetMaterial(code As String) As clsMaterialItem
|
||||
On Error Resume Next
|
||||
Set GetMaterial = Materials(code)
|
||||
On Error GoTo 0
|
||||
End Function
|
||||
|
||||
' 检查是否有子类别
|
||||
Public Function HasSubCategories() As Boolean
|
||||
HasSubCategories = (SubCategories.Count > 0)
|
||||
End Function
|
||||
Reference in New Issue
Block a user