Files
AutoBOM/VBA/ClassModules/BomItem.cls
Misaka 79dc7cbf72 feat: add core VBA source code modules
Add VBA directory with essential project code including:
- ClassModules: BomExtractor, BomItem, ConditionEvaluator, ProductModelParser
- Modules: MainModule, TestModule
- Forms and DocumentModules
- vba_metadata.json for module metadata

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 16:18:17 +08:00

89 lines
3.3 KiB
OpenEdge ABL

'=====================================================================
' 类名: BomItem
' 功能: BOM物料项数据模型
' 作者: Auto-generated
' 日期: 2025-01-29
'=====================================================================
Option Explicit
' 物料属性
Public RowNumber As Long ' 行号
Public Module As String ' 模块
Public code As String ' 代号
Public Name As String ' 名称
Public Quantity As Double ' 数量
Public SelectCondition As String ' 选择条件
Public Remark As String ' 备注
Public category As String ' 类别
Public ParentCategory As String ' 上层类别
Public CategoryCondition As String ' 类别选用条件
Public Code66 As String ' 66代码
' 匹配状态
Public IsMatched As Boolean ' 是否匹配
Public MatchError As String ' 匹配错误信息
'=====================================================================
' 方法: Class_Initialize
' 功能: 初始化类
'=====================================================================
Private Sub Class_Initialize()
IsMatched = False
MatchError = ""
End Sub
'=====================================================================
' 方法: LoadFromRow
' 功能: 从工作表行加载数据
' 参数: ws - 工作表对象
' row - 行号
'=====================================================================
Public Sub LoadFromRow(ws As Worksheet, row As Long)
On Error Resume Next
Me.RowNumber = CLng(ws.Cells(row, 1).value) ' A列: 行号
Me.Module = CStr(ws.Cells(row, 2).value) ' B列: 模块
Me.code = CStr(ws.Cells(row, 3).value) ' C列: 代号
Me.Name = CStr(ws.Cells(row, 4).value) ' D列: 名称
Me.Quantity = CDbl(ws.Cells(row, 5).value) ' E列: 数量
Me.SelectCondition = CStr(ws.Cells(row, 6).value) ' F列: 选择条件
Me.Remark = CStr(ws.Cells(row, 7).value) ' G列: 备注
Me.category = CStr(ws.Cells(row, 8).value) ' H列: 类别
Me.ParentCategory = CStr(ws.Cells(row, 9).value) ' I列: 上层类别
Me.CategoryCondition = CStr(ws.Cells(row, 10).value) ' J列: 类别选用条件
Me.Code66 = CStr(ws.Cells(row, 11).value) ' K列: 66代码
On Error GoTo 0
End Sub
'=====================================================================
' 方法: IsValidItem
' 功能: 判断是否为有效物料(类别字段不为空)
' 返回: Boolean
'=====================================================================
Public Function IsValidItem() As Boolean
IsValidItem = (Trim(Me.category) <> "")
End Function
'=====================================================================
' 方法: HasParentCategory
' 功能: 判断是否有父类别
' 返回: Boolean
'=====================================================================
Public Function HasParentCategory() As Boolean
HasParentCategory = (Trim(Me.ParentCategory) <> "")
End Function
'=====================================================================
' 方法: ToString
' 功能: 转换为字符串描述
' 返回: String
'=====================================================================
Public Function ToString() As String
ToString = "行号:" & Me.RowNumber & _
" | 类别:" & Me.category & _
" | 代号:" & Me.code & _
" | 名称:" & Me.Name
End Function