以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 随机红、黑方 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=151325) |
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/20 16:50:00 -- 随机红、黑方 这段代码是安顺序把数据搬到红、黑方对阵表,并没在确定对手后随机红、黑方,我把它改这红色显示代码: Dim drs3 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] <> 0","","排序,上轮止累计积分 Desc,曾交战对手累计积分") For ib As Integer = 0 To drs3.Count - 1 Step 2 Dim nr As DataRow = DataTables("对阵表").AddNew If ib + 1 <= drs3.Count - 1 nr("桌号") = drs3(ib)("排序") nr("红方_编号") = drs3(ib)("编号") nr("红方_姓名") = drs3(ib)("姓名") nr("红方_上轮止累计积分") = drs3(ib)("上轮止累计积分") nr("红方_曾交战对手累计积分") = drs3(ib)("曾交战对手累计积分") nr("黑方_姓名") = drs3(ib+1)("编号") nr("黑方_姓名") = drs3(ib+1)("姓名") nr("黑方_上轮止累计积分") = drs3(ib+1)("上轮止累计积分") nr("黑方_曾交战对手累计积分") = drs3(ib+1)("曾交战对手累计积分") Else nr("桌号") = drs3(ib)("排序") nr("红方_编号") = drs3(ib)("编号") nr("红方_姓名") = drs3(ib)("姓名") nr("红方_上轮止累计积分") = drs3(ib)("上轮止累计积分") nr("红方_曾交战对手累计积分") = drs3(ib)("曾交战对手累计积分") End If Next DataTables("比赛积分").SQLUpdate(drs3) 转换过程头脑都晕了!请帮我改改。 Dim drs3 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] <> 0","","排序,上轮止累计积分 Desc,曾交战对手累计积分") For ib As Integer = 0 To drs1.Count - 1 Step 2 Dim n = 2 If drs3.Count >= n Then Dim ls1 As new List(Of String) Do While ls1.count < n Dim c As Integer = rand.Next(ib,ib+1) If ls1.Contains(c) = False Then ls1.add(c) End If Loop Dim nr As DataRow = DataTables("对阵表").AddNew nr("桌号") = drs3(c)("桌号") \'最后要得出这样的结果 If ls1.count = 0 Then nr("红方_编号") = drs3(c)(0)("编号") \'最后要得出这样的结果 nr("红方_姓名") = drs3(c)(0)("姓名") \'最后要得出这样的结果 Else ls1.count = 1 Then nr("黑方_编号") = drs3(c)(1)("编号") \'最后要得出这样的结果 nr("黑方_姓名") = drs3(c)(1)("姓名") \'最后要得出这样的结果 End If End If Next DataTables("比赛积分").SQLUpdate(drs3) 后面省略
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/20 16:58:00 -- 参考:http://www.foxtable.com/webhelp/topics/2963.htm |
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/21 12:32:00 --
密码:888888 对阵表窗口第2轮对阵表代码不报错,但没生成数据,我想实现比赛积分表中当前比赛轮次相同排序随机红黑方: ElseIf di2 = 2 And cnt = 0 Then Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & a & "\'","","积分 Desc") For ia As Integer = 0 To drs2.Count - 1 dr = DataTables("比赛积分").AddNew Dim dts1 As DataRow = DataTables("基本信息").SQLFind("[棋赛名称] = \'" & di1 & "\'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("第几轮比赛") = di2 dr("日期") = di3 dr("编号") = drs2(ia)("编号") dr("姓名") = drs2(ia)("姓名") dr("轮赛次数值转换") = Val(di2) dr("上轮止累计积分") = drs2(ia)("积分") dr("曾交战对手累计积分") = DataTables("比赛积分").SQLCompute("SUM(积分)","[排序] = " & drs2(ia)("排序") & "And ([编号] <> \'" & drs2(ia)("编号") & "\'or [姓名] <> \'" & drs2(ia)("姓名") & "\')") i2 + = 1 Next DataTables("比赛积分").Load DataTables("比赛积分").Save() DataTables("对阵表").DataRows.Clear Dim drs3 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] <> 0","","排序,上轮止累计积分 Desc,曾交战对手累计积分") For ib As Integer = 0 To cnt - 1 Step 2 If ib + 1 <= cnt - 1 Do Dim c As Integer = rand.Next(ib,ib+1) Dim dr3 As DataRow = drs3(c) If dr3(c)("编号") = False Then Dim nr As DataRow = DataTables("对阵表").AddNew nr("桌号") = drs3(c)("排序") nr("红方_编号") = drs3(c)("编号") nr("红方_姓名") = drs3(c)("姓名") nr("红方_上轮止累计积分") = drs3(c)("上轮止累计积分") nr("红方_曾交战对手累计积分") = drs3(c)("曾交战对手累计积分") nr("黑方_姓名") = drs3(c)("编号") nr("黑方_姓名") = drs3(c)("姓名") nr("黑方_上轮止累计积分") = drs3(c)("上轮止累计积分") nr("黑方_曾交战对手累计积分") = drs3(c)("曾交战对手累计积分") End If Loop End If Next DataTables("比赛积分").SQLUpdate(drs3) drs3 = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] = 0","","排序,上轮止累计积分 Desc,曾交战对手累计积分") For ib As Integer = 0 To cnt - 1 Step 2 Do Dim c As Integer = rand.Next(ib,ib+1) Dim dr3 As DataRow = drs3(c) If dr3(c)("编号") = False Then Dim nr As DataRow = DataTables("对阵表").AddNew nr("桌号") = 0 nr("红方_编号") = drs3(c)("编号") nr("红方_姓名") = drs3(c)("姓名") nr("红方_上轮止累计积分") = drs3(c)("上轮止累计积分") nr("红方_曾交战对手累计积分") = drs3(c)("曾交战对手累计积分") nr("黑方_姓名") = drs3(c)("编号") nr("黑方_姓名") = drs3(c)("姓名") nr("黑方_上轮止累计积分") = drs3(c)("上轮止累计积分") nr("黑方_曾交战对手累计积分") = drs3(c)("曾交战对手累计积分") End If Loop Next DataTables("比赛积分").SQLUpdate(drs3) [此贴子已经被作者于2020/6/21 19:57:32编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/21 22:18:00 -- …… DataTables("比赛积分").Save() DataTables("对阵表").DataRows.Clear Dim drs3 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] <> 0","","排序,上轮止累计积分 Desc,曾交战对手累计积分") Dim iii As Integer = 1 Do While drs3.Count > 0 Dim nr As DataRow = DataTables("对阵表").AddNew Dim c As Integer = rand.Next(0,drs3.Count) Dim dr3 As DataRow = drs3(c) Dim sss As String = "\'" & dr3("编号") & "\'" nr("桌号") = iii nr("红方_编号") = dr3("编号") nr("红方_姓名") = dr3("姓名") nr("红方_上轮止累计积分") = dr3("上轮止累计积分") nr("红方_曾交战对手累计积分") = dr3("曾交战对手累计积分") drs3.RemoveAt(c) If drs3.Count > 0 c = rand.Next(0,drs3.Count) dr3 = drs3(c) sss = sss & ",\'" & dr3("编号") & "\'" nr("黑方_姓名") = dr3("编号") nr("黑方_姓名") = dr3("姓名") nr("黑方_上轮止累计积分") = dr3("上轮止累计积分") nr("黑方_曾交战对手累计积分") = dr3("曾交战对手累计积分") drs3.RemoveAt(c) End If DataTables("比赛积分").SQLReplaceFor("桌号",iii,"[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] <> 0 and 编号 in (" & sss & ")") iii += 1 Loop DataTables("比赛积分").Load drs3 = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\' and [排序] = 0","","排序,上轮止累计积分 Desc,曾交战对手累计积分") ……[排序] = 0的用法参考自己做
|
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/22 9:58:00 -- 对阵表的桌号跟比赛积分表的排序不相符! [此贴子已经被作者于2020/6/22 9:58:55编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/22 10:12:00 -- 要按排序还随机干嘛?随机了当然就是乱序的 |
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/22 10:49:00 -- 随机特指当前轮比赛排序相同才随机红黑方,所以我用到 For ib As Integer = 0 To cnt - 1 Step 2 If ib + 1 <= cnt - 1 Do Dim c As Integer = rand.Next(ib,ib+1) 这代码
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/22 11:13:00 -- For ib As Integer = 0 To drs3.Count - 1 Step 2 Dim c As Integer = rand.Next(0,2) Dim c1 As Integer = IIF(c = 0,1,0) c = ib+c c1 = ib+c1 Dim nr As DataRow = DataTables("对阵表").AddNew If c <= drs3.Count - 1 nr("桌号") = drs3(c)("排序") nr("红方_编号") = drs3(c)("编号") nr("红方_姓名") = drs3(c)("姓名") nr("红方_上轮止累计积分") = drs3(c)("上轮止累计积分") nr("红方_曾交战对手累计积分") = drs3(c)("曾交战对手累计积分") End If If c1 <= drs3.Count - 1 nr("黑方_姓名") = drs3(c1)("编号") nr("黑方_姓名") = drs3(c1)("姓名") nr("黑方_上轮止累计积分") = drs3(c1)("上轮止累计积分") nr("黑方_曾交战对手累计积分") = drs3(c1)("曾交战对手累计积分") End If Next
|
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/22 14:06:00 --
密码:888888 第2轮没错了,第3轮报错,对阵表不显示排序=0的数据,排序不为0多出的那个人出没显示,他应独立一桌,随机红黑方。
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/22 14:33:00 -- 我测试 没有问题 |