DataTables("班级超人数奖励").DataRows.Clear() For Each dr1 As DataRow In DataTables("班级人数").DataRows For Each dr2 As DataRow In DataTables("教师课时安排").Select("[学期] = \'" & dr1("学期") & "\' and [班级] =\'" & dr1("班级") & "\'") Dim nm As String = dr2("学期") Dim vl As Integer = dr1("班级人数")*? If dic.ContainsKey(nm) = False dic.Add(nm,vl) Else dic(nm) = dic(nm)+ vl End If Next Next For Each key As String In dic.keys Dim dr As DataRow = DataTables("班级超人数奖励").AddNew() dr("学期") = key dr("班级超人数") = dic(key) Next
Dim dic1 As new Dictionary(of String,Integer) DataTables("班级超人数奖励").DataRows.Clear() For Each dr1 As DataRow In DataTables("班级人数").DataRows For Each dr2 As DataRow In DataTables("教师课时安排").Select("[学期] = \'" & dr1("学期") & "\' and [班级] =\'" & dr1("班级") & "\'") Dim nm1 As String = dr2("教工姓名") Dim vl As Integer = dr1("班级人数")*? If dic1.ContainsKey(nm1 & "|" & dr2("学期")) = False dic1.Add(nm1 & "|" & dr2("学期"),vl) Else dic1(nm1 & "|" & dr2("学期")) = dic1(nm1 & "|" & dr2("学期"))+ vl End If Next Next For Each key As String In dic1.keys Dim dr1 As DataRow = DataTables("班级超人数奖励").AddNew() Dim str() As String = key.Split("|") dr1("教工姓名") = str(0) dr1("学期")=str(1) dr1("班级超人数") = dic1(key) Next