Dim Arys As List(Of String())
Arys = DataTables("工序表").GetUniqueValues("", "工序号","姓名")
DataTables("人机工位图").RemoveFor("[姓名] <> ''")
Dim kc As Row
Dim ys,a1,a2,b1,b2 As String
Dim int1,int2,iint1,iint2,int,hint As Integer
ys = "一"
iint1 = 0
iint2 = 0
'注意循环变量是字符型数组,所以类型是String(),而不是String
For Each Ary As String() In Arys
Dim dt As DataTable =DataTables("工序表")
If ys = "一" Then
'先判断当前行第一组数据的数量
iint1 = dt.compute("count(姓名)","[工序号] = '" & Ary(0) & "' and [姓名] = '" & Ary(1) & "'")
a1 = Ary(0)
a2 = Ary(1)
Else If ys = "二" Then
'再判断判断当前第二组数据的数量
iint2 = dt.compute("count(姓名)","[工序号] = '" & Ary(0) & "' and [姓名] = '" & Ary(1) & "'")
b1 = Ary(0)
b2 = Ary(1)
End If
If ys = "二" Then
If iint1 > iint2 Then
int = iint1
Else If iint1 < iint2 Then
int = iint2
Else If iint1 = iint2 Then
int = iint1
End If
' 一 时 给当前行赋值
hint = 0
'遍历第一组数据
Dim drs1 As List(Of DataRow)
drs1 = DataTables("工序表").Select("[工序号] = '" & a1 & "' and [姓名] = '" & a2 & "'")
For Each dr As DataRow In drs1
If hint < int Then
kc = Tables("人机工位图").addnew() '先新增一行
int1 = dt.compute("sum(工时)","[工序号] = '" & a1 & "' and [姓名] = '" & a2 & "'")
kc("工序号") = dr("工序号")
kc("姓名") = dr("姓名")
kc("工序名称") = dr("工序名称")
kc("工时") = Int1
kc("设备") = dr("设备")
kc("颜色") = ys
Dim drs2 As DataRow
drs2 = DataTables("工序表").find("[工序号] <> '" & b1 & "' and [姓名] = '" & b2 & "'")
int2 = dt.compute("sum(工时)","[工序号] = '" & b1 & "' and [姓名] = '" & b2 & "'")
If drs2 IsNot Nothing Then
kc("工序号1") = drs2("工序号")
kc("姓名1") = drs2("姓名")
kc("工序名称1") = drs2("工序名称")
kc("工时1") = Int2
kc("设备1") = drs2("设备")
End If
End If
Next
End If
'下面的代码是用来区分颜色的
If ys = "二" Then
ys = "一"
Else If ys = "一" Then
ys = "二"
End If
Next