三楼可能理会错楼主的意思了,用下面的代码试试。
Dim dc As DataCol = e.DataCol
Dim dr As DataRow = e.DataRow
Dim d1 As Date = dr("加班止时间")
Dim d2 As Date = dr("加班起时间")
Dim t As TimeSpan = d1 - d2
If dc.Name = "加班类型" OrElse dc.Name = "加班起时间" OrElse dc.Name = "加班止时间" Then
if dr.IsNull("加班类型") OrElse dr.IsNull("加班起时间") OrElse dr.IsNull("加班止时间") Then
dr("合计加班时间") = Nothing
dr("单位") = Nothing
Else
if dr("加班类型") = "正常工作日" Then
dr("合计加班时间") = Math.Round(t.TotalHours,2)
dr("单位") = "小时"
End If
if dr("加班类型") = "休息日" Then
if t.TotalHours > 4 Then
dr("合计加班时间") = 1
dr("单位") = "天"
ElseIf t.TotalHours > 2 Then
dr("合计加班时间") = 0.5
dr("单位") = "天"
Else
dr("合计加班时间") = Math.Round(t.TotalHours,2)
dr("单位") = "小时"
End If
End If
if dr("加班类型") = "法定节假日" Then
if t.TotalHours <= 4 Then
dr("合计加班时间") = 0.5
dr("单位") = "天"
Else
dr("合计加班时间") = 1
dr("单位") = "天"
End If
End If
End If
End If
[此贴子已经被作者于2009-1-30 15:02:16编辑过]