Select Case e.DataCol.name
Case "第1段", "第2段", "第3段", "第4段", "第5段", "第6段"
Dim dr As DataRow = e.DataRow
If dr.IsNull("第1段") Then
dr("卡一") = Nothing
Else
Dim dr2 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr2 IsNot Nothing Then
Dim tp As TimeSpan
If dr("第1段") > dr2("第1段") Then
Dim tp1 As Double = (dr("第1段") - dr2("第1段")).TotalSeconds()
dr("卡一") = tp'真正的时段型数据要转换为秒数,才能存入时段列
Else
tp = dr2("第1段").adddays(1) - dr("第1段")
End If
dr("卡一") = tp.TotalSeconds() '
End If
Dim dr02 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr02 IsNot Nothing Then
Dim tp01 As TimeSpan
If dr("第2段") > dr02("第2段") Then
Dim tp2 As Double = (dr("第2段") - dr02("第2段")).TotalSeconds()
dr("卡二") = tp01'真正的时段型数据要转换为秒数,才能存入时段列
Else
tp01 = dr02("第2段").adddays(1) - dr("第2段")
End If
dr("卡二") = tp01.TotalSeconds() '
End If
Dim dr3 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr3 IsNot Nothing Then
Dim tp02 As TimeSpan
If dr("第3段") > dr3("第3段") Then
Dim tp3 As Double = (dr("第3段") - dr3("第3段")).TotalSeconds()
dr("卡三") = tp02'
Else
tp02 = dr3("第3段").adddays(1) - dr("第3段")
End If
dr("卡三") = tp02.TotalSeconds() '
End If
Dim dr4 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr4 IsNot Nothing Then
Dim tp03 As TimeSpan
If dr("第4段") > dr4("第4段") Then
Dim tp4 As Double = (dr("第4段") - dr4("第4段")).TotalSeconds()
dr("卡四") = tp03'
Else
tp03 = dr4("第4段").adddays(1) - dr("第4段")
End If
dr("卡四") = tp03.TotalSeconds() '
End If
Dim dr5 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr5 IsNot Nothing Then
Dim tp04 As TimeSpan
If dr("第5段") > dr5("第5段") Then
Dim tp5 As Double = (dr("第5段") - dr5("第5段")).TotalSeconds()
dr("卡五") = tp04'
Else
tp04 = dr5("第5段").adddays(1) - dr("第5段")
End If
dr("卡五") = tp04.TotalSeconds() '
End If
Dim dr6 As DataRow = DataTables("时间").find("类别='" & dr("类别") & "'")
If dr6 IsNot Nothing Then
Dim tp05 As TimeSpan
If dr("第6段") > dr6("第6段") Then
Dim tp6 As Double = (dr("第6段") - dr6("第6段")).TotalSeconds()
dr("卡六") = tp05'
Else
tp05 = dr6("第6段").adddays(1) - dr("第6段")
End If
dr("卡六") = tp05.TotalSeconds() '
End If
End If
End Select
上面写没报错,但执行时,报错:详细错误信息:
调用的目标发生了异常。
参数“Expression”无法转换为类型“TimeSpan”。