Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "有功起码","有功止码"
If dr.IsNull("有功起码") OrElse dr.IsNull("有功止码") Then
dr("有走字") = Nothing
ElseIf dr("有功止码") >= dr("有功起码") Then
dr("有走字") = dr("有功止码") - dr("有功起码")
ElseIf dr("有功起码") < 99.99 Then
dr("有走字") = dr("有功止码") - dr("有功起码") + 100
ElseIf dr("有功起码") < 999.99 Then
dr("有走字") = dr("有功止码") - dr("有功起码") + 1000
ElseIf dr("有功起码") < 9999.99 Then
dr("有走字") = dr("有功止码") - dr("有功起码") + 10000
ElseIf dr("有功起码") < 99999.99 Then
dr("有走字") = dr("有功止码") - dr("有功起码") + 100000
End If
If dr.IsNull("有功电量") OrElse dr.IsNull("无功电量") Then
dr("无功功率") = Nothing
dr("无功电费") = Nothing
ElseIf dr("无功电量") >= dr("有功电量") * 0.75 Then
dr ("无功电费") = 0
dr("无功功率") = 1 / math.Sqrt(1 + (dr("无功电量")^2 / dr("有功电量")^2))
ElseIf dr("无功电量") < dr("有功电量") * 0.75 Then
dr ("无功电费") = dr("有功电量") * 0.75 - dr("无功电量") * 0.01
' Else
dr("无功功率") = 1 / math.Sqrt(1 + (dr("无功电量")^2 / dr("有功电量")^2))
End If
Case "无功起码","无功止码"
If dr.IsNull("无功起码") OrElse dr.IsNull("无功止码") Then
dr("无走字") = Nothing
ElseIf dr("无功止码") >= dr("无功起码") Then
dr("无走字") = dr("无功止码") - dr("无功起码")
ElseIf dr("无功起码") < 99.99 Then
dr("无走字") = dr("无功止码") - dr("无功起码") + 100
ElseIf dr("无功起码") < 999.99 Then
dr("无走字") = dr("无功止码") - dr("无功起码") + 1000
ElseIf dr("无功起码") < 9999.99 Then
dr("无走字") = dr("无功止码") - dr("无功起码") + 10000
ElseIf dr("无功起码") < 99999.99 Then
dr("无走字") = dr("无功止码") - dr("无功起码") + 100000
End If
If dr.IsNull("有功电量") OrElse dr.IsNull("无功电量") Then
dr("无功功率") = Nothing
dr("无功电费") = Nothing
ElseIf dr("无功电量") >= dr("有功电量") * 0.75 Then
dr ("无功电费") = 0
dr("无功功率") = 1 / math.Sqrt(1 + (dr("无功电量")^2 / dr("有功电量")^2))
ElseIf dr("无功电量") < dr("有功电量") * 0.75 Then
dr ("无功电费") = dr("有功电量") * 0.75 - dr("无功电量") * 0.01
dr("无功功率") = 1 / math.Sqrt(1 + (dr("无功电量")^2 / dr("有功电量")^2))
End If
End Select