Select Case e.DataCol.name
Case "身份证号码"
If e.DataRow.IsNull("身份证号码") Then
e.DataRow("出生地点") = Nothing
e.DataRow("籍贯") = Nothing
e.DataRow("国籍") = Nothing
e.DataRow("出生日期") = Nothing
ElseIf ValidPIN(e.NewValue)
e.DataRow("出生日期") = ReadBirthday(e.NewValue)
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
Case "出生日期"
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
Case "出院日期","入院日期"
Dim rq As DataRow = e.DataRow
Dim t As TimeSpan
If rq.IsNull("入院日期") OrElse rq.IsNull("入院日期") Then
rq("住院天数") = Nothing
Else
t = rq("出院日期")-rq("入院日期")
rq("住院天数") = t.Days
End If
End Select