以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]计算 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=194488) |
||||
-- 作者:苏州老街 -- 发布时间:2024/12/16 14:03:00 -- [求助]计算 老师,怎样把购气_数量列的数据加到总表_上期列中。
![]() ![]() |
||||
-- 作者:有点蓝 -- 发布时间:2024/12/16 14:28:00 -- 如果有多行购气_数量,取哪一行的 |
||||
-- 作者:苏州老街 -- 发布时间:2024/12/16 14:36:00 -- 老师,项目为燃气的才能相加,购气_数量和下一行项目为燃气的总表_上期相加。谢谢老师 |
||||
-- 作者:有点蓝 -- 发布时间:2024/12/16 15:10:00 -- 和这里的用法一样,使用find查询最后一个购气日期的行,然后赋值:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=194487&skin=0 |
||||
-- 作者:苏州老街 -- 发布时间:2024/12/16 20:24:00 -- 老师,搞不好。 If e.DataCol.Name = "项目" Then If e.DataRow.IsNull("项目") = False Then Dim dr2 As DataRow = e.DataTable.Find("项目=\'" & e.NewValue & "\' and _sortkey <" & e.DataRow("_sortkey"),"_sortkey desc") If dr2 IsNot Nothing Then dr2("总表_本期读数") = dr("总表_上期读数") + dr("购气_数量") End If End If End If ![]() ![]()
|
||||
-- 作者:有点蓝 -- 发布时间:2024/12/16 21:30:00 -- 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 dr("总表_本期读数") = dr("总表_上期读数") + dr2("购气_数量") End If |
||||
-- 作者:苏州老街 -- 发布时间:2024/12/16 22:22:00 -- 老师,我想加在上期上否则总表_消耗数为出现负数。老师谢谢了 If dr2 IsNot Nothing Then dr("总表_上期读数") = dr("总表_上期读数") + dr2("购气_数量") End If [此贴子已经被作者于2024/12/16 22:23:22编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2024/12/16 22:29:00 -- 没看懂 |
||||
-- 作者:苏州老街 -- 发布时间:2024/12/16 22:50:00 -- 老师,标出的代码不计算 Dim dr As DataRow = e.DataRow Select Case e.DataCol.Name Case "总表_本期读数","总表_上期读数" If dr.IsNull("总表_本期读数") OrElse dr.IsNull("总表_上期读数") Then dr("总表_消耗数") = Nothing Else If dr("项目") <>"燃气" Then dr("总表_消耗数") = dr("总表_本期读数") - dr("总表_上期读数") Else dr("总表_消耗数") = dr("总表_上期读数") - dr("总表_本期读数") End If End If End Select If e.DataCol.Name = "项目" Then If e.DataRow.IsNull("项目") = False Then 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 dr("总表_上期读数") = dr2("购气_数量") + dr("总表_上期读数") 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("总表_本期读数") End If End If End If
|
||||
-- 作者:有点蓝 -- 发布时间:2024/12/16 22:54:00 -- 被第3段代码给覆盖了,后面2段代码合并到一起 |