Foxtable(狐表)用户栏目专家坐堂 → 自动学号


  共有2500人关注过本帖树形打印复制链接

主题:自动学号

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/29 9:52:00 [显示全部帖子]

请上传具体实例说明

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/23 22:06:00 [显示全部帖子]

Dim lst As List(of String) = DataTables("学生缴费").GetValues("班内编号","学期='20191'")
Dim max As Integer = val(lst(lst.Count - 1))
Dim lst2 As new List(of String)
For  i As Integer = 1 To max
    If lst.Contains(Format(i,"00")) = False Then lst2.Add(Format(i,"00"))
Next
If lst2.Count > 0 Then
    msgbox("可用编号为" & lst2(0))
Else
    max += 1
    msgbox("可用编号为" & Format(max,"00"))
End If

 回到顶部
帅哥,在线噢!
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/23 22:57:00 [显示全部帖子]

没看懂。表格数据和上面的结果完全对不上。因为表格并没有缺号,如果表格有缺号,6楼的用法没有问题。

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/24 10:23:00 [显示全部帖子]

还不如直接清空,搞个临时编号干嘛

Dim lst As List(of String()) = DataTables("学生缴费").GetValues("学生编号|班内编号","学期='20182'")
Dim lst2 As List(of String) = DataTables("学生缴费").GetValues("学生编号","学期='20191'")

Dim lst3 As new List(of String)
Dim dict As new Dictionary(of String,String)
For Each a1 As String() In lst
    If lst2.Contains(a1(0)) = False Then
        lst3.Add(a1(1))
    Else
        dict.Add(a1(0),a1(1))
    End If
Next
Dim max As Integer = val(DataTables("学生缴费").Compute("max(班内编号)","学期='20182'"))

For Each dr As DataRow In DataTables("学生缴费").Select("学期='20191'")
    If dict.ContainsKey(dr("学生编号"))
        dr("班内编号") = dict(dr("学生编号"))
    Else
        If lst3.Count > 0 Then
            dr("班内编号") = lst3(0)
            lst3.RemoveAt(0)
        Else
            max += 1
            dr("班内编号") = Format(max,"00")
        End If
    End If
Next

 回到顶部
帅哥,在线噢!
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/24 10:52:00 [显示全部帖子]

就4楼的项目,我测试没有问题。如果是搬到自己的项目,看懂代码逻辑,自行扩展

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/9/26 14:54:00 [显示全部帖子]

Dim ary() As String = Functions.Execute("Xueqi")
Dim kjmc() As String = "学生编号,班级".Split(",")
For i As Integer = 0 To kjmc.Length - 1
    If e.Form.Controls(kjmc(i)).Value Is Nothing Then
        MessageBox.Show("【"& kjmc(i)&"】不能为空,请检查")
        e.Form.Controls(kjmc(i)).Select
        Return
    End If
Next
Dim dr1 As DataRow = DataTables("学生缴费").Find("学期 = '"& ary(0) &"' And 学生编号 = '" & e.Form.Controls("学生编号").Text & "'")
If dr1 Is Nothing Then
    
    Dim lst As List(of String()) = DataTables("学生缴费").GetValues("学生编号|班内编号","学期 = '" & ary(0)-9 & "' And 班级 = '" & val(e.Form.Controls("班级").Text) -100 & "'")
    Dim lst2 As List(of String) = DataTables("学生缴费").GetValues("学生编号","学期 ='" & ary(0) & "'  And 班级 = '" & e.Form.Controls("班级").Text & "'")
    Dim lst4 As List(of String) = DataTables("学生缴费").GetValues("班内编号","学期 ='" & ary(0) & "'  And 班级 = '" & e.Form.Controls("班级").Text & "'")
    Dim lst3 As new List(of String)
    Dim dict As new Dictionary(of String,String)
    For Each a1 As String() In lst
        If lst2.Contains(a1(0)) = False Then
            If lst4.Contains(a1(1)) = False Then  lst3.Add(a1(1))
        Else
            dict.Add(a1(0),a1(1))
        End If
    Next
    
    Dim r As DataRow = DataTables("学生缴费").AddNew()
    r("学期") = ary(0)
    r("班级") = e.Form.Controls("班级").Text
    r("学生编号") = e.Form.Controls("学生编号").Text
    Dim max As Integer = val(DataTables("学生缴费").Compute("max(班内编号)","学期 = '"& ary(0) &"' And 班级 = '" & val(e.Form.Controls("班级").Text) & "'"))
    If lst3.Count > 0 Then
        r("班内编号") = lst3(0)
        lst3.RemoveAt(0)
    Else
        max += 1
        r("班内编号") = Format(max,"00")
    End If

End If

 回到顶部
帅哥,在线噢!
有点蓝
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107757 积分:548124 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/10/10 8:35:00 [显示全部帖子]

这种不合理。而且会增加很多额外不必要的操作。个人觉得应该把老生和新生分开处理,先录入所有老生消息,再录入新生

 回到顶部