private void RetrieveData(RadioButton rdb) { if (cmbSummaryGradeType.SelectedItem != null && cmbSchoolSubjects.SelectedItem != null) { if (rdb == rdbMissing) { dgwGrades.DataSource = db.GetStudentsWithNoMicrogrades(currentClass, ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType, ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject, dtpStartPeriod.Value, dtpEndPeriod.Value ); } if (rdb == rdbShowGrades) { dgwGrades.DataSource = db.GetGradesOfClass(currentClass, ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType, ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject, dtpStartPeriod.Value, dtpEndPeriod.Value ); lblSum.Text = ""; txtMediaMicroDomande.Text = ""; } else if (rdb == rdbShowWeights) { dgwGrades.DataSource = db.GetWeightedAveragesOfClass(currentClass, ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType, ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject, dtpStartPeriod.Value, dtpEndPeriod.Value ); double sumLeftToClose = 0; double maxGradesFraction = 0; foreach (DataRow row in ((DataTable)dgwGrades.DataSource).Rows) { double gf = (double)row["GradesFraction"]; if (gf > maxGradesFraction) { maxGradesFraction = gf; } sumLeftToClose += (double)row["LeftToCloseAssesments"]; } int nGrades = (int)Math.Round(maxGradesFraction + 0.10); lblSum.Text = "Mancanti a fine giro"; txtMediaMicroDomande.Text = (sumLeftToClose / nGrades).ToString(); } else if (rdb == rdbShowWeightedGrades) { dgwGrades.DataSource = db.GetGradesWeightedAveragesOfClass(currentClass, ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType, ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject, dtpStartPeriod.Value, dtpEndPeriod.Value ); lblSum.Text = ""; txtMediaMicroDomande.Text = ""; } else if (rdb == rdbShowWeightsOnOpenGrades) { dgwGrades.DataSource = db.GetGradesWeightsOfClassOnOpenGrades(currentClass, ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType, ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject, dtpStartPeriod.Value, dtpEndPeriod.Value ); lblSum.Text = ""; txtMediaMicroDomande.Text = ""; setRowNumbers(dgwGrades); } } txtNStudents.Text = ((DataTable)dgwGrades.DataSource).Rows.Count.ToString(); }