Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共18 条记录, 每页显示 10 条, 页签: [1] [2]
[浏览完整版]

标题:[求助]计算

1楼
苏州老街 发表于: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
2楼
有点蓝 发表于: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
3楼
苏州老街 发表于:2025/2/20 10:49:00
老师,还是不行。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:计算购气数加上期读数.table


图片点击可在新窗口打开查看此主题相关图片如下:2025-02-19 22 00 49.png
图片点击可在新窗口打开查看
4楼
有点蓝 发表于:2025/2/20 11:42:00
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:计算购气数加上期读数.zip

5楼
苏州老街 发表于:2025/2/20 14:12:00
老师好


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

6楼
有点蓝 发表于:2025/2/20 14:20:00
不要动不动就重置列。没有上一期,期初为0是正常的。如果要保留,自己加代码判断,如果没有上一期,就保留不更改数据
7楼
苏州老街 发表于: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
8楼
有点蓝 发表于:2025/2/20 19:49:00
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
        e.DataRow("总表_上期读数") = sl
        End If
9楼
苏州老街 发表于: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
10楼
有点蓝 发表于:2025/2/20 21:07:00
没看懂
共18 条记录, 每页显示 10 条, 页签: [1] [2]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .04688 s, 5 queries.