Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & Cstr(Val(di2)-1) & "' And [分组] = '" & Str & "'")
Dim cmd As new SQLCommand
Dim t As DataTable
cmd.CommandText = "Select * Fro m {比赛积分} WHERE [团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & Cstr(Val(di2)-1) & "' And [分组] = '" & Str & "' Order by 积分 Desc"
t = cmd.ExecuteReader(True)
t.Save()
Dim b As New GroupTableBuilder("统计表1",t)
b.Groups.AddDef("棋赛名称")
b.Groups.AddDef("棋赛副名")
b.Groups.AddDef("团体赛或个人赛")
b.Groups.AddDef("第几轮比赛")
b.Groups.AddDef("分组")
b.Groups.AddDef("编号")
b.Groups.AddDef("姓名")
b.Totals.AddDef("排序")
b.Totals.AddDef("上轮止累计积分")
b.Totals.AddDef("曾交战对手累计积分")
b.Build()
MainTable = Tables("统计表1")
For ia1 As Integer = 0 To Tables("统计表1").rows.count-1 Step 2
If ia1+1 < Tables("统计表1").Rows.Count Then
For ia As Integer = 0 To drs2.Count - 1
Dim dr2a1 As DataRow = DataTables("比赛积分").SQLFind("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & Cstr(Val(di2)-1) & "' And [分组] = '" & Str & "' And [排序] = " & drs2(ia)("排序") & " And ([编号] <> '" & drs2(ia)("编号") & "'or [姓名] <> '" & drs2(ia)("姓名") & "')")
If Tables("统计表1").Rows(ia1+1)("编号") = dr2a1("编号") Then
With Tables("统计表1").Rows(ia1+1)("编号")
.Move(.Position + 1)
End With
End If
Next
End If
Next
For ia2 As Integer = 0 To Tables("统计表1").Rows.Count - 1
dr = DataTables("比赛积分").AddNew
Dim dts1 As DataRow = DataTables("基本信息").SQLFind("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [分组] = '" & Str & "' And [身份] = '参赛人' And [缺赛轮号] like '%" & di2 & "%' and [编号] = '" & Tables("统计表1").Rows(ia2)("编号") & "'")
If dts1 IsNot Nothing Then
dr("排序") = 0
Else
dr("排序") = math.Ceiling(ii2 / 2)
ii2 + = 1
End If
dr("棋赛名称") = di1
dr("棋赛副名") = Forms("主窗口").Controls("TextBox4").text
dr("第几轮比赛") = di2
dr("日期") = di3
dr("上轮名次") = Tables("统计表1").Rows(ia2)("名次")
dr("编号") = Tables("统计表1").Rows(ia2)("编号")
dr("姓名") = Tables("统计表1").Rows(ia2)("姓名")
dr("团体赛或个人赛") = lx
dr("分组") = Str
dr("上轮止累计积分") = Tables("统计表1").Rows(ia2)("积分")
dr("曾交战对手累计积分") = DataTables("比赛积分").SQLCompute("SUM(积分)","[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [分组] = '" & Str & "' And [排序] = " & Tables("统计表1").Rows(ia2)("排序") & " And ([编号] <> '" & Tables("统计表1").Rows(ia2)("编号") & "'or [姓名] <> '" & Tables("统计表1").Rows(ia2)("姓名") & "')")
Next
DataTables("比赛积分").Load
DataTables("比赛积分").Save()