请教老师水电费快捷计算方法,如果录入月初和月末数计量电量,只要简单加减即可,实际操作中每次要去找上月的期末数填到本月的期初数,比较麻烦
想要实现,每间房每次操表时只填本月末数,即可算出当月用电量,要怎么操作,谢谢老师
蓝老师,版本太高了,麻烦存为2019能打开的,谢谢
datacolchanged事件
Select Case e.DataCol.Name
Case "年", "月", "房号"
If e.DataRow.IsNull("年") OrElse e.DataRow.IsNull("月") OrElse e.DataRow.IsNull("房号") Then
e.DataRow("月初数") = Nothing
Else
Dim y As Integer = e.DataRow("年")
Dim m As Integer = e.DataRow("月")
Dim d As Date = New Date(y, m, 1)
d = d.AddMonths( - 1)
Dim dr As DataRow = e.DataTable.Find("年='" & d.Year & "' and 月='" & d.Month & "' and 房号='" & e.DataRow("房号") & "'")
If dr Is Nothing Then
e.DataRow("月初数") = 0
Else
e.DataRow("月初数") = dr("月末数")
End If
End If
Case "月末数", "月初数"
If e.DataRow.IsNull("月末数") OrElse e.DataRow.IsNull("月初数") Then
e.DataRow("用电量") = Nothing
Else
e.DataRow("用电量") = e.DataRow("月末数") - e.DataRow("月初数")
End If
End Select