老师好,我想在下面再增加一个判断条件(房屋主体),房屋主体下有:
一号楼
二号楼
三号楼
If e.DataCol.Name = "项目" Then
If e.DataCol.Name = "项目" OrElse e.DataCol.Name ="抄表日期" 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")
e.DataRow("总表_上期读数") = sl
End If
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
老师好,我新增一列名称为(房屋主体)如果该列字段是(二号楼)就复制本期读数,如果不是就不复制。谢谢老师!
If e.DataCol.Name = "项目" Then
If e.DataCol.Name = "项目" OrElse e.DataCol.Name ="抄表日期" 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")
e.DataRow("总表_上期读数") = sl
End If
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
If e.DataRow("房屋主体") = "二号楼" Then
If e.DataCol.Name = "项目" OrElse e.DataCol.Name ="抄表日期" Then
Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.DataRow("项目") & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")
……
老师好
此主题相关图片如下:2025-03-17 12 19 54.png

If e.DataRow("房屋主体") = "一号楼" Then
If e.DataCol.Name = "项目" OrElse e.DataCol.Name ="抄表日期" Then
Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.DataRow("项目") & "' 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")
e.DataRow("总表_上期读数") = sl
End If
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
老师,添加不好,谢谢老师帮忙。
Dim dr1 As DataRow = e.DataTable.Find("项目='" & e.DataRow("项目") & "' and 抄表日期 is not null and _sortkey <" & e.DataRow("_sortkey"), "_sortkey desc")