Dim dic 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 nm As String = dr2("学科")
Dim vl As String = dr1("班级人数")*dr2("课时")
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 String = dr1("班级人数")*dr2("课时")
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
Dim dic2 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 nm2 As String = dr2("学期")
Dim vl As String = dr1("班级人数")*dr2("课时")
If dic2.ContainsKey(nm2 & "|" & dr2("学期")) = False
dic2.Add(nm2 & "|" & dr2("学期"),vl)
Else
dic2(nm2 & "|" & dr2("学期")) = dic2(nm2 & "|" & dr2("学期"))+ vl
End If
Next
Next
For Each key As String In dic1.keys
Dim dr2 As DataRow = DataTables("教师课时奖励").AddNew()
Dim str() As String = key.Split("|")
dr2("教师姓名") = str(0)
dr2("学科")=str(1)
dr2("学期")=str(2)
dr2("超班额金额") = dic2(key)
Next
前两组是对的,好像错在第三组,请高手指教
此主题相关图片如下:qq截图20130424153217.png
[此贴子已经被作者于2013-4-24 15:33:26编辑过]