1、
Dim jzr As Integer = e.form.Controls("TextBox2").Value
Dim b1 As WinForm.Control=e.form.Controls("Button1")
Dim t As WinForm.Control = e.form.Controls("TextBox2")
If Tables("工单主表.工单子表").Rows.Count > 0 Then
MessageBox.show("已经生成过了")
Return
End If
For Each dr1 As DataRow In DataTables("BOM子表").Select("BOM母件编码 = " & jzr )
Dim r2 As Row = Tables("工单主表.工单子表").AddNew()
r2("BOM子件编码")=dr1("BOM子件编码")
r2("用料名称")=dr1("子件名称")
r2("比例")=dr1("用料比例")
Next
'b1.Enabled=False
2、工单主表的DataColChanging事件(注意不是DataColChanged):
Select Case e.DataCol.name
Case "BOM母件编码"
Dim drs As List(of DataRow) = e.DataRow.GetChildRows("工单子表")
For Each dr As DataRow In drs
dr.Delete
Next
End Select