Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
Select Case e.DataCol.Name
Case "客户","产品"
Dim kh As String = e.DataRow("客户")
Dim cp As String = e.DataRow("产品")
Dim tj = "客户 = '" & kh & "' And 产品 = '" & cp & "' "
If kh >"" Andalso cp> "" Then
If DataTables("表B").Find(tj) Is Nothing Then
Dim dr As DataRow = DataTables("表B").AddNew()
dr("客户") = kh
dr("产品") = cp
End If
End If
End Select
这个代码是在A表输入客户,产品的同时,在B表新增行输入客户,产品.
假定表A是父表,表B是子表,代码大概如下,请自行理解调试:
Dim Childs As List(of DataRow) = Tables("表A").Current.DataRow.GetChildRows("表B")
Dim pr As Row = Tables("表A").AddNew
pr("关联列") = "aaa" '如果通过_Identify列关联,则不需要此行
For Each cr As DataRow In Childs
Dim nr As Row = Tables("表A.表B").AddNew
For Each cl As Col In Tables("表B").Cols
If cl.Name <> "关联列" Then
nr(cl.name) = cr(cl.Name)
End If
Next
Next
Dim r1 As Row = Tables("父表").Current
Dim r2 As Row= r1.Clone
For Each r3 As DataRow = r1.DataRow.GetChildRows("子表")
Dim r4 As Row = Tables("子表").AddNew
For c As Col In Tables("子表").Cols
r4(c.Name) = r3(c.Name)
Next
r4("子表关联列") = r2("父表关联列")
Next
试试这个,我以前保存下来的.
谢谢大家的帮助,晚上搞定这个。再次谢谢大家。
希望给个示例看看,谢谢各位前辈。