Foxtable(狐表)用户栏目专家坐堂 → [求助]计算


  共有224人关注过本帖树形打印复制链接

主题:[求助]计算

帅哥哟,离线,有人找我吗?
苏州老街
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
[求助]计算  发帖心情 Post By: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楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/20 10:49:00 [显示全部帖子]

老师,还是不行。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:计算购气数加上期读数.table


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

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/20 14:12:00 [显示全部帖子]

老师好


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


 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/20 22:16: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

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/21 8:17:00 [显示全部帖子]

老师,下面代码还是连续相加了。

图片点击可在新窗口打开查看此主题相关图片如下:捕获.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")
        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

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/21 12:48:00 [显示全部帖子]

谢谢老师

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/21 12:51: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
dim st as Decimal=0
        If dr1 IsNot Nothing Then
            sl = dr1("总表_本期读数")
st  = dr1("_sortkey")
        End If
        e.DataRow("总表_上期读数") = sl
        Dim dr2 As DataRow = e.DataTable.find("项目='" & e.NewValue & "' and 购气_数量 is not null and _sortkey <" & e.DataRow("_sortkey") & " and _sortkey > " & st, "_sortkey desc")
        If dr2 IsNot Nothing Then
            e.DataRow("总表_上期读数") = sl + dr2("购气_数量")
        End If 
    End If
End If

 回到顶部
帅哥哟,离线,有人找我吗?
苏州老街
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:778 积分:4955 威望:0 精华:0 注册:2016/10/19 16:45:00
  发帖心情 Post By:2025/2/21 18:42:00 [显示全部帖子]

老师,怎样判断?搞不好。
[此贴子已经被作者于2025/2/21 21:41:21编辑过]

 回到顶部
总数 12 1 2 下一页