代码意思是:从ddpsb和ddqdb中,取zzh相同,zzh_xx与right(zzh_yy,2)相同的记录,将ddpsb 发货日期取出来,再取出ddqdb的清单条码编码,一起依据清单条码编码将”发货日期“匹配到“实时工序计算表“中。代码运行每问题就是慢。
dataTables("ddpsb").LoadFilter = "发货日期 is not null"
DataTables("ddpsb").load
Dim dtb1 As New DataTableBuilder("临时表")
dtb1.AddDef("清单条码编码", GetType(String), 60)
dtb1.AddDef("发货日期", GetType(Date))
dtb1.Build()
Dim zh1, zh2 As String
'Dim srs1 As List(Of DataRow)
For Each dr1 As DataRow In DataTables("ddpsb").DataRows
zh1 = dr1("zzh")
zh2 = dr1("zzh_xx")
For Each dr2 As DataRow In DataTables("ddqdb").Select("zzh='" & zh1 & "'") '找到符合条件的所有记录
Dim s As String = dr2("zzh_yy")
Dim syy As String = Right(s, 2)
If dr1.IsNull("zzh_xx") = False And syy = zh2 Then
Dim dr3 As DataRow = DataTables("临时表").AddNew()
If dr2.IsNull("清单条码编码") = False Then
dr3("清单条码编码") = dr2("清单条码编码")
dr3("发货日期") = dr1("发货日期")
End If
Else If dr1.IsNull("zzh_xx") = True Then
Dim dr4 As DataRow = DataTables("临时表").AddNew()
If dr2.IsNull("清单条码编码") = False Then
dr4("清单条码编码") = dr2("清单条码编码")
dr4("发货日期") = dr1("发货日期")
End If
End If
Next
Next
''Dim qds As New List(Of String)
DataTables("临时表").DeleteFor("发货日期 is null or 清单条码编码 is null")
Dim Arys As List(Of String())
Arys = DataTables("临时表").GetValues("清单条码编码|发货日期") '列名用符号|分割
For Each Ary As String() In Arys
Dim drs As List(Of DataRow) = DataTables("实时工序计算表").Select("清单条码编码='" & Ary(0) & "'")
For Each dr8 As DataRow In drs
dr8("发货日期") = Ary(1)
Next
Next