第一轮的数据已经没问题,当对阵表窗口控件上的棋赛名称=di1,第几轮比赛=2,比赛积分表还没生成这轮数据,则比赛积分表这轮数据安上轮积分排序、排座。对阵表安比赛积分表排座随机红、黑方。
红色标注的数组个数统计为0,我只好用SQLfind直接定义行,但报错:
此主题相关图片如下:qq图片20200615081132.png

完整代码请看上传附件
ElseIf di2 = 2 And cnt = 0 Then
Dim drs2 As DataRow = DataTables("比赛积分").SQLfind("[棋赛名称] = '" & di1 & "'And [第几轮比赛] = '" & a & "'","桌号 Desc")
'Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = '" & di1 & "'And ([第几轮比赛] = '" & a & "'","","积分 Desc")
messagebox.show(cnt1)
'Do While drs2.count > 0
Do While cnt1 > 0
'Dim idx1 As Integer = drs2.count - 1
Dim idx1 As Integer = cnt1 - 1
dr = DataTables("比赛积分").AddNew
dr("棋赛名称") = di1
dr("第几轮比赛") = di2
dr("日期") = di3
dr("编号") = drs2(idx1)("编号")
dr("姓名") = drs2(idx1)("姓名")
dr("上轮止累计积分") = drs2(idx1)("积分")
'Dim dr1 As DataRow = DataTables("比赛积分").SQLfind("[桌号] = " & drs2(idx1)("桌号") & "And ([编号] <> '" & drs2(idx1)("编号") & "'or [姓名] <> '" & drs2(idx1)("姓名") & "')")
'dr("曾交战对手累计积分") = dr1("积分")
dr("曾交战对手累计积分") = DataTables("比赛积分").SQLCompute("SUM(积分)","[桌号] = " & drs2(idx1)("桌号") & "And ([编号] <> '" & drs2(idx1)("编号") & "'or [姓名] <> '" & drs2(idx1)("姓名") & "')")
messagebox.show(dr("曾交战对手累计积分"))
Dim dts1 As List(of DataRow) = DataTables("基本信息").SQLSelect("[棋赛名称] = '" & di1 & "'And [身份] = '参赛人' And [缺赛轮号] like '%" & di2 & "%'")
If dr("编号") = dts1("编号") Then
dr("桌号") = Nothing
Else
dr("桌号") = math.Ceiling((i2+1) \ 2)
End If
i2 += 1
Loop
DataTables("比赛积分").Save()
DataTables("对阵表").DataRows.Clear
Dim drs3 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = '" & di1 & "'And [第几轮比赛] = '" & di2 & "'","","上轮止累计积分,曾交战对手累计积分 Desc")
For i As Integer = 0 To drs3.Count - 1 Step 2
If i+1 <= drs3.Count - 1
Dim nr As DataRow = DataTables("对阵表").AddNew
nr("桌号") = drs3(i)("桌号")
nr("红方_编号") = drs3(i)("编号")
nr("红方_姓名") = drs3(i)("姓名")
nr("黑方_编号") = drs3(i+1)("编号")
nr("黑方_姓名") = drs3(i+1)("姓名")
nr("红方_上轮止累计积分") = drs3(i)("上轮止累计积分")
nr("红方_曾交战对手累计积分") = drs3(i)("曾交战对手累计积分")
nr("黑方_上轮止累计积分") = drs3(i+1)("上轮止累计积分")
nr("黑方_曾交战对手累计积分") = drs3(i+1)("曾交战对手累计积分")
End If
Next