第3轮对阵表只生成一行数据!代码不通用!
Else If cnt = 0 Then
Dim drs4 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & a & "'","","上轮止累计积分,曾交战对手累计积分 Desc")
Dim ii2 As Integer = 1
For ic As Integer = 0 To drs4.Count - 1
dr = DataTables("比赛积分").AddNew
Dim dts2 As DataRow = DataTables("基本信息").SQLFind("[棋赛名称] = '" & di1 & "'And [身份] = '参赛人' And ([缺赛轮号] like '%" & di2 & "%' or [缺赛轮号] like '%" & di2 & "') and [编号] = '" & dr("编号") & "'") '没加or 条件与加 or条件都出错,第几轮是不是最后一轮不定,包含的内容所在位置不定,因此此代码有问题。
If dts2 IsNot Nothing Then
dr("排序") = Nothing
Else
dr("排序") = math.Ceiling((ii2+1) \ 2)
ii2 + = 1
End If
dr("棋赛名称") = di1
dr("第几轮比赛") = di2
dr("日期") = di3
dr("编号") = drs4(ic)("编号")
dr("姓名") = drs4(ic)("姓名")
dr("上轮止累计积分") = drs4(ic)("上轮止累计积分") + drs4(ic)("积分")
dr("曾交战对手累计积分") = drs4(ic)("曾交战对手累计积分") + DataTables("比赛积分").SQLCompute("SUM(积分)","[桌号] = " & drs4(ic)("桌号") & "And [编号] <> '" & drs4(ic)("编号") & "'and [姓名] <> '" & drs4(ic)("姓名") & "'")
i2 += 1
Next
DataTables("比赛积分").Save()
DataTables("对阵表").DataRows.Clear
Dim drs5 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = '" & di1 & "'And [第几轮比赛] = '" & di2 & "'","","排序,上轮止累计积分 Desc,曾交战对手累计积分")
For id As Integer = 0 To drs5.Count - 1 Step 2
If id+1 <= drs5.Count - 1
Dim nr As DataRow = DataTables("对阵表").AddNew()
nr("桌号") = drs5(id)("排序")
nr("红方_编号") = drs5(id)("编号")
nr("红方_姓名") = drs5(id)("姓名")
nr("黑方_编号") = drs5(id+1)("编号")
nr("黑方_姓名") = drs5(id+1)("姓名")
nr("红方_上轮止累计积分") = drs5(id)("上轮止累计积分")
nr("红方_曾交战对手累计积分") = drs5(id)("曾交战对手累计积分").
nr("黑方_上轮止累计积分") = drs5(id+1)("上轮止累计积分")
nr("黑方_曾交战对手累计积分") = drs5(id+1)("曾交战对手累计积分")
End If
Next
DataTables("比赛积分").SQLUpdate(drs5)
End If
DataTables("比赛积分").Load