public static void CreateStudentCPsDataGridView(ref DataGridView dgv, uint groupId, uint disciplineId, out bool isReexamCommited) { dgv.Columns.Clear(); isReexamCommited = false; int cpIter = 0; double sum = 0; List <StudentExam> exams = null; StudentReexam tempReexam = null; List <StudentsWithCP> studentsCPs = GetStudentsCPs(groupId, disciplineId, out exams); if (isHavingNullPoints(ref studentsCPs)) { return; } DataGridViewColumn[] columns = CreateColumns(ref dgv, studentsCPs); if (columns == null) { throw new NullReferenceException($"In 'studentCPsDataGridViewFactory'.'CreateStudentCPsDataGridView' object 'columns' = {columns == null}"); } dgv.Columns.AddRange(columns); dgv.Rows.Add(studentsCPs.Count); if (exams.Count == 0) { dgv.Columns["grade"].Visible = false; } for (int i = 0; i < studentsCPs.Count; i++) { dgv.Rows[i].Cells[0].Value = studentsCPs[i].id; dgv.Rows[i].Cells[1].Value = studentsCPs[i].name; for (int j = 2; j < dgv.Columns.Count - 2; j += 2, cpIter++) { dgv.Rows[i].Cells[j].Value = studentsCPs[i].studentCPs[cpIter].id; dgv.Rows[i].Cells[j + 1].Value = studentsCPs[i].studentCPs[cpIter].points; sum += studentsCPs[i].studentCPs[cpIter].points; } if (exams.Count != 0) { if (exams[i].id_of_reexam != 0) { tempReexam = GetReexam(exams[i].id_of_reexam); if (tempReexam.points == 0) { dgv.Rows[i].Cells[dgv.Columns.Count - 1].Value = "неуд."; dgv.Rows[i].Cells[dgv.Columns.Count - 1].Style.BackColor = Color.IndianRed; } else if (tempReexam.points != 0) { dgv.Rows[i].Cells[dgv.Columns.Count - 1].Value = $"{tempReexam.CountRecommendedGrade(studentsCPs[i].id, disciplineId)}*"; dgv.Rows[i].Cells[dgv.Columns.Count - 1].Style.BackColor = Color.White; isReexamCommited = true; } } else if (exams[i].id_of_reexam == 0) { dgv.Rows[i].Cells[dgv.Columns.Count - 1].Value = exams[i].CountRecommendedGrade(); } //dgv.Rows[i].Cells[dgv.Columns.Count - 1].Style.BackColor = Color.LightSeaGreen; } dgv.Rows[i].Cells[dgv.Columns.Count - 2].Value = sum; cpIter = 0; sum = 0; } }
private void GenerateReportColumns(ref Document doc, ref PdfPTable stTable) { StudentReexam bufReexam = null; Font trFont = new Font(bFont, 13, Font.NORMAL, BaseColor.BLACK); PdfPCell trCell; int iter = 0; foreach (Student student in students) { trCell = new PdfPCell(); trCell.AddElement(new Paragraph((iter + 1).ToString(), trFont) { Alignment = Element.ALIGN_LEFT }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph(student.name, trFont) { Alignment = Element.ALIGN_LEFT }); stTable.AddCell(trCell); trCell = new PdfPCell(); if (exams[iter].id_of_reexam == 0) { trCell.AddElement(new Paragraph((exams[iter].GetMaxStudentScore() + exams[iter].points).ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph(exams[iter].points.ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph((exams[iter].GetMaxSumOfPoints() + 20).ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph(exams[iter].CountRecommendedGrade().ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); } else { bufReexam = GetStudentReexam(exams[iter].id_of_reexam); if (bufReexam == null) { return; } trCell.AddElement(new Paragraph(bufReexam.points.ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph((bufReexam.GetMaxStudentScore(exams[iter].id_of_student, exams[iter].id_of_discipline) + bufReexam.points).ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph((bufReexam.GetMaxSumOfPoints(exams[iter].id_of_student, exams[iter].id_of_discipline) + 20).ToString(), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); trCell = new PdfPCell(); trCell.AddElement(new Paragraph((bufReexam.points != 0?bufReexam.grade.ToString() + "*":"неуд."), trFont) { Alignment = Element.ALIGN_CENTER }); stTable.AddCell(trCell); } iter++; } stTable.SpacingAfter = 25; doc.Add(stTable); }