If e .DataCol . Name = "身份证号码" Then '如果更改的是身份证号码列
If e .DataRow . IsNull( "身份证号码" ) Then '身份证号码是否为空
e .DataRow ( "出生日期" ) = Nothing '如果为空,则清除出生日期
e .DataRow ( "性别") = Nothing
Else
'否则从身份证号码列中提取出生日期
e .DataRow ( "出生日期" ) = ReadBirthday ( e. DataRow ("身份证号码" ))
e .DataRow ( "性别") = ReadSex (e .DataRow ( "身份证号码" ))
End If
End If
If e.DataCol.name = "出生日期" Then '如果更改的是出生日期列
If e.DataRow.IsNull("出生日期") Then '出生日期是否为空
e.DataRow("年龄") = Nothing '如果为空,则清除年龄
Else
'否则从出生日期列中提取出年龄
Dim n As Integer= Date.Today.Year - e.DataRow("出生日期").Year
If e.DataRow("出生日期").AddMonths(n*12) > Date.Today Then
n = n -1
End If
e.DataRow("年龄") = n
End If
End If
(前面的已经实现了,后面代码没有办法显示出退休时间)
If e.DataCol.Name = "出生日期" Then
If e.DataRow.IsNull("出生日期") Then
e.DataRow("退休时间") = Nothing
Else If e.DataRow("性别") ="女" Then
e.DataRow("退休时间") = e.DataRow("出生日期").AddYears(50)
Else If e.DataRow("性别") ="男"
e.DataRow("退休时间") = e.DataRow("出生日期").AddYears(60)
End If
End If