If e.DataCol.Name = "项目名称" Then '如果更改的是身份证号码列
If e.DataRow.IsNull("项目名称") Then '身份证号码是否为空
e.DataRow("项目代码") = Nothing '如果为空,则清除出生日期
Else
Dim dr As DataRow
dr = DataTables("表A").Find("项目名称 = " & "'" & e.DataRow("项目名称") & "'" )
If dr IsNot Nothing '如果找到, 则设置各列内容
e.DataRow("项目代码")= dr("项目编号")
End If
End If
End If
If e.DataCol.Name = "项目名称" Then '如果更改的是身份证号码列
If e.DataRow.IsNull("项目名称") Then '身份证号码是否为空
e.DataRow("项目代码") = Nothing
e.DataRow("档案序号") = Nothing
Else
Dim drs As List(of DataRow) = e.DataTable.Select("[项目名称] = '" & e.DataRow("项目名称") & "' And 档案序号 Is Not Null", "[_Identify]")
If drs.count = 0 Then
e.DataRow("档案序号")= e.DataRow("项目代码") & "001"
Else
Dim bn As String = drs(drs.count -1)("档案序号").substring(3)
Dim cnt As Integer
If Integer.TryParse(bn,cnt) Then
e.DataRow("档案序号")= e.DataRow("项目代码") & Format(cnt +1,"000")
End If
End If
End If
End If