/// <summary> /// 显示成绩统计界面 /// </summary> void ShowScoreCount() { ClassStudentDao classStudentDao = new ClassStudentDao(); StudentDao studentDaoDao = new StudentDao(); List <ClassStudentBean> classStudentList = classStudentDao.FindListById(new ClassStudentBean(CourseClass.Id, 0, 0, 0, 0, 0)); if (classStudentList.Count == 0) { return; } //计算平均分、最高分、最低分、分段统计 int stuId_MaxScore = classStudentList[0].Student_Id; int stuId_MinScore = classStudentList[0].Student_Id; int maxScore = classStudentList[0].Score; int minScore = classStudentList[0].Score; float avgScore = 0; int 及格人数 = 0; int 及格人数 = 0; int 九十分及以上人数 = 0; foreach (ClassStudentBean bean in classStudentList) { if (bean.Score > maxScore) { maxScore = bean.Score; stuId_MaxScore = bean.Student_Id; } if (bean.Score < minScore) { minScore = bean.Score; stuId_MinScore = bean.Student_Id; } if (bean.Score >= 90) { 九十分及以上人数++; } else if (bean.Score >= 60) { 及格人数++; } else { 及格人数++; } avgScore += bean.Score; } avgScore = avgScore / classStudentList.Count; //打印 StudentBean stu_maxScore = studentDaoDao.FindById(new StudentBean(stuId_MaxScore)); StudentBean stu_minScore = studentDaoDao.FindById(new StudentBean(stuId_MinScore)); label3.Text = "班级平均分 : " + avgScore; label4.Text = "班级最高分 : " + maxScore + "(" + stu_maxScore.Name + ")"; label5.Text = "班级最低分 : " + minScore + "(" + stu_minScore.Name + ")";; label6.Text = "各分段统计 :不及格人数= " + 及格人数 + " 及格人数= " + 及格人数 + " 九十分及以上人数= " + 九十分及以上人数; }