Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "工单单号"
For Each dr As DataRow In DataTables("生产主计划").Select("工单单号 is not null", cs)
Dim flag As Boolean = False
If pdr IsNot Nothing Then
For Each c As String In cs.split(",")
If pdr(c) <> dr(c) Then
flag = True
Exit For
End If
Next
If flag Then
If count > 1 Then
idx &= idx_temp
End If
count = 1
idx_temp = ""
Else
count += 1
idx_temp &= dr("_Identify") & ","
End If
Else
count += 1
End If
pdr = dr
Next
If count > 1 Then
idx &= idx_temp
End If
DataTables("生产主计划").DeleteFor("_Identify In (" & idx.trim(",") & ")")
现有排重代码如上。
两条数据相同的工单单号,一条“生管人员”字段有值,一条没有值,优先取有值的。如果两条都没值,随机取一条。
这个要怎么写代码?