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