以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 统计行数有问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=151082) |
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/15 9:03:00 -- 统计行数有问题 第一轮的数据已经没问题,当对阵表窗口控件上的棋赛名称=di1,第几轮比赛=2,比赛积分表还没生成这轮数据,则比赛积分表这轮数据安上轮积分排序、排座。对阵表安比赛积分表排座随机红、黑方。 红色标注的数组个数统计为0,我只好用SQLfind直接定义行,但报错: 完整代码请看上传附件 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
密码:888888 |
||||
-- 作者:有点蓝 -- 发布时间:2020/6/15 10:14:00 -- ElseIf di2 = 2 And cnt = 0 Then Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\' And [第几轮比赛] = \'" & a & "\'","","积分 Desc") For i As Integer = 0 To drs2.Count - 1 dr = DataTables("比赛积分").AddNew dr("棋赛名称") = di1 dr("第几轮比赛") = di2 dr("日期") = di3 dr("编号") = drs2(i)("编号") dr("姓名") = drs2(i)("姓名") dr("上轮止累计积分") = drs2(i)("积分") \'Dim dr1 As DataRow = DataTables("比赛积分").SQLfind("[桌号] = " & drs2(idx1)("桌号") & "And ([编号] <> \'" & drs2(idx1)("编号") & "\'or [姓名] <> \'" & drs2(idx1)("姓名") & "\')") \'dr("曾交战对手累计积分") = dr1("积分") dr("曾交战对手累计积分") = DataTables("比赛积分").SQLCompute("SUM(积分)","[桌号] = " & drs2(i)("桌号") & "And ([编号] <> \'" & drs2(i)("编号") & "\'or [姓名] <> \'" & drs2(i)("姓名") & "\')") 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 Next 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
|
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/15 12:00:00 -- Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And ([第几轮比赛] = \'" & a & "\'","","积分 Desc") messagebox.show(drs2.count) 这段代码个数是0,我之前测试过为0,不行,才改代码的。 另这段代码不能注识,我的文字说明漏写了如果基本信息表中的缺赛轮号含当前比赛轮次,这人不编桌号。 If dr("编号") = dts1("编号") Then dr("桌号") = Nothing Else dr("桌号") = math.Ceiling((i2+1) \\ 2) End If
[此贴子已经被作者于2020/6/15 12:01:19编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/15 13:35:00 -- 1、请照抄2楼的代码,关键字前后加了许多空格 2、这段代码【dts1("编号"),集合只能使用1,2,3...这种索引,不支持字符串索引】用法是错的,但是只在看不懂这段代码要干嘛,只能注释掉
|
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/15 17:00:00 -- 我把它改为红色代码,直接说我不对,应怎么写? ElseIf di2 = 2 And cnt = 0 Then Dim drs2 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\' And [第几轮比赛] = \'" & a & "\'","","积分 Desc") messagebox.show(drs2.count) For ia As Integer = 0 To drs2.Count - 1 dr = DataTables("比赛积分").AddNew dr("棋赛名称") = di1 dr("第几轮比赛") = di2 dr("日期") = di3 dr("编号") = drs2(ia)("编号") dr("姓名") = drs2(ia)("姓名") dr("上轮止累计积分") = drs2(ia)("积分") dr("曾交战对手累计积分") = DataTables("比赛积分").SQLCompute("SUM(积分)","[桌号] = " & drs2(ia)("桌号") & "And ([编号] <> \'" & drs2(ia)("编号") & "\'or [姓名] <> \'" & drs2(ia)("姓名") & "\')") messagebox.show(dr("曾交战对手累计积分")) If drs2(ia)("编号") = dts("编号") AndAlso dts("缺赛轮号").Contains("\'" & di2 & "\'") Then dr("桌号") = Nothing Else dr("桌号") = math.Ceiling((i2+1) \\ 2) End If i2 += 1 Next DataTables("比赛积分").Save() DataTables("对阵表").DataRows.Clear Dim drs3 As List(of DataRow) = DataTables("比赛积分").SQLSelect("[棋赛名称] = \'" & di1 & "\'And [第几轮比赛] = \'" & di2 & "\'","","上轮止累计积分,曾交战对手累计积分 Desc") For ib As Integer = 0 To drs3.Count - 1 Step 2 If ib+1 <= drs3.Count - 1 Dim nr As DataRow = DataTables("对阵表").AddNew nr("桌号") = drs3(ib)("桌号") nr("红方_编号") = drs3(ib)("编号") nr("红方_姓名") = drs3(ib)("姓名") nr("黑方_编号") = drs3(ib+1)("编号") nr("黑方_姓名") = drs3(ib+1)("姓名") nr("红方_上轮止累计积分") = drs3(ib)("上轮止累计积分") nr("红方_曾交战对手累计积分") = drs3(ib)("曾交战对手累计积分") nr("黑方_上轮止累计积分") = drs3(ib+1)("上轮止累计积分") nr("黑方_曾交战对手累计积分") = drs3(ib+1)("曾交战对手累计积分") End If Next |
||||
-- 作者:有点蓝 -- 发布时间:2020/6/15 17:23:00 -- Dim dr As DataRow = DataTables("比赛积分").SQLFind("[棋赛名称] = \'" & di1 & "\'And ([第几轮比赛] = \'" & a & "\' and 编号=\'" & dr("编号") & "\'","","积分 Desc") If dr IsNot Nothing Then dr("桌号") = Nothing Else dr("桌号") = math.Ceiling((i2+1) \\ 2) End If
|
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/15 18:01:00 -- 你这段代码没有判断如果基本信息表中的缺赛轮号含当前比赛轮次,这人不编桌号,他仅不排桌号,编号、姓名、积分都存在的,因为有的人中途有事退场,但积分依然显示,所以你这代码不符要求。 |
||||
-- 作者:有点蓝 -- 发布时间:2020/6/15 20:09:00 -- Dim dr As DataRow = DataTables("基本信息").SQLFind("[棋赛名称] = \'" & di1 & "\'And [身份] = \'参赛人\' And [缺赛轮号] like \'%" & di2 & "%\' and 编号=\'" & dr("编号") & "\'") If dr IsNot Nothing Then dr("桌号") = Nothing Else dr("桌号") = math.Ceiling((i2+1) \\ 2) End If
|
||||
-- 作者:采菊东篱下 -- 发布时间:2020/6/16 11:46:00 -- 密码:888888 对阵表中排序和生成的数据都符合我要求了,但比赛积分表中的桌号怎么与对阵表中桌号不相符?应怎么让它们一致?
|
||||
-- 作者:有点蓝 -- 发布时间:2020/6/16 11:57:00 -- 自己重新生成了桌号,当然不相符,如果要一样,直接赋值就行了 dr("桌号") = drs2(ia)("桌号")
|