private void RefreshData()
        {
            if (cmbSummaryGradeType.SelectedItem != null && cmbSchoolSubjects.SelectedItem != null)
            {
                if (cmbSummaryGradeType.SelectedItem != null && cmbSchoolSubjects.SelectedItem != null)
                {
                    if (rdbShowGrades.Checked)
                    {
                        dgwGrades.DataSource = db.GetGradesOfStudent(currentStudent, currentSchoolYear,
                                                                     ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType,
                                                                     ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject,
                                                                     dtpStartPeriod.Value, dtpEndPeriod.Value
                                                                     );
                        lblSum.Text = "";
                        txtMediaMicroDomande.Text = "";
                    }
                    else if (rdbShowWeights.Checked)
                    {
                        dgwGrades.DataSource = db.GetWeightedAveragesOfStudent(currentStudent,
                                                                               ((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 (rdbShowWeightedGrades.Checked)
                    {
                        dgwGrades.DataSource = db.GetGradesWeightedAveragesOfStudent(currentStudent,
                                                                                     ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType,
                                                                                     ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject,
                                                                                     dtpStartPeriod.Value, dtpEndPeriod.Value
                                                                                     );
                        lblSum.Text = "";
                        txtMediaMicroDomande.Text = "";
                    }
                    else if (rdbShowWeightsOnOpenGrades.Checked)
                    {
                        dgwGrades.DataSource = db.GetGradesWeightsOfStudentOnOpenGrades(currentStudent,
                                                                                        ((GradeType)(cmbSummaryGradeType.SelectedItem)).IdGradeType,
                                                                                        ((SchoolSubject)(cmbSchoolSubjects.SelectedItem)).IdSchoolSubject,
                                                                                        dtpStartPeriod.Value, dtpEndPeriod.Value
                                                                                        );
                        lblSum.Text = "";
                        txtMediaMicroDomande.Text = "";

                        setRowNumbers(dgwGrades);
                    }
                }
            }
        }