public void RelatorioInfraEstruturaPorCurso() { var Cursos = new GerarDadosRelatorioBLL().ListaCursos(); var QuestoesInfra = new GerarDadosRelatorioBLL().ListaQuestoesInfraPorCurso(); var DadosDiscursivas = new GerarDadosRelatorioBLL().DiscursivasInfra(); foreach (var curso in Cursos) { int count = 0; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; Document doc = new Document(PageSize.A4); string NomeArquivo = "Relatório Infraestrutura" + "-" + curso.NomeCurso; string caminho = @"C:\pdf\" + NomeArquivo + ".pdf"; PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(caminho, FileMode.Create)); doc.Open(); Paragraph p = new Paragraph(); p.Add(" "); // Cabeçalho cabecalho(doc, writer, 3, curso.NomeCurso); doc.Add(p); doc.Add(p); doc.Add(p); doc.Add(p); //Corpo do Relatório BaseFont bf = BaseFont.CreateFont( BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED); Font font1 = new Font(bf, 10); BaseFont bf2 = BaseFont.CreateFont( BaseFont.TIMES_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED); Font font2 = new Font(bf2, 10); PdfPTable tableObjetivas = new PdfPTable(4); tableObjetivas.TotalWidth = 450f; tableObjetivas.LockedWidth = true; tableObjetivas.HorizontalAlignment = PdfPCell.ALIGN_CENTER; tableObjetivas.AddCell(new PdfPCell(new Phrase("Descrição Questão", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Média Curso", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Média Geral", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Respondentes", font2))); double MediaQuest = 0; double MediaGeral = 0; int CountQuest = 0; foreach (var QuestInfra in QuestoesInfra) { if ((curso.IdCurso == QuestInfra.IdCurso)) { CountQuest++; MediaQuest = MediaQuest + QuestInfra.MediaQuestao; MediaGeral = MediaGeral + QuestInfra.MediaGeral; tableObjetivas.AddCell(new PdfPCell(new Phrase(QuestInfra.Questao, font1))); tableObjetivas.AddCell(new PdfPCell(new Phrase(QuestInfra.MediaQuestao.ToString("N2"), font1))); tableObjetivas.AddCell(new PdfPCell(new Phrase(QuestInfra.MediaGeral.ToString("N2"), font1))); tableObjetivas.AddCell(new PdfPCell(new Phrase(QuestInfra.QtdAvaliacoes.ToString(), font1))); } } MediaGeral = MediaGeral / CountQuest; MediaQuest = MediaQuest / CountQuest; tableObjetivas.AddCell(new PdfPCell(new Phrase("Média", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase(MediaQuest.ToString("N2"), font1))); tableObjetivas.AddCell(new PdfPCell(new Phrase(MediaGeral.ToString("N2"), font1))); tableObjetivas.AddCell(""); doc.Add(tableObjetivas); doc.Add(p); PdfPTable tableDiscursivas = new PdfPTable(1); tableDiscursivas.TotalWidth = 450f; tableDiscursivas.LockedWidth = true; tableDiscursivas.AddCell(new PdfPCell(new Phrase("Respostas Discursivas", font2))); foreach (var itDisc in DadosDiscursivas) { if (curso.IdCurso == itDisc.IdCurso) { count++; tableDiscursivas.AddCell(new PdfPCell(new Phrase(textInfo.ToLower(itDisc.RespostaDiscursiva), font1))); } } if (count == 0) { tableDiscursivas.AddCell(new PdfPCell(new Phrase("Sem respostas", font1))); } doc.Add(tableDiscursivas); doc.Close(); } }
public void RelatorioProfessores() { var DadosDiscursiva = new GerarDadosRelatorioBLL().ListaDicenteXdocenteSubReportDiscursiva(); var Professores = new GerarDadosRelatorioBLL().ListaDocenteXdocenteMasterReport(); var DadosObjetivas = new GerarDadosRelatorioBLL().ListaDicenteXdocenteSubReport(); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; foreach (var item in Professores) { int count = 0; var curso = item.DescricaoCurso.Replace(':', ' '). Replace('|', ' '). Replace('?', ' '). Replace('<', ' '). Replace('>', ' '). Replace('*', ' '). Replace(':', ' '). Replace('“', ' '). Replace('/', '-'); var disciplina = item.DescricaoDisciplina.Replace(':', ' '). Replace('|', ' '). Replace('?', ' '). Replace('<', ' '). Replace('>', ' '). Replace('*', ' '). Replace(':', ' '). Replace('“', ' '). Replace('/', '-'); Document doc = new Document(PageSize.A4); doc.SetMargins(3, 2, 3, 2); string NomeArquivo = item.NomeProfessor + "-" + curso + "-" + disciplina + "-" + item.IdTurma; string caminho = @"C:\pdf\" + NomeArquivo + ".pdf"; PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(caminho, FileMode.Create)); BaseFont bf = BaseFont.CreateFont( BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED); Font font = new Font(bf, 10); BaseFont bf2 = BaseFont.CreateFont( BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED); Font font2 = new Font(bf2, 11); doc.Open(); Paragraph p = new Paragraph(); p.Add(" "); //Cabeçalho relatório cabecalho(doc, writer, 2, "a"); doc.Add(p); doc.Add(p); doc.Add(p); doc.Add(p); doc.Add(p); PdfPTable tableCabecalho = new PdfPTable(2); tableCabecalho.TotalWidth = 450f; tableCabecalho.LockedWidth = true; tableCabecalho.AddCell(new PdfPCell(new Phrase("Professor", font2))); tableCabecalho.AddCell(new PdfPCell(new Phrase(item.NomeProfessor, font))); tableCabecalho.AddCell(new PdfPCell(new Phrase("Disciplina", font2))); tableCabecalho.AddCell(new PdfPCell(new Phrase(item.DescricaoDisciplina, font))); tableCabecalho.AddCell(new PdfPCell(new Phrase("Turma", font2))); tableCabecalho.AddCell(new PdfPCell(new Phrase(item.IdTurma, font))); doc.Add(tableCabecalho); doc.Add(p); PdfPTable tableObjetivas = new PdfPTable(5); tableObjetivas.TotalWidth = 450f; tableObjetivas.LockedWidth = true; tableObjetivas.HorizontalAlignment = PdfPCell.ALIGN_CENTER; tableObjetivas.AddCell(new PdfPCell(new Phrase("Descrição Questão", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Média Docente", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Média Curso", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Média Geral", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase("Respondentes", font2))); double MediaDoc = 0; double MediaCurs = 0; double MediaGeral = 0; int CountQuest = 0; foreach (var it in DadosObjetivas) { if ((item.IdDisciplina == it.IdDisciplina) && (item.IdProfessor == it.IdProfessor) && (item.IdTurma == it.IdTurma) && (item.IdCurso == it.IdCurso)) { CountQuest++; MediaDoc = MediaDoc + it.MediaDocente; MediaCurs = MediaCurs + it.MediaQuestaoDiciplina; MediaGeral = MediaGeral + it.MediaQuestao; tableObjetivas.AddCell(new PdfPCell(new Phrase(it.DescricaoQuestao, font))); tableObjetivas.AddCell(new PdfPCell(new Phrase(it.MediaDocente.ToString("N2"), font))); tableObjetivas.AddCell(new PdfPCell(new Phrase(it.MediaQuestaoDiciplina.ToString("N2"), font))); tableObjetivas.AddCell(new PdfPCell(new Phrase(it.MediaQuestao.ToString("N2"), font))); tableObjetivas.AddCell(new PdfPCell(new Phrase(it.QuantAvaliacoes.ToString(), font))); } } MediaDoc = MediaDoc / CountQuest; MediaCurs = MediaCurs / CountQuest; MediaGeral = MediaGeral / CountQuest; tableObjetivas.AddCell(new PdfPCell(new Phrase("Total", font2))); tableObjetivas.AddCell(new PdfPCell(new Phrase(MediaDoc.ToString("N2"), font))); tableObjetivas.AddCell(new PdfPCell(new Phrase(MediaCurs.ToString("N2"), font))); tableObjetivas.AddCell(new PdfPCell(new Phrase(MediaGeral.ToString("N2"), font))); tableObjetivas.AddCell(""); doc.Add(tableObjetivas); doc.Add(p); doc.Add(p); doc.Add(p); PdfPTable tableDiscursivas = new PdfPTable(1); tableDiscursivas.TotalWidth = 450f; tableDiscursivas.LockedWidth = true; tableDiscursivas.AddCell(new PdfPCell(new Phrase("Respostas Discursivas", font2))); foreach (var itDisc in DadosDiscursiva) { if ((item.IdProfessor == itDisc.IdProfessor) && (item.IdDisciplina == itDisc.IdDisciplina) && (item.IdTurma == itDisc.IdTurma)) { count++; tableDiscursivas.AddCell(new PdfPCell(new Phrase(textInfo.ToLower(itDisc.RespostaDiscursiva), font))); } } if (count == 0) { tableDiscursivas.AddCell(new PdfPCell(new Phrase("Sem respostas", font))); } doc.Add(tableDiscursivas); doc.Close(); } }