Dim tb As Table = Tables("配件计划")
Dim r As Row = Tb.current
If r IsNot Nothing Then
If tb.GetCheckedRows.count = 0 Then
messagebox.show("没有可用于生成 配件采购单 的数据信息!","提示")
Return
ElseIf tb.GetCheckedRows.count > 0 Then
Dim Result As DialogResult
Result = MessageBox.Show("是否要根据 ""计划需求数量"" 生成 配件采购单 ?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim dic As new Dictionary(of String, Row)
For i As Integer = 0 To Tb.GetCheckedRows.count -1
Dim r1 As Row = tb.GetCheckedRows(i)
If dic.ContainsKey(r1("供应商编号")) = False
dic.add(r1("供应商编号"), Tables("配件采购主表").addnew())
End If
Dim r3 As Row = dic(r1("供应商编号"))
r3("配件采购系统编号") = "PJCG-"
r3("供应商名称") = r1("供应商名称")
r3("供应商编号") = r1("供应商编号")
r3("开单员") = user.name
r3("开单日期") = Date.Today
Dim r2 As Row = Tables("配件采购子表").addnew()
Dim nms() As String = {"配件编号","配件名称","配件规格","货品单位","配件品牌","配件材质","货品类别","货品颜色"}
r2("供应商编号") = r1("供应商编号")
For Each nm As String In nms
r2(nm) = r1(nm)
r2("配件数量") = r1("计划需求数量")
Next
Next
Forms("配件计划").close()
End If
End If
End If
如果有问题,尽量发实例上来测试。