'===================================================================== ' 类名:BomItem ' 功能:BOM 物料项数据模型 '===================================================================== 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 BipRowNumberBase As Long ' BIP 行号基数 ' 匹配状态 Public IsMatched As Boolean ' 是否匹配 Public MatchError As String ' 匹配错误信息 '===================================================================== ' 方法:Class_Initialize ' 功能:初始化类 '===================================================================== Private Sub Class_Initialize() IsMatched = False MatchError = "" BipRowNumberBase = 7000 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 代码 Me.BipRowNumberBase = CLng(ws.Cells(row, 12).value) ' L 列:BIP 行号基数 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