以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  排号问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=102205)

--  作者:刘林
--  发布时间:2017/6/15 9:20:00
--  排号问题

If e.Form.Controls("ComboBox4").value > ""
    Dim p As WinForm.ProgressBar
    p = e.Form.Controls("ProgressBar1")
    p.Maximum = MainTable.Rows.Count \'设置最大值
    p.Minimum = 0 \'设置最小值
    p.Value = 0 \'设置当前值
    Dim ksmc As String = e.Form.controls("combobox4").value
    Dim dt As DataTable = DataTables("成绩")
    Dim Arys As List(Of String())  = dt.GetValues("学校代码|年级代码|考试名称","考试名称 = \'" & ksmc & "\' And 单位名称 = \'" & _usergroup & "\'")
    e.Form.StopRedraw
    For Each Ary As String() In Arys
        Dim filter As String = CExp("学校代码=\'{0}\' and 年级代码=\'{1}\' and 考试名称=\'{2}\'",Ary(0),Ary(1),ary(2))
        Dim bhstr As String = Ary(1) & Ary(0)
        Dim bj As List(Of String) = dt.GetValues("班级",filter,"班级")
        Dim bjlist As new List(Of List(of DataRow))(bj.Count)
        Dim max As Integer = 0
        For Each s As String In bj
            Dim lst As List(of DataRow) = dt.Select(filter & " And 班级 =\'" & s & "\'","姓名")
            If max < lst.Count Then max = lst.Count
            bjlist.add(lst)
        Next
        Dim idx As Integer = 1
        Dim dr As DataRow
        For i As Integer = 0 To max - 1
            For j As Integer = 0 To bjlist.Count - 1
                Dim lst As List(of DataRow) = bjlist(j)
                If i < lst.Count Then
                    dr = lst(i)
                    If dr("考号锁定") = False
                        dr("考号") = bhstr & Format(idx,"0000")
                        idx += 1
                        p.Value = i
                    End If
                End If
            Next
        Next
    Next
    Dim t As Table = Tables("初中报名_Table1")
    t.Sort = "考试名称,考号"
    \'dt.save()
    e.form.ResumeRedraw
   
    p.value = 0
   
Else
    MessageBox.show("请选择考试名称","提示")
End If

 

老师上面代码是实现了各班混排,但有想实现同一年级的1、2、3班混排,4、5、6、7年级混排怎么改进,没思路,请指导

 

 


--  作者:有点蓝
--  发布时间:2017/6/15 9:34:00
--  
分开2批处理

For Each Ary As String() In Arys
    Dim filter As String = CExp("学校代码=\'{0}\' and 年级代码=\'{1}\' and 考试名称=\'{2}\'",Ary(0),Ary(1),ary(2))
    Dim bhstr As String = Ary(1) & Ary(0)

    Dim bj As List(Of String) = dt.GetValues("班级",filter & " and 班级 in (1,2,3)","班级")
    Dim bjlist As new List(Of List(of DataRow))(bj.Count)
    Dim max As Integer = 0
    For Each s As String In bj
        Dim lst As List(of DataRow) = dt.Select(filter & " And 班级 =\'" & s & "\'","姓名")
        If max < lst.Count Then max = lst.Count
        bjlist.add(lst)
    Next
    Dim idx As Integer = 1
    Dim dr As DataRow
    For i As Integer = 0 To max - 1
        For j As Integer = 0 To bjlist.Count - 1
            Dim lst As List(of DataRow) = bjlist(j)
            If i < lst.Count Then
                dr = lst(i)
                If dr("考号锁定") = False
                    dr("考号") = bhstr & Format(idx,"0000")
                    idx += 1
                    p.Value = i
                End If
            End If
        Next
    Next
    
    bj = dt.GetValues("班级",filter & " and 班级 in (4,5,6,7)","班级")
    bjlist.Clear
    max = 0
    For Each s As String In bj
        Dim lst As List(of DataRow) = dt.Select(filter & " And 班级 =\'" & s & "\'","姓名")
        If max < lst.Count Then max = lst.Count
        bjlist.add(lst)
    Next
    idx = 1
    dr = Nothing
    For i As Integer = 0 To max - 1
        For j As Integer = 0 To bjlist.Count - 1
            Dim lst As List(of DataRow) = bjlist(j)
            If i < lst.Count Then
                dr = lst(i)
                If dr("考号锁定") = False
                    dr("考号") = bhstr & Format(idx,"0000")
                    idx += 1
                    p.Value = i
                End If
            End If
        Next
    Next
    
Next

--  作者:刘林
--  发布时间:2017/6/15 12:15:00
--  

但号还是同年级通排如1,2,3班混排至150号,4,5,6接着150号混起走


--  作者:刘林
--  发布时间:2017/6/15 13:53:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20170615134917.png
图片点击可在新窗口打开查看
为什么排号时是1班接10班呢?10班后再接2班呢?想法是按班级从小到大循环
--  作者:有点色
--  发布时间:2017/6/15 14:06:00
--  
以下是引用刘林在2017/6/15 12:15:00的发言:

但号还是同年级通排如1,2,3班混排至150号,4,5,6接着150号混起走

 

做个例子看看。

 

 


--  作者:有点色
--  发布时间:2017/6/15 14:08:00
--  
以下是引用刘林在2017/6/15 13:53:00的发言:

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20170615134917.png

为什么排号时是1班接10班呢?10班后再接2班呢?想法是按班级从小到大循环

 

班号列的值赋值有问题,不能使 1、2、3、10、11、21 这样的,必须改成 01、02、03、10、11、21 这样,不然字符串就是那样排序的。


--  作者:刘林
--  发布时间:2017/6/15 14:10:00
--  

4楼这个排序问题如何解决


--  作者:有点色
--  发布时间:2017/6/15 14:12:00
--  

班号列的值赋值有问题,不能使 1、2、3、10、11、21 这样的,必须改成 01、02、03、10、11、21 这样,不然字符串就是那样排序的。

 

你可以加入一列辅助列【班号】,改成规范的字符,根据此列排序


--  作者:刘林
--  发布时间:2017/8/6 15:40:00
--  

If e.Form.Controls("ComboBox4").value > ""
    Dim p As WinForm.ProgressBar
    p = e.Form.Controls("ProgressBar1")
    p.Maximum = MainTable.Rows.Count \'设置最大值
    p.Minimum = 0 \'设置最小值
    p.Value = 0 \'设置当前值
    Dim ksmc As String = e.Form.controls("combobox4").value
    Dim dt As DataTable = DataTables("成绩")
    Dim Arys As List(Of String())  = dt.GetValues("学校代码|年级代码|考试名称","考试名称 = \'" & ksmc & "\' And 单位名称 = \'" & _usergroup & "\'")
    e.Form.StopRedraw
    For Each Ary As String() In Arys
        Dim szbj As String = e.Form.Controls("CheckedComboBox1").text
        MessageBox.show(szbj)
        Dim filter As String = CExp("学校代码=\'{0}\' and 年级代码=\'{1}\'",Ary(0),Ary(1))
        Dim bhstr As String = Ary(1) & Ary(0)
        Dim bj As List(Of String) = dt.GetValues("班级",filter & " and 班级 in (\'01\',\'02\')","班级")
        Dim bjlist As new List(Of List(of DataRow))(bj.Count)
        Dim max As Integer = 0
        For Each s As String In bj
            Dim lst As List(of DataRow) = dt.Select(filter & " And 班级 =\'" & s & "\'","姓名")
            If max < lst.Count Then max = lst.Count
            bjlist.add(lst)
        Next
        Dim idx As Integer = 1
        Dim dr As DataRow
        For i As Integer = 0 To max - 1
            For j As Integer = 0 To bjlist.Count - 1
                Dim lst As List(of DataRow) = bjlist(j)
                If i < lst.Count Then
                    dr = lst(i)
                    If dr("考号锁定") = False
                        dr("考号") = bhstr & Format(idx,"0000")
                        idx += 1
                        p.Value = i
                    End If
                End If
            Next
        Next
bj = dt.GetValues("班级",filter & " and 班级 not in (\'01\',\'02\')","班级")
    bjlist.Clear
    max = 0
    For Each s As String In bj
        Dim lst As List(of DataRow) = dt.Select(filter & " And 班级 =\'" & s & "\'","姓名")
        If max < lst.Count Then max = lst.Count
        bjlist.add(lst)
    Next
    idx = 1
    dr = Nothing
    For i As Integer = 0 To max - 1
        For j As Integer = 0 To bjlist.Count - 1
            Dim lst As List(of DataRow) = bjlist(j)
            If i < lst.Count Then
                dr = lst(i)
                If dr("考号锁定") = False
                    dr("考号") = bhstr & Format(idx,"0000")
                    idx += 1
                    p.Value = i
                End If
            End If
        Next
    Next
   
Next
        Dim t As Table = Tables("初中报名_Table1")
        t.Sort = "考试名称,考号"
        e.form.ResumeRedraw
        p.value = 0
    
    Else
        MessageBox.show("请选择考试名称","提示")
    End If

 

老师,接着1楼的问题,因需要将排号进行改进,想法是一个年级某次考试排号时可能有需要将01,02班混排,其余班混排,(针对有快慢班)。现在有几个情况:1、如何使快班排完后在排慢班时的号与快班的最大号接着排,2、窗口中加一个checkedcombobox 来选快班,未选的为慢班,这样如何写,谢谢


--  作者:刘林
--  发布时间:2017/8/6 16:07:00
--  

第一个问题解决了: 将这个删了就行了idx = 1,麻烦老师帮看下第2问