For Each dr As DataRow In DataTables("净进货核算差额调整").DataRows
If dr("店铺性质") = "正价店" Then
If dr("新季节属性") = "当季新款" Then
Dim pr As DataRow
Dim filter As String
filter = "货品年份 = '" & dr("款式年份") & "' And 货品季节 = '" & dr("款式季度") & "' And 仓店编号 = '" & dr("仓店编号") & "' and 退货截止日期 is not null"
pr = DataTables("客户当季货品退货核算标准").Find(filter)
If pr IsNot Nothing Then
If (pr("退货截止年份") = N1 And pr("退货截止月份") <= y1) Or pr("退货截止年份") < N1 Then
dr("退货完成标记") = "完成退货"
dr("核算年份") = pr("退货截止年份")
dr("核算月份") = pr("退货截止月份")
Else
dr("退货完成标记") = "未完成退货"
dr("核算年份") = Nothing
dr("核算月份") = Nothing
End If
Else
dr("退货完成标记") = "未完成退货"
dr("核算年份") = Nothing
dr("核算月份") = Nothing
End If
End If
If dr("新季节属性") = "往年旧款" Then
Dim pr1 As DataRow
Dim filter1 As String
filter1 = "款式季度 = '" & dr("款式季度") & "' And 仓店编号 = '" & dr("仓店编号") & "' and ((年份= '" & dr("年份") & "' and 月份>= " & dr("月份") & ") or 年份> '" & dr("年份") & "') and 退货完成标记='完成退货' and 新季节属性='当季新款'"
pr1 = DataTables("净进货核算差额调整").Find(filter1)
If pr1 IsNot Nothing Then
dr("退货完成标记") = "完成退货"
dr("核算年份") = pr1("核算年份")
dr("核算月份") = pr1("核算月份")
Else
dr("退货完成标记") = "未完成退货"
dr("核算年份") = Nothing
dr("核算月份") = Nothing
End If
End If
ElseIf dr("店铺性质") = "非正价店" Then
Dim pr2 As DataRow
Dim filter2 As String
filter2 = "款式季度 = '" & dr("款式季度") & "' And 品牌名称 = '" & dr("品牌名称") & "' and ((调整退市年份= '" & dr("年份") & "' and 调整退市月份>= " & dr("月份") & ") or 调整退市年份> '" & dr("年份") & "')"
pr2 = DataTables("商品上市退市时间档案").Find(filter2, "调整退货日期")
If pr2 IsNot Nothing Then
If (pr2("调整退市年份") = N1 And pr2("调整退市月份") <= y1) Or pr2("调整退市年份") < N1 Then
dr("退货完成标记") = "完成退货"
dr("核算年份") = pr2("调整退市年份")
dr("核算月份") = pr2("调整退市月份")
Else
dr("退货完成标记") = "未完成退货"
dr("核算年份") = Nothing
dr("核算月份") = Nothing
End If
Else
dr("退货完成标记") = "未完成退货"
dr("核算年份") = Nothing
dr("核算月份") = Nothing
End If
Else
dr("退货完成标记") = "未完成退货"
dr("核算年份") = Nothing
dr("核算月份") = Nothing
End If
Next
两万来条记录,结果出来差不多个把小时,如何调整可以效率高一些