以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关联表中的数据刷新  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=136634)

--  作者:蓝蚂蚁
--  发布时间:2019/6/17 23:10:00
--  关联表中的数据刷新

父表有一列名“发票张数”,是根据子表对应的发票号码的个数生成的,下面的代码是子表发票号码发生变化时,生成父表的发票张数。

Select Case e.DataCol.Name
    Case "发票号码"
        Dim cnt As Integer
        Dim pdr As DataRow = e.DataRow.GetParentRow("发票首页")
        Dim fdr As DataRow = e.DataTable.Find("报销单号 = \'" & e.DataRow("报销单号") & "\'", "_Sortkey")
        If pdr IsNot Nothing Then
            If fdr IsNot Nothing Then
                cnt = DataTables("发票明细").Compute("Count([发票号码])","报销单号= \'" & e.DataRow("报销单号") &"\' ")
                pdr("发票张数") = cnt
            Else
                pdr("发票张数") = 0
            End If
        End If
End Select

问题:如果我删除子表对应的一条记录,即发票个数发生了变化(即个数减少了1),如何才能刷新父表发票张数的数据?谢谢!

[此贴子已经被作者于2019/6/17 23:10:41编辑过]

--  作者:有点蓝
--  发布时间:2019/6/17 23:26:00
--  
删除到DataRowDeleting事件处理:http://www.foxtable.com/webhelp/topics/0633.htm