以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  删除行时,刷新计算  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96101)

--  作者:漂亮美眉vszh
--  发布时间:2017/2/13 11:59:00
--  删除行时,刷新计算

各位老师,我在进出明细记录内录入数据,表属性在datacolchanged内写入计算代码:总账 “物料代码”就会刷新; 可是当删除行时,总账上的总数就不会自动扣除;于是我又将这个语句写入删除时执行的代码中,依然不会刷新汇总数据,各位老师帮我看看,我刷新重新计算的代码要写在哪里?

 Case "入库数量"
        e.DataRow.Save()
        Dim dr As DataRow
        dr = DataTables("物料信息").Find("物料代码 = \'" & e.DataRow("物料代码") & "\'" )
        If dr IsNot Nothing \'如果找到, 则设置各列内容
           
            dr("入库数量") = DataTables("进出明细记录").SQLCompute("Sum(入库数量)","物料代码 = \'" & e.DataRow("物料代码") & "\'")
            dr.Save()
        End If
    Case "出库数量"
        e.DataRow.Save()
        Dim dr As DataRow
        dr = DataTables("物料信息").Find("物料代码 = \'" & e.DataRow("物料代码") & "\'" )
        If dr IsNot Nothing \'如果找到, 则设置各列内容
           
            dr("出库数量") = DataTables("进出明细记录").SQLCompute("Sum(出库数量)","物料代码 = \'" & e.DataRow("物料代码") & "\'")
            dr.Save()
        End If


--  作者:漂亮美眉vszh
--  发布时间:2017/2/13 12:01:00
--  
我在datarowdeleting 中写的代码删除时刷新汇总数据的代码 :

e.DataRow.Save()
Dim dr As DataRow
\'MessageBox.Show(1)
dr = DataTables("物料信息").Find("物料代码 = \'" & e.DataRow("物料代码") & "\'" )
If dr IsNot Nothing \'如果找到, 则设置各列内容
   \' MessageBox.Show(2)
    dr("入库数量") = DataTables("进出明细记录").SQLCompute("Sum(入库数量)","物料代码 = \'" & e.DataRow("物料代码") & "\'") - e.DataRow("入库数量")
    dr("出库数量") = DataTables("进出明细记录").SQLCompute("Sum(出库数量)","物料代码 = \'" & e.DataRow("物料代码") & "\'") - e.DataRow("出库数量")
   


End If


--  作者:有点色
--  发布时间:2017/2/13 12:22:00
--  

datarowdeleting 事件,如果msgbox(2)弹出,肯定会改的。


Dim dr As DataRow
MessageBox.Show(1)
dr = DataTables("物料信息").Find("物料代码 = \'" & e.DataRow("物料代码") & "\'" )
If dr IsNot Nothing \'如果找到, 则设置各列内容
    MessageBox.Show(2)

SystemReady = False
    dr("入库数量") = DataTables("进出明细记录").SQLCompute("Sum(入库数量)","物料代码 = \'" & e.DataRow("物料代码") & "\'") - e.DataRow("入库数量")
    dr("出库数量") = DataTables("进出明细记录").SQLCompute("Sum(出库数量)","物料代码 = \'" & e.DataRow("物料代码") & "\'") - e.DataRow("出库数量")
SystemReady = True
End If