以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]计算  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=195082)

--  作者:苏州老街
--  发布时间:2025/2/19 22:21:00
--  [求助]计算
老师好

图片点击可在新窗口打开查看此主题相关图片如下:2025-02-19 22 00 49.png
图片点击可在新窗口打开查看


If e.DataCol.Name = "项目" Then
    If e.DataRow.IsNull("项目") = False AndAlso e.DataRow.IsNull("抄表日期") = False Then
        Dim dr1 As DataRow = e.DataTable.Find("项目=\'" & e.NewValue & "\' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"),"_sortkey desc")
        If dr1 IsNot Nothing Then
            e.DataRow("总表_上期读数") = dr1("总表_本期读数")
        End If
        Dim idx As Integer = Tables(e.DataTable.name).findrow(e.DataRow)
        If idx > 0 Then
            Dim r As Row = Tables(e.DataTable.name).rows(idx-1)
            If r.isnull("购气_日期")=False
                e.DataRow("总表_上期读数") = e.DataRow("总表_上期读数")  + r("购气_数量")
            End If
        End If
    End If
End If

--  作者:有点蓝
--  发布时间:2025/2/20 9:05:00
--  
dim dr as datarow = e.DataTable.find("购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey"),"_sortkey desc")
if dr isnot nothing then
e.DataRow("总表_上期读数") = e.DataRow("总表_上期读数")  + r("购气_数量")
end if

--  作者:苏州老街
--  发布时间:2025/2/20 10:49:00
--  
老师,还是不行。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:计算购气数加上期读数.table


图片点击可在新窗口打开查看此主题相关图片如下:2025-02-19 22 00 49.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2025/2/20 11:42:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:计算购气数加上期读数.zip


--  作者:苏州老街
--  发布时间:2025/2/20 14:12:00
--  
老师好


图片点击可在新窗口打开查看此主题相关图片如下:2025-02-19 22 00 49.png
图片点击可在新窗口打开查看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table


--  作者:有点蓝
--  发布时间:2025/2/20 14:20:00
--  
不要动不动就重置列。没有上一期,期初为0是正常的。如果要保留,自己加代码判断,如果没有上一期,就保留不更改数据
--  作者:苏州老街
--  发布时间:2025/2/20 18:06:00
--  
老师,下面代码用黄色标出的代码怎样合并到用红色标出的代码中。

If e.DataCol.Name = "项目" Then
    If e.DataRow.IsNull("项目") = False AndAlso e.DataRow.IsNull("抄表日期") = False Then
        Dim dr1 As DataRow = e.DataTable.Find("项目=\'" & e.NewValue & "\' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        Dim sl As Double
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
        End If
        e.DataRow("总表_上期读数") = sl
        Dim dr2 As DataRow = e.DataTable.find("项目=\'" & e.NewValue & "\' and 购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        If dr2 IsNot Nothing Then
            e.DataRow("总表_上期读数") = sl + dr2("购气_数量")
        End If
    End If
End If



If e.DataCol.Name = "项目" Then
    If e.DataRow.IsNull("项目") = False AndAlso e.DataRow.IsNull("抄表日期") = False Then
        Dim dr1 As DataRow = e.DataTable.Find("项目=\'" & e.NewValue & "\' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"),"_sortkey desc")
        If dr1 IsNot Nothing Then            
            e.DataRow("一号楼_分表上期") = dr1("一号楼_分表本期")
            e.DataRow("二号楼_分表上期") = dr1("二号楼_分表本期")
            e.DataRow("三号楼_分表上期") = dr1("三号楼_分表本期")
        End If
        Dim idx As Integer = Tables(e.DataTable.name).findrow(e.DataRow)
        If idx > 0 Then
            Dim r As Row = Tables(e.DataTable.name).rows(idx-1)
           \' If r.isnull("购气_日期")=False
                \'e.DataRow("总表_上期读数") = e.DataRow("总表_上期读数")  + r("购气_数量")
            \'End If
        End If
    End If
End If

--  作者:有点蓝
--  发布时间:2025/2/20 19:49:00
--  
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
        e.DataRow("总表_上期读数") = sl
        End If

--  作者:苏州老街
--  发布时间:2025/2/20 21:04:00
--  
老师,这样设置只显示三号楼的数据。
If e.DataCol.Name = "项目" Then
    If e.DataRow.IsNull("项目") = False AndAlso e.DataRow.IsNull("抄表日期") = False Then
        Dim dr1 As DataRow = e.DataTable.Find("项目=\'" & e.NewValue & "\' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        Dim sl As Double
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
            sl = dr1("一号楼_分表本期")
            sl = dr1("二号楼_分表本期")
            sl = dr1("三号楼_分表本期")
End If
            e.DataRow("总表_上期读数") = sl
            e.DataRow("一号楼_分表上期") = sl
            e.DataRow("二号楼_分表上期") = sl
            e.DataRow("三号楼_分表上期") = sl
        
        Dim dr2 As DataRow = e.DataTable.find("项目=\'" & e.NewValue & "\' and 购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
        If dr2 IsNot Nothing Then
            e.DataRow("总表_上期读数") = sl + dr2("购气_数量")
        End If
    End If
End If

--  作者:有点蓝
--  发布时间:2025/2/20 21:07:00
--  
没看懂