Esempio n. 1
0
        private void GradeGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (isAssignmentColumn(e.ColumnIndex))
            {
                StudentViewModel    student    = (StudentViewModel)this.Rows[e.RowIndex].DataBoundItem;
                AssignmentViewModel assignment = (AssignmentViewModel)this.Columns[e.ColumnIndex].Tag;

                if (assignment.Grades.ContainsKey(student.Id))
                {
                    if (this[e.ColumnIndex, e.RowIndex].IsInEditMode)
                    {
                        this.Columns[e.ColumnIndex].DefaultCellStyle.Format = "";
                        e.Value = assignment.Grades[student.Id].Points;
                    }
                    else
                    {
                        this.Columns[e.ColumnIndex].DefaultCellStyle.Format = "P";
                        double gradePercentage = assignment.CalculateGradePercentage(student);
                        e.Value = gradePercentage;
                        e.CellStyle.BackColor = GradeColorCode.getColor(gradePercentage);
                    }
                }
            }
            else if (this.Columns["totalGradeColumn"].Index == e.ColumnIndex)
            {
                StudentViewModel student         = (StudentViewModel)this.Rows[e.RowIndex].DataBoundItem;
                double           gradePercentage = Course.CalculateGradePercentage(student);
                e.Value = gradePercentage;
                e.CellStyle.BackColor = GradeColorCode.getColor(gradePercentage);
            }
        }
Esempio n. 2
0
        private void GradeTotalsGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            StudentViewModel student = (StudentViewModel)this.Rows[e.RowIndex].DataBoundItem;

            if (isGradingPeriodColumn(e.ColumnIndex))
            {
                GradingPeriodViewModel gradingPeriod = (GradingPeriodViewModel)this.Columns[e.ColumnIndex].Tag;

                CourseViewModel course = findCourse(gradingPeriod);

                double gradePercentage = course.CalculateGradePercentage(student);
                e.Value = gradePercentage;
                e.CellStyle.BackColor = GradeColorCode.getColor(gradePercentage);
            }
            else if (this.Columns["totalGradeColumn"].Index == e.ColumnIndex)
            {
                double gradePercentage = calculateStudentTotalGradePercentage(student);
                e.Value = gradePercentage;
                e.CellStyle.BackColor = GradeColorCode.getColor(gradePercentage);
            }
        }