它是一个分页加载的表,如何实现自动生成的数据,移动一下行的位置?
Dim dr As DataRow = DataTables("比赛积分").SQLfind("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & di2 & "' And [分组] = '" & Str & "'")
Dim dts As List(of DataRow) = DataTables("基本信息").SQLSelect("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [分组] = '" & Str & "' And [身份] = '参赛人'")
DataTables("比赛积分").DeleteFor("[棋赛名称] Is null")
Dim cnt As Integer = DataTables("比赛积分").Compute("Count([姓名])", "[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & di2 & "' And [分组] = '" & Str & "'")
If di2 = 1 And cnt = 0 Then
Do While dts.Count > 0
Dim idx As Integer = rand.Next(0,dts.Count)
dr = DataTables("比赛积分").AddNew()
dr("排序") = math.Ceiling(i2 / 2)
dr("日期") = di3
dr("棋赛名称") = di1
dr("棋赛副名") = Forms("主窗口").Controls("TextBox4").text
dr("第几轮比赛") = di2
dr("编号") = dts(idx)("编号")
dr("姓名") = dts(idx)("姓名")
dr("团体赛或个人赛") = lx
dr("分组") = Str
dts.RemoveAt(idx)
i2 = i2 + 1
Loop
DataTables("比赛积分").Load
DataTables("比赛积分").Save()
tbl.Table.DataTable.DataRows.Clear
Dim drs1 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & di2 & "' And [分组] = '" & Str & "'","","排序")
For i As Integer = 0 To drs1.Count - 1
Dim nr As DataRow
If i <= drs1.Count And i Mod 2 = 0 Then
nr = tbl.Table.DataTable.AddNew()
nr("桌号") = drs1(i)("排序")
nr("红方_编号") = drs1(i)("编号")
nr("红方_姓名") = drs1(i)("姓名")
ElseIf i <= drs1.Count And i Mod 2 = 1 Then
nr("黑方_编号") = drs1(i)("编号")
nr("黑方_姓名") = drs1(i)("姓名")
End If
Next
DataTables("比赛积分").SQLUpdate(drs1)
ElseIf di2 = 2 And cnt = 0 Then
Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [第几轮比赛] = '" & Cstr(Val(di2)-1) & "' And [分组] = '" & Str & "'","","积分 Desc")
For ia As Integer = 0 To drs2.Count - 1
dr = DataTables("比赛积分").AddNew
Dim dts1 As DataRow = DataTables("基本信息").SQLFind("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [分组] = '" & Str & "' And [身份] = '参赛人' And [缺赛轮号] like '%" & di2 & "%' and [编号] = '" & drs2(ia)("编号") & "'")
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("上轮名次") = drs2(ia)("名次")
dr("编号") = drs2(ia)("编号")
dr("姓名") = drs2(ia)("姓名")
dr("团体赛或个人赛") = lx
dr("分组") = Str
dr("上轮止累计积分") = drs2(ia)("积分")
dr("曾交战对手累计积分") = DataTables("比赛积分").SQLCompute("SUM(积分)","[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "' And [分组] = '" & Str & "' And [排序] = " & drs2(ia)("排序") & " And ([编号] <> '" & drs2(ia)("编号") & "'or [姓名] <> '" & drs2(ia)("姓名") & "')")
Next
DataTables("比赛积分").Load
DataTables("比赛积分").Save()
Dim drs3a As List(of DataRow) = DataTables("比赛积分").SQLSelect("[团体赛或个人赛] = '" & lx & "' And [棋赛名称] = '" & di1 & "'And [第几轮比赛] = '" & di2 & "' And [分组] = '" & Str & "' And [排序] <> 0")
For ia1 As Integer = 0 To drs3a.Count - 1 Step 2
If ia1+1 < drs3a.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 drs3a(ia1+1)("编号") = dr2a1("编号") Then
With drs3a(ia1+1)("编号")
.Move(.Position + 1)
End With
End If
Next
End If
Next
[此贴子已经被作者于2021/12/30 15:03:59编辑过]