Dim dt1 As DataTable = DataTables("员工资料")
Dim dt2 As DataTable = DataTables("粮农直补")
Dim i1 As Integer = 0
Dim i2 As Integer = 0
Dim 找到的行 As new Dictionary(Of DataRow, DataRow)
Dim 增加的行 As new List(Of DataRow)
For Each dr As DataRow In dt2.DataRows
Dim fdr As DataRow = dt1.find("身份证号 = '" & dr("身份证号") & "'")
If fdr IsNot Nothing Then
找到的行.Add(dr, fdr)
i1 = i1+1
Else
增加的行.Add(dr)
i2 = i2 +1
End If
Next
For Each key As DataRow In 找到的行.Keys
找到的行(key)("姓名") = key("姓名")
Next
For Each dr As DataRow In 增加的行
Dim ndr As DataRow = DT1.ADDNEW()
ndr("身份证号") = dr("身份证号")
ndr("姓名") = dr("姓名")
next
PopMessage("共更新了" & i1 & "条记录" & vbcrlf & "新增了" & i2 & "条记录","通知", PopIconEnum.OK, 5)