private void BindStudent() { Repository.ClassAssignment repoClassAssignment = new Repository.ClassAssignment(); List <Repository.Entity.Student> students = repoClassAssignment.GetClassStudents(this.NewClassID); this.dgStudent.DataSource = students; }
private void BtnClear_Click(object sender, EventArgs e) { if (MessageBox.Show("确认清空所有分班信息?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // 清空原有分班信息 Repository.ClassAssignment repoClassAssignment = new Repository.ClassAssignment(); repoClassAssignment.Clear(); } }
private void ChkNoClass_CheckedChanged(object sender, EventArgs e) { if (this.chkNoClass.Checked) { Repository.ClassAssignment repoClassAssignment = new Repository.ClassAssignment(); List <Repository.Entity.Student> cs = repoClassAssignment.GetNoClassStudents(""); this.dgStudent.DataSource = cs; } else { this.BindStudent(); } }
private void BindClassStudent(int cid) { this.dgClassStudent.AutoGenerateColumns = false; Repository.ClassAssignment repoClassAssignment = new Repository.ClassAssignment(); List <Repository.Entity.Student> cs = repoClassAssignment.GetClassStudents(cid); this.dgClassStudent.DataSource = cs; this.lblTotal.Text = cs.Count.ToString(); this.lblBoys.Text = cs.Where(x => x.xb == "男").ToList <Repository.Entity.Student>().Count.ToString(); this.lblGirls.Text = cs.Where(x => x.xb == "女").ToList <Repository.Entity.Student>().Count.ToString(); this.lblAverage.Text = cs.Count > 0?cs.Average(x => x.zf).ToString():"0"; }
private void BindRecommendedStudent() { Repository.ClassAssignment repoClassAssignment = new Repository.ClassAssignment(); List <Repository.Entity.Student> students = repoClassAssignment.GetClassStudents(this.NewClassID); // 推荐规则 // 1. 性别相同 // 2. 总分与对调学生最接近的1个人 List <Repository.Entity.Student> candidates = students.Where(x => x.xb == this.OldStudent.xb).ToList(); // 取性别相同学生 float minDiff = Math.Abs(candidates[0].zf - this.OldStudent.zf); this.recomendedStudents.Insert(0, candidates[0]); for (int i = 1; i < candidates.Count; i++) { if (Math.Abs(candidates[i].zf - this.OldStudent.zf) < minDiff) { minDiff = Math.Abs(candidates[i].zf - this.OldStudent.zf); this.recomendedStudents[0] = candidates[i]; } } this.dgRecommendedStudent.DataSource = this.recomendedStudents; }