If e.DataCol.Name = "身份证号码" Then '是身份证号码发生变化吗?
If e.DataRow.IsNull("身份证号码") Then '身份证号码是否为空
e.DataRow("出生日期") = Nothing '如果为空,则清除出生日期
Else
'否则从身份证号码列中提取出生日期
e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号码"))
End If
ElseIf e.DataCol.name = "出生日期" Then
If e.newvalue <> Nothing Then
Dim y As Integer = e.NewValue.year
If format(e.newvalue, "MMdd") <= Format(Date.Today, "MMdd") Then
e.DataRow("年龄") = Date.Today.Year - y
Else
e.DataRow("年龄") = Date.Today.Year - y -1
End If
Else
e.DataRow("年龄") = Nothing
End If
End If
Select Case e.DataCol.name
Case "身份证号码"
If e.DataRow.IsNull("身份证号码") Then
e.DataRow("出生地点") = Nothing
e.DataRow("籍贯") = Nothing
e.DataRow("国籍") = Nothing
Else
Dim szd As String = e.DataRow("身份证号码").SubString(0,6)
Dim jg As String = e.DataRow("身份证号码").SubString(0,2)
Dim gj As String = e.DataRow("身份证号码").SubString(0,1)
Dim dr As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = '" & szd & "'")
Dim dc As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = '" & jg & "'")
Dim dt As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = '" & gj & "'")
If dr IsNot Nothing Then
e.DataRow("出生地点") = dr("哈文名称")
e.DataRow("籍贯") = dc("哈文名称")
e.DataRow("国籍") = dt("哈文名称")
End If
End If
End Select
Dim rq As DataRow = e.DataRow
Dim t As TimeSpan
If e.DataCol.Name = "出院日期" Then
If rq.IsNull("入院日期") OrElse rq.IsNull("入院日期") Then
rq("住院天数") = Nothing
Else
t = rq("出院日期")-rq("入院日期")
rq("住院天数") = t.Days
End If
End If