以文本方式查看主题 - Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp) -- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2) ---- 多记录问题 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=169121) |
|
-- 作者:lin98 -- 发布时间:2021/6/3 13:48:00 -- 多记录问题 AA(主表)和AB(明细)是关联表, DA(主表)和DB(明细)是关联表, 需求是: 当“DA(主表)”录入“产品编号”,并以“产品编号”从”AB(明细)“找到相同“产品编号”, 将其对应记录,赋值到”DB(明细)“,不要单击按键一条条新增行。 If e.DataCol.Name = "产品编号" Then Dim nms() As String = {"品名","料号","料名","数量"} If e.NewValue Is Nothing Then For Each nm As String In nms e.DataRow(nm) = Nothing Next Else Dim dr As DataRow dr = DataTables("AB").Find("[产品编号] = \'" & e.NewValue & "\'") If dr IsNot Nothing For Each nm As String In nms e.DataRow(nm) = dr(nm) Next End If End If End If 上面代码实现单条记录复制重复同一条记录,并是"产品编号"相应记录,比如:"产品编号" PD01有二记录, 而上面是在”DB(明细)“新增一行只复制”AB(明细)“其第一条 ,如何解决?谢谢 |
|
-- 作者:有点蓝 -- 发布时间:2021/6/3 13:54:00 -- 改为select查询,参考这里用法:http://www.foxtable.com/webhelp/topics/1453.htm |
|
-- 作者:lin98 -- 发布时间:2021/6/3 15:04:00 -- 在AB表放下面代码: Select Case e.DataCol.Name Case "品名","料号","料名","数量" Dim Filter As String = "[产品编号] = \'" & e.DataRow("产品编号") & "\'" Dim drs As List(Of DataRow) = DataTables("DB").Select(Filter) For Each dr As DataRow In drs dr(e.DataCol.Name) = e.NewValue Next End Select \'Select Case e.DataCol.Name \'Case "品名","料号","料名","数量" \'Dim drs As List(Of DataRow) = e.DataRow.GetChildRows("DB")) \'For Each dr As DataRow In drs \'dr(e.DataCol.Name) = e.NewValue \'Next \'End Select 使用注掉的代码,红字有问题,报错,应为结束语句,是从帮助复制过改 在DB表 If e.DataCol.Name = "产品编号" Then If e.NewValue Is Nothing Then e.DataRow("品名") = Nothing e.DataRow("料号") = Nothing e.DataRow("料号") = Nothing e.DataRow("数量") = Nothing Else Dim dr As DataRow dr = DataTables("DB").Find("[产品编号] = \'" & e.NewValue & "\'") If dr IsNot Nothing e.DataRow("品名") = dr("品名") e.DataRow("料号") = dr("料号") e.DataRow("料名") = dr("料名") e.DataRow("数量") = dr("数量") End If End If End If 上面代码,在DA表新增“产品编号”没执行,从AB表对应产品编号的记录复制到DB表。 |
|
-- 作者:有点蓝 -- 发布时间:2021/6/3 15:15:00 -- 在AB表放下面代码: Select Case e.DataCol.Name Case "品名","料号","料名","数量" Dim Filter As String = "[产品编号] = \'" & e.DataRow("产品编号") & "\'" Dim drs As List(Of DataRow) = DataTables("DB").Select(Filter) Dim nms() As String = {"品名","料号","料名","数量"} For Each dr As DataRow In drs For Each nm As String In nms dr(nm) = e.DataRow(nm) Next Next End Select 在DB表 If e.DataCol.Name = "产品编号" Then If e.NewValue Is Nothing Then e.DataRow("品名") = Nothing e.DataRow("料号") = Nothing e.DataRow("料号") = Nothing e.DataRow("数量") = Nothing Else Dim dr As DataRow dr = DataTables("AB").Find("[产品编号] = \'" & e.NewValue & "\'") If dr IsNot Nothing |
|
-- 作者:lin98 -- 发布时间:2021/6/3 15:29:00 -- 老师,效果跟最早那一种一样,并没实现在DA表新增“产品编号”没执行,从AB表对应产品编号的所有记录复制到DB表。还是只有第一条 |
|
-- 作者:有点蓝 -- 发布时间:2021/6/3 15:38:00 -- AB表和DB表,2个表数据通过什么列进行关联? |
|
-- 作者:lin98 -- 发布时间:2021/6/3 15:52:00 --
|
|
-- 作者:lin98 -- 发布时间:2021/6/3 15:54:00 -- 采用1楼和4楼结果如下: |
|
-- 作者:有点蓝 -- 发布时间:2021/6/3 16:19:00 -- AB表和DB表,2个表数据通过哪些列关联对应?“产品编号,品名,料号,料名,数量”,四个列数据一样才能对应? |
|
-- 作者:lin98 -- 发布时间:2021/6/3 16:47:00 --
|