以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  自动加减数量的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=128330)

--  作者:蓝蚂蚁
--  发布时间:2018/12/4 9:49:00
--  自动加减数量的问题

不知道写什么主题好,就用【自动加减数量的问题】哈哈

 相关描述见下图:


图片点击可在新窗口打开查看此主题相关图片如下:image 1.jpg
图片点击可在新窗口打开查看

 

删除下表最后一条记录时提示的错误,见下图

图片点击可在新窗口打开查看此主题相关图片如下:image 2.jpg
图片点击可在新窗口打开查看


 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:自动加减.zip


--  作者:y2287958
--  发布时间:2018/12/4 10:04:00
--  
具体逻辑不明白,按照原代码要判断一下当前行是否存在。
If Tables("盈亏对账主窗口_Table2").Rows.Count>0 Then
    If Tables("盈亏对账主窗口_Table2").Current.IsNull("盈亏号") = False Then
        If MessageBox.Show("是否删除","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)=DialogResult.Yes Then
            Tables("盈亏对账主窗口_Table2").Current.Delete
            If Tables("盈亏对账主窗口_Table2").Current IsNot Nothing
                Dim SumT1 As Integer=DataTables("盈亏对账数量表").Compute("Sum(对账数量)","[盈亏号] = \'" & Tables("盈亏对账主窗口_Table2").Current("盈亏号")&  "\'")
                Dim dr As DataRow = DataTables("盈亏待对账表").Find("盈亏号=\'" &  Tables("盈亏对账主窗口_Table2").Current("盈亏号")&  "\'")
                If dr IsNot Nothing Then
                    dr("已对账数量")=SumT1
                End If
                Dim SumT2 As Integer= DataTables("盈亏对账数量表").Compute("Sum(对账盈亏号数量)","[对账盈亏号] = \'" & Tables("盈亏对账主窗口_Table2").Current("对账盈亏号")& "\'")
                Dim drzb As DataRow = DataTables("盈亏待对账表").Find("盈亏号=\'" &  Tables("盈亏对账主窗口_Table2").Current("对账盈亏号")& "\'")
                If drzb IsNot Nothing Then
                    drzb("已对账数量")=SumT2*-1
                    drzb("处理后数量")=drzb("亏损")+ drzb("已对账数量")
                End If
            End If
        End If
    Else
        Tables("盈亏对账主窗口_Table2").Current.Delete
    End If
End If

--  作者:蓝蚂蚁
--  发布时间:2018/12/4 10:16:00
--  

首先,谢谢老师的解答,按照你的提示,把删除按钮代码修改后,没有提示错误,但已对账数量和处理后数量没有变化


图片点击可在新窗口打开查看此主题相关图片如下:image 3.jpg
图片点击可在新窗口打开查看


--  作者:有点甜
--  发布时间:2018/12/4 10:34:00
--  
If Tables("盈亏对账主窗口_Table2").Rows.Count>0 Then
    If Tables("盈亏对账主窗口_Table2").Current.IsNull("盈亏号") = False Then
        If MessageBox.Show("是否删除","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question)=DialogResult.Yes Then
            Dim r As Row = Tables("盈亏对账主窗口_Table2").Current
            Dim n1 = r("盈亏号")
            Dim n2 = r("对账盈亏号")
            r.Delete
            Dim SumT1 As Integer=DataTables("盈亏对账数量表").Compute("Sum(对账数量)","[盈亏号] = \'" & n1 &  "\'")
            Dim dr As DataRow = DataTables("盈亏待对账表").Find("盈亏号=\'" & n1 &  "\'")
            If dr IsNot Nothing Then
                dr("已对账数量")=SumT1
            End If
            Dim SumT2 As Integer= DataTables("盈亏对账数量表").Compute("Sum(对账盈亏号数量)","[对账盈亏号] = \'" & n2 & "\'")
            Dim drzb As DataRow = DataTables("盈亏待对账表").Find("盈亏号=\'" & n2 & "\'")
            If drzb IsNot Nothing Then
                drzb("已对账数量")=SumT2*-1
                drzb("处理后数量")=drzb("亏损")+ drzb("已对账数量")
            End If
        End If
    Else
        Tables("盈亏对账主窗口_Table2").Current.Delete
    End If
End If

--  作者:蓝蚂蚁
--  发布时间:2018/12/4 10:46:00
--  
谢谢,有点甜  你真是神人啊  完美解决,老师收徒弟吗 我跪拜了  哈哈