Select Case e.DataCol.Name
Case "进厂日期","出厂日期"
Dim dr As DataRow = e.DataRow
If dr.IsNull("进厂日期") OrElse dr.IsNull("出厂日期") Then
dr("天差") = Nothing
Else
Dim n As Integer = (dr("出厂日期") - dr("进厂日期")).TotalDays
dr("天差") = n
End If
End Select
Select Case e.DataCol.Name
Case "进厂时间","出厂时间"
If e.DataRow.IsNull(e.DataCol.Name) Then
e.DataRow("时差") = Nothing
Else
Dim t As TimeSpan
If e.DataRow("出厂时间") > e.DataRow("进厂时间")
t = e.DataRow("出厂时间") - e.DataRow("进厂时间")
Else
t = e.DataRow("出厂时间").AddHours(24) - e.DataRow("进厂时间")
End If
e.DataRow("时差") = t.Hours & "小时" & t.Minutes & "分"
End If
End Select