以下是图例中【转换】按钮的代码,将用料表的数据复制到BOM。每次复制时都要新增行。现在需要【修改】按钮的代码,取消转换勾选,不新增行,只是对现有数据进行修改。
'DataTables("产品BOM").DataRows.Clear
Dim drs As List(Of DataRow) = DataTables("用料").Select("[导体] Is Not Null And [转换] = False")
If drs.Count = 0 Then
MessageBox.Show("没有新数据!")
Return
Else
'生成BOM
Tables("BOM").StopRedraw
For Each dr As DataRow In drs
For Each dc As DataCol In DataTables("用料").DataCols
Select Case dc.Name
Case "产品分类","型号","规格","转换"
Case Else
If dr.IsNull(dc.Name) = False Then
Dim n As Row = Tables("BOM").Addnew
n("产品分类") = dr("产品分类")
n("型号") = dr("型号")
n("规格") = dr("规格")
n("材料分类") = dc.Name
n("结构用料") = dr(dc.Name)
End If
End Select
Next
dr("转换") = True
Next
Tables("BOM").ResumeRedraw
End If
此主题相关图片如下:snap1.jpg