第一次判断
'合并小于等于1200数量为1来源和备注都相同的相同规格线条
Dim ss As List(Of String()) = DataTables(eform.name & "_Table2").GetValues("产品分类|产品型号|工艺|基材|木皮|来源|备注")
Dim dr1,dr2 As DataRow
For Each s As String() In ss
Dim filter as string = "产品分类 = '" & s(0) & "' and 产品型号 = '" & s(1) & "' and 工艺 = '" & s(2) & "' and 基材 = '" & s(3) & "' and 木皮 = '" & s(4) & "' and 来源 = '" & s(5) & "' and 高 <=1200 and 数量= 1 and 不并线 = 0 and 竖线 = 0 and 导入类型='套线'"
If s(6) > "" then
filter = filter & " and 备注 = '" & s(6) & "'"
Else
filter = filter & " and 备注 is null "
End If
'MessageBox.Show(8)
Dim drs1 As List(Of DataRow) = DataTables(eform.name & "_Table2").Select(filter,"高")
Do While drs1.Count > 1
'MessageBox.Show(7)
dr1 = drs1(0)
dr2 = drs1(drs1.Count - 1)
dr1("序")=DataTables(eform.name & "_Table2").Compute("Max(序)") + 1
dr1("行")=DataTables(eform.name & "_Table2").Compute("Max(行)") + 1
'Dim f as string
dr1("来源") = dr1("来源") & "," & dr2("来源")
'dr1("来源") = String.join(",",f.split(",").Distinct.ToArray)
dr1("高") = dr1("高") + dr2("高")
If dr1("高") <=1200 then
dr1("高")=1200
ElseIf dr1("高")>1200 And dr1("高")<=1500 then
dr1("高")=1500
ElseIf dr1("高")>1500 And dr1("高")<=1800 then
dr1("高")=1800
ElseIf dr1("高")>1800 And dr1("高")<=2200 then
dr1("高")=2200
ElseIf dr1("高")>2200 And dr1("高")<=2400 then
dr1("高")=2400
End If
dr1("备注")=dr1("备注")
drs1.Remove(dr1)
drs1.Remove(dr2)
dr2.Delete
'MessageBox.Show(6)
Loop
Next
Tables(eform.name & "_Table2").Save
第二次判断
'合并小于等于1200数量为1的来源不同备注相同的相同规格线条
Dim ss1 As List(Of String()) = DataTables(eform.name & "_Table2").GetValues("产品分类|产品型号|工艺|基材|木皮|备注")
Dim dr11,dr22 As DataRow
For Each s1 As String() In ss1
Dim filter1 as string = "产品分类 = '" & s1(0) & "' and 产品型号 = '" & s1(1) & "' and 工艺 = '" & s1(2) & "' and 基材 = '" & s1(3) & "' and 木皮 = '" & s1(4) & "' and 高 <=1200 and 数量= 1 and 不并线 = 0 and 竖线 = 0 and 导入类型='套线'"
If s1(5) > "" then
filter1 = filter1 & " and 备注 = '" & s1(5) & "'"
Else
filter1 = filter1 & " and 备注 is null "
End If
Dim drs11 As List(Of DataRow) = DataTables(eform.name & "_Table2").Select(filter1,"高")
Do While drs11.Count > 1
'MessageBox.Show(4)
dr11 = drs11(0)
dr22 = drs11(drs11.Count - 1)
dr11("序")=DataTables(eform.name & "_Table2").Compute("Max(序)") + 1
dr11("行")=DataTables(eform.name & "_Table2").Compute("Max(行)") + 1
'Dim f as string
'f = dr11("来源") & "," & dr22("来源")
'dr11("来源")=String.Join(",",f.ToArray)
dr11("来源")= dr11("来源") & "," & dr22("来源")
dr11("高") = dr11("高") + dr22("高")
If dr11("高") <=1200 then
dr11("高")=1200
ElseIf dr11("高")>1200 And dr11("高")<=1500 then
dr11("高")=1500
ElseIf dr11("高")>1500 And dr11("高")<=1800 then
dr11("高")=1800
ElseIf dr11("高")>1800 And dr11("高")<=2200 then
dr11("高")=2200
ElseIf dr11("高")>2200 And dr11("高")<=2400 then
dr11("高")=2400
End If
dr1("备注")=dr1("备注")
drs11.Remove(dr11)
drs11.Remove(dr22)
dr22.Delete
Loop
Next
Tables(eform.name & "_Table2").Save