Exemplo n.º 1
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            var exportFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var exportFile   = System.IO.Path.Combine(exportFolder, "MarkSummary.pdf");

            Users[]           users  = UserFacade.GetStudentsToPDFForm(LoginPanel.TeacherID);
            Students_Groups[] groups = DependencyFacade.GetStudentsGroupsPDF(LoginPanel.TeacherID);
            Table             tab    = new Table(3);

            tab.AddCell("Section number:");
            tab.AddCell("Album number:");
            tab.AddCell("Mark:");

            using (var writer = new PdfWriter(exportFile))
            {
                using (var pdf = new PdfDocument(writer))
                {
                    if (groups != null)
                    {
                        var doc = new Document(pdf);
                        doc.Add(new Paragraph("List of grades for semester:\n\n\n\n\n\n").SetRelativePosition(200, 20, 50, 200));
                        for (int i = 0; i < groups.Length; i++)
                        {
                            tab.AddCell(groups[i].GroupID.ToString());
                            tab.AddCell(groups[i].StudentAlbumNr + ": ");
                            if (!groups[i].Mark.ToString().Equals(null))
                            {
                                tab.AddCell(groups[i].Mark.ToString());
                            }
                            else
                            {
                                tab.AddCell("No mark");
                            }
                        }
                        doc.Add(tab);
                    }
                }
            }
        }