不要简单的代码都不会改好吧?你最后的项目,能够是别人帮你写好的么?
Select Case e.DataCol.Name
Case "身份证号", "报销起日", "记录时间", "报销止日"
If e.DataCol.Name = "记录时间" AndAlso e.DataRow.IsNull(e.DataCol) = False Then
Dim dr As DataRow = e.DataTable.Find("身份证号 = '" & e.DataRow("身份证号") & "' and 报销起日 = #" & e.DataRow("报销起日") & "# and _Identify <> '" & e.DataRow("_Identify") & "' and 记录时间 <= #" & e.DataRow("记录时间") & "#","记录时间 Desc")
If dr IsNot Nothing Then
Dim tp As TimeSpan = e.DataRow("记录时间") - dr("记录时间")
e.DataRow("天数") = tp.TotalDays
dr = e.DataTable.Find("身份证号 = '" & e.DataRow("身份证号") & "' and 报销起日 = #" & e.DataRow("报销起日") & "# And 记录时间 <= #" & e.DataRow("记录时间") & "#","记录时间 Desc")
If dr IsNot Nothing Then
If dr.IsNull("报销止日") Then
tp = dr("记录时间") - Date.Today
e.DataRow("距今天数") = tp.TotalDays
Else
tp = dr("记录时间") - dr("报销止日")
e.DataRow("距今天数") = tp.TotalDays
End If
End If
Else
e.DataRow("天数") = 0
End If
End If
End Select