public static MemoryStream GeneratePDF(Teacher teacher, SchoolClass schoolClass, string schoolYear) { Document document = new Document(); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); writer.CloseStream = false; document.Open(); document.AddCreationDate(); document.AddAuthor("VaKEGrade"); document.AddTitle("Certificate"); foreach (Pupil pupil in teacher.PrimaryClasses.First().Pupils.OrderBy(x => x.LastName).ToList()) { CertificateGenerator.GenerateCertificate(pupil, schoolClass, schoolYear, ref document); } document.Close(); stream.Seek(0, SeekOrigin.Begin); return stream; }
public void GenerateClasses() { Random random; SchoolClass schoolClass; List<Branch> b = repository.GetBranches().ToList(); for (int i = 0; i < 12; i++) { random = new Random(); schoolClass = new SchoolClass(); schoolClass.Level = random.Next(1,5); schoolClass.Name = ((char)random.Next(97, 106)).ToString(); schoolClass.Branch = b[random.Next(0, b.Count)]; List<Teacher> pt = repository.GetTeachers().Where(x=>x.PrimaryClasses.Count == 0).ToList(); schoolClass.PrimaryClassTeacher = pt[random.Next(0, pt.Count)]; if (random.Next(0, 100) <= 20) { pt = repository.GetTeachers().Where(x => x.PrimaryClasses.Count == 0).ToList(); schoolClass.SecondaryClassTeacher = pt[random.Next(0, pt.Count)]; } repository.AddClass(schoolClass); } }
public void AddClass(SchoolClass schoolClass) { entities.AddToSchoolClasses(schoolClass); entities.SaveChanges(); }
public IEnumerable<Subject> GetSubjectsOfClass(SchoolClass schoolClass) { return (from bsa in schoolClass.Branch.BranchSubjectAssignments where bsa.Level == schoolClass.Level select bsa.Subject); }
public void AssignSubject(Teacher teacher, Subject subject, SchoolClass schoolClass) { entities.AddToTeacherSubjectAssignments(new TeacherSubjectAssignment() { Teacher = teacher, Subject = subject, SchoolClass = schoolClass}); entities.SaveChanges(); }
public void AssignSchoolClass(Teacher teacher, SchoolClass schoolClass) { if (teacher.PrimaryClasses.Count > 0) throw new AlreadyAssignedException(teacher.PrimaryClasses.First(), teacher); teacher.PrimaryClasses.Add(schoolClass); entities.SaveChanges(); }
private static void GenerateCertificate(Pupil pupil, SchoolClass schoolClass, string schoolYear, ref Document document) { Paragraph paragraph; PdfPTable table; PdfPCell cell; paragraph = new Paragraph("HAUPTSCHULE 1 RIED IM INNKREIS", FontFactory.GetFont("Arial", 14f, 1)); paragraph.Alignment = 1; document.Add(paragraph); table = new PdfPTable(1); cell = new PdfPCell(new Paragraph("Brucknerstraße 20, 4910 Ried im Innkreis", FontFactory.GetFont("Arial", 7f, 0))); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0.5f; cell.BorderColorBottom = BaseColor.BLACK; cell.PaddingBottom = 5; cell.HorizontalAlignment = Element.ALIGN_CENTER; table.AddCell(cell); table.WidthPercentage = 100f; document.Add(table); //paragraph = new Paragraph("Brucknerstraße 20, 4910 Ried im Innkreis", FontFactory.GetFont("Arial", 10f, 0)); //paragraph.Alignment = 1; //paragraph.SpacingAfter = 12; //document.Add(paragraph); table = new PdfPTable(2); cell = new PdfPCell(new Paragraph("Alternative Form der Leistungsbeurteilung gemäß § 78 SchUG", FontFactory.GetFont("Arial", 7f, 0))); cell.BorderWidth = 0; cell.Padding = 0; cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Paragraph("Schuljahr " + schoolYear, FontFactory.GetFont("Arial", 7f, 0))); cell.BorderWidth = 0; cell.Padding = 0; cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); table.WidthPercentage = 100f; table.SpacingAfter = 10; document.Add(table); paragraph = new Paragraph("Jahreszeugnis", FontFactory.GetFont("Arial", 24f, 0)); paragraph.Alignment = 1; document.Add(paragraph); paragraph = new Paragraph("VaKE-Klasse", FontFactory.GetFont("Arial", 12f, 0)); paragraph.Alignment = 1; paragraph.SpacingAfter = 8; document.Add(paragraph); paragraph = new Paragraph(pupil.LastName.ToUpper() + " " + pupil.FirstName, FontFactory.GetFont("Arial", 14f, 1)); paragraph.Alignment = 1; paragraph.SpacingAfter = 8; document.Add(paragraph); paragraph = new Paragraph("geboren am " + pupil.Birthdate.ToShortDateString() + ", Religionsbekenntnis: " + pupil.Religion, FontFactory.GetFont("Arial", 11f, 0)); paragraph.Alignment = 1; paragraph.SpacingAfter = 3; document.Add(paragraph); paragraph = new Paragraph((pupil.Gender == "m" ? "Schüler" : "Schülerin") + " der Klasse " + schoolClass.Level + schoolClass.Name + " (" + (schoolClass.Level + 4) + ".Schulstufe), Hauptschule", FontFactory.GetFont("Arial", 11f, 0)); paragraph.Alignment = 1; paragraph.SpacingAfter = 3; document.Add(paragraph); paragraph = new Paragraph("Verhalten in der Schule: ", FontFactory.GetFont("Arial", 12f, 0)); paragraph.Add(new Chunk("Sehr zufriedenstellend", FontFactory.GetFont("Arial", 11f, 1))); paragraph.Alignment = 0; paragraph.SpacingAfter = 10; document.Add(paragraph); document.Add(CertificateGenerator.GenerateImage(pupil)); if (pupil.BindingSubjectAssignments.Count > 0) { List<Subject> bindingSubjects = (from vsa in pupil.BindingSubjectAssignments select vsa.Subject).ToList(); string subjects = ""; for(int i = 0; i < bindingSubjects.Count; i++) { subjects += (bindingSubjects.Count > 1 && i == bindingSubjects.Count-1 ? " und " : " ") + "\"" + bindingSubjects[i].Name + "\""+(i < bindingSubjects.Count-2 ? "," : ""); } subjects.Remove(subjects.Length - 1,1); paragraph = new Paragraph((pupil.Gender == "m" ? "Er" : "Sie") + " hat an "+(bindingSubjects.Count > 1 ? "den" : "der")+" verbindlichen "+(bindingSubjects.Count > 1 ? "Übungen" : "Übung") + subjects + " teilgenommen.", FontFactory.GetFont("Arial", 9f, 0)); paragraph.Alignment = 0; paragraph.SpacingBefore = 5; paragraph.SpacingAfter = 0; document.Add(paragraph); } if (pupil.VoluntarySubjectAssignements.Count > 0) { List<Subject> voluntarySubjects = (from vsa in pupil.VoluntarySubjectAssignements select vsa.Subject).ToList(); string subjects = ""; for (int i = 0; i < voluntarySubjects.Count; i++) { subjects += (voluntarySubjects.Count > 1 && i == voluntarySubjects.Count - 1 ? " und " : " ") + "\"" + voluntarySubjects[i].Name + "\"" + (i < voluntarySubjects.Count - 2 ? "," : ""); } subjects.Remove(subjects.Length - 1); paragraph = new Paragraph((pupil.Gender == "m" ? "Er" : "Sie") + " hat an " + (voluntarySubjects.Count > 1 ? "den" : "der") + " freiwilligen " + (voluntarySubjects.Count > 1 ? "Übungen " : "Übung ") + subjects + " teilgenommen.", FontFactory.GetFont("Arial", 9f, 0)); paragraph.Alignment = 0; paragraph.SpacingBefore = 5; paragraph.SpacingAfter = 0; document.Add(paragraph); } paragraph = new Paragraph((pupil.Gender == "m" ? "Er" : "Sie") + " ist gemäß §25 des SchUG zum Aufsteigen in die " + (schoolClass.Level + 1) + ".Klasse (" + (schoolClass.Level + 5) + ".Schulstufe) berechtigt.", FontFactory.GetFont("Arial", 9f, 0)); paragraph.Alignment = 0; paragraph.SpacingBefore = 30; paragraph.SpacingAfter = 50; document.Add(paragraph); paragraph = new Paragraph("Ried im Innkreis, am " + DateTime.Now.ToShortDateString(), FontFactory.GetFont("Arial", 10f, 0)); paragraph.Alignment = 0; paragraph.SpacingAfter = 30; document.Add(paragraph); paragraph = new Paragraph("R.S.", FontFactory.GetFont("Arial", 10f, 1)); paragraph.Alignment = 1; paragraph.SpacingAfter = 25; document.Add(paragraph); table = new PdfPTable(2); cell = new PdfPCell(new Paragraph("__________________________", FontFactory.GetFont("Arial", 10f, 0))); cell.BorderWidth = 0; cell.Padding = 0; cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Paragraph("__________________________", FontFactory.GetFont("Arial", 10f, 0))); cell.BorderWidth = 0; cell.Padding = 0; cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); cell = new PdfPCell(new Paragraph("Leiter der Schule", FontFactory.GetFont("Arial", 7f, 0))); cell.PaddingTop = 3; cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Paragraph("Klassenvorstand", FontFactory.GetFont("Arial", 7f, 0))); cell.PaddingTop = 3; cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); cell = new PdfPCell(new Paragraph("Max Mustermann", FontFactory.GetFont("Arial", 9f, 0))); cell.BorderWidth = 0; cell.Padding = 0; cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0.5f; cell.BorderColorBottom = BaseColor.BLACK; cell.PaddingBottom = 12; cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); cell = new PdfPCell(new Paragraph(schoolClass.PrimaryClassTeacher.FirstName + " " + schoolClass.PrimaryClassTeacher.LastName, FontFactory.GetFont("Arial", 9f, 0))); cell.BorderWidth = 0; cell.Padding = 0; cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0.5f; cell.BorderColorBottom = BaseColor.BLACK; cell.PaddingBottom = 12; cell.HorizontalAlignment = Element.ALIGN_RIGHT; table.AddCell(cell); table.WidthPercentage = 100f; table.SpacingAfter = 10; document.Add(table); paragraph = new Paragraph("DVR: 0064351412052\nBeurteilungskriterien: Lernziele (LZ), Mitarbeit (MA)\nBeurteilungsstufen: Sehr gut (1), Gut (2), Befriedigend (3), Genügend (4), Nicht genügend (5), Nicht teilgenommen (0)\nVerhalten in der Schule: Sehr zufriedenstellend, Zufriedenstellend, Wenig zufriedenstellend, Nicht zufriedenstellend\n", FontFactory.GetFont("Arial", 7f, 0)); paragraph.Add(new Chunk(pupil.LastName.ToUpper() + " " + pupil.FirstName, FontFactory.GetFont("Arial", 7f, 2))); paragraph.Alignment = 0; document.Add(paragraph); document.NewPage(); }
/// <summary> /// Deprecated Method for adding a new object to the SchoolClasses EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSchoolClasses(SchoolClass schoolClass) { base.AddObject("SchoolClasses", schoolClass); }
/// <summary> /// Create a new SchoolClass object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="level">Initial value of the Level property.</param> /// <param name="primaryClassTeacherID">Initial value of the PrimaryClassTeacherID property.</param> public static SchoolClass CreateSchoolClass(global::System.Int32 id, global::System.String name, global::System.Int32 level, global::System.Int32 primaryClassTeacherID) { SchoolClass schoolClass = new SchoolClass(); schoolClass.ID = id; schoolClass.Name = name; schoolClass.Level = level; schoolClass.PrimaryClassTeacherID = primaryClassTeacherID; return schoolClass; }