Dim d As Date = Date.Today
Dim SXQ As String
If d.Month >= 5 And d.Month <=11 Then
SXQ = d.Year & "年春季"
Else If d.Month = 12 Then
SXQ = d.Year & "年秋季"
Else If d.Month < 5 Then
SXQ = (d.Year-1) & "年秋季"
End If
Dim fdr As DataRow = DataTables("学生信息").find("学期 = '"& SXQ &"'And 学生姓名 = '" & e.Form.controls("学生姓名").Text & "'")
If fdr IsNot Nothing Then
If fdr("学期") Like "*春*" Then
Dim bjs As List(Of String) = DataTables("计划人数").GetValues("班级","学期 = '"& SXQ &"'")
If bjs.Contains(cstr(fdr("班级")+100)) Then
e.Form.controls("班级").Text = fdr("班级")+100
Else
Dim pre As String = cint(fdr("班级").ToString().SubString(0,1)) + 1
Dim count As Integer
Dim min As Integer = 999
Dim newbj As String
For Each bj As String In bjs
If bj.StartsWith(pre) Then
count = DataTables("学生信息").Compute("count(学生姓名)","学期 = '" & SXQ & "' And 班级='" & bj & "'")
If count < min Then
min = count
newbj = bj
End If
End If
Next
e.Form.controls("班级").Text = newbj
End If
Else
e.Form.controls("班级").Text = fdr("班级")
End If
End If