public ActionResult ViewMarks(int id) { classID = id; List <Pupil> pupils = PupilsDB.GetPupilsInClass(id); // Список учеников. ViewBag.Pupils = pupils; List <List <Subject> > subjects = new List <List <Subject> >(); for (int i = 0; i < pupils.Count; i++) { subjects.Add(SubjectsDB.GetPupilSubjects(pupils[i].Pupil_ID)); } // Предметы по которым у ученика есть оценки. ViewBag.Subjects = subjects; List <List <List <Mark> > > marks = new List <List <List <Mark> > >(); for (int i = 0; i < pupils.Count; i++) { marks.Add(new List <List <Mark> >(subjects[i].Count)); for (int j = 0; j < subjects[i].Count; j++) { marks[i].Add(MarksDB.GetPupilSubjectMark(pupils[i].Pupil_ID, subjects[i][j].Subject_ID)); } } ViewBag.Marks = marks; return(View()); }
public ActionResult SchoolMarksStatistic() { List <KeyValuePair <int, int> > statistic = MarksDB.GetSchoolMarksStatistic(); ViewBag.Statistic = statistic; return(View()); }
public ActionResult ViewMarkInfo(int delete, int a = 0) { int pupilId = PupilsDB.GetPupilIdByMark(delete); PupilFullInformation p = PupilsDB.GetPupilsFullInformation(pupilId); int classID = ClassesDB.GetClassId(p.Class); MarksDB.DeleteMark(delete); return(RedirectToAction("ViewMarks", "Teacher", new { id = classID })); }
public ActionResult AddNewMark(Mark m, int res = 0) { MarksDB.AddMark(m.Pupil_ID, res, (int)m.TypeOfWork_ID, (int)m.PupilMark); PupilFullInformation pupil = PupilsDB.GetPupilsFullInformation(m.Pupil_ID); int classID = ClassesDB.GetClassId(pupil.Class); return(RedirectToAction("ViewMarks", "Teacher", new { id = classID })); }
public ActionResult SearchMarksBySurname(string Person) { string[] parts = Person.Split(' '); List <PupilWithClass> pupils = new List <PupilWithClass>(); if (parts.Length == 3) { string part1 = parts[0]; string part2 = parts[1]; string part3 = parts[2]; pupils = PupilsDB.SearchPupilByThreeParametersAndClass(part1, part2, part3, TeacherController.classID); } else if (parts.Length == 2) { string part1 = parts[0]; string part2 = parts[1]; pupils = PupilsDB.SearchPupilByTwoParametersAndClass(part1, part2, TeacherController.classID); } if (pupils.Count != 0) { ViewBag.Pupil = pupils[0]; } List <Pupil> pupilsInClass = PupilsDB.GetPupilsInClass(TeacherController.classID); ViewBag.Pupils = PupilsDB.GetPupilsInClass(TeacherController.classID); List <List <Subject> > subjects = new List <List <Subject> >(); for (int i = 0; i < pupilsInClass.Count; i++) { subjects.Add(SubjectsDB.GetPupilSubjects(pupilsInClass[i].Pupil_ID)); } // Предметы по которым у ученика есть оценки. ViewBag.Subjects = subjects; List <List <List <Mark> > > marks = new List <List <List <Mark> > >(); for (int i = 0; i < pupilsInClass.Count; i++) { marks.Add(new List <List <Mark> >(subjects[i].Count)); for (int j = 0; j < subjects[i].Count; j++) { marks[i].Add(MarksDB.GetPupilSubjectMark(pupilsInClass[i].Pupil_ID, subjects[i][j].Subject_ID)); } } ViewBag.Marks = marks; return(PartialView()); }
public ActionResult SelectAbsentPupils(int lesson, List <int> Absent) { if (Absent != null) { for (int i = 0; i < Absent.Count; i++) { MarksDB.AddAbsentMark(Absent[i], lesson); } } int classID = TeacherController.classID; return(RedirectToAction("ViewMarks", "Teacher", new { id = classID })); }
public JsonResult GetSchoolMarksStatistic() { List <KeyValuePair <int, int> > statistic = MarksDB.GetSchoolMarksStatistic(); List <KeyValuePair <string, int> > result = new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("От 0 до 4:", statistic[0].Value), new KeyValuePair <string, int>("От 4 до 7:", statistic[1].Value), new KeyValuePair <string, int>("От 7 до 9:", statistic[2].Value), new KeyValuePair <string, int>("От 9 до 12:", statistic[3].Value), }; return(Json(new { Results = result }, JsonRequestBehavior.AllowGet)); }
public ActionResult GetPupilMarksReport(int pupilID) { PupilFullInformation pupil = PupilsDB.GetPupilsFullInformation(pupilID); List <Subject> subjects = SubjectsDB.GetPupilSubjects(pupil.Pupil_ID); List <List <Mark> > marks = new List <List <Mark> >(); for (int i = 0; i < subjects.Count; i++) { marks.Add(MarksDB.GetPupilSubjectMark(pupil.Pupil_ID, subjects[i].Subject_ID)); } new ElectronicJournnal.Models.GeneratePupilMarksReport().CreatePackage(@"E:\Uni\Course Project\ElectronicJournnal\ElectronicJournnal\Files\CurrentPupilMarksReport.docx", pupil, subjects, marks); string file_path = Server.MapPath("~/Files/CurrentPupilMarksReport.docx");; string file_type = "application/docx"; string file_name = "Оценки " + pupil.Surname + " " + pupil.Name + ".docx"; return(File(file_path, file_type, file_name)); }
public ActionResult SelectAbsentPupils(int lessonID) { LessonFullInf lesson = LessonsDB.GetLessonFullInf(lessonID); List <Pupil> pupils = PupilsDB.GetPupilsInClass(lesson.Class_ID); TeacherController.classID = lesson.Class_ID; ViewBag.Pupils = pupils; ViewData["Lesson"] = lesson.Lesson_ID; // список ID учеников, которые были ранее отмечены как отсутствующие на данном уроке List <int> previosAbsent = LessonsDB.GetAbsentPupils(lessonID); ViewBag.AbsentPupils = previosAbsent; // удаляем всех отсутствующих отмеченных ранее MarksDB.DeleteAbsentPupilsMark(lessonID); return(View()); }
public ActionResult ViewPupilMarks(int pupilID) { PupilFullInformation pupil = PupilsDB.GetPupilsFullInformation(pupilID); ViewBag.Pupil = pupil; ViewData["CurrentPupil"] = pupil.Pupil_ID; List <Subject> subjects = SubjectsDB.GetPupilSubjects(pupil.Pupil_ID); ViewBag.Subjects = subjects; List <List <Mark> > marks = new List <List <Mark> >(); for (int i = 0; i < subjects.Count; i++) { marks.Add(MarksDB.GetPupilSubjectMark(pupil.Pupil_ID, subjects[i].Subject_ID)); } ViewBag.Marks = marks; return(View()); }
public ActionResult ViewMarkAbsentInfo(int markID) { MarkAbsentFullInf mark = MarksDB.GetMarkAbsentFullInf(markID); return(View(mark)); }
public ActionResult ViewMarkInfo(int markID) { MarkFullInf m = MarksDB.GetMarkFullInf(markID); return(View(m)); }
public ActionResult MailMerge(string send, List <int> Mail) { StringBuilder result = new StringBuilder(); try { List <Parenthood> parenthoods = new List <Parenthood>(); if (Mail == null) { parenthoods = ParentsDB.GetParenthoods(); } else { List <Pupil> pupils = new List <Pupil>(); foreach (int c in Mail) { foreach (Pupil p in PupilsDB.GetPupilsInClass(c)) { pupils.Add(p); } } foreach (Pupil p in pupils) { foreach (Parenthood parenthood in ParentsDB.GetPupilParenthoods(p.Pupil_ID)) { parenthoods.Add(parenthood); } } } foreach (Parenthood p in parenthoods) { StringBuilder message = new StringBuilder(); PupilFullInformation pupil = PupilsDB.GetPupilsFullInformation(p.Pupil_ID); Parent parent = ParentsDB.GetParentInfo(p.Parent_ID); ClassWithManagment c = ClassesDB.GetClassFullInf(ClassesDB.GetClassId(pupil.Class)); TeacherFullInformation classManager = TeachersDB.GetTeacherFullInformation(c.Teacher_ID); List <Subject> subjects = SubjectsDB.GetPupilSubjects(p.Pupil_ID); List <List <Mark> > marks = new List <List <Mark> >(); for (int i = 0; i < subjects.Count; i++) { marks.Add(MarksDB.GetPupilSubjectMark(pupil.Pupil_ID, subjects[i].Subject_ID)); } if (DateTime.Now.Hour < 10) { message.AppendLine($"<p>Доброе утро, {parent.Name} {parent.Patronymic}!</p>"); } else if (DateTime.Now.Hour >= 10 && DateTime.Now.Hour <= 17) { message.AppendLine($"<p>Добрый день, {parent.Name} {parent.Patronymic}!</p>"); } else { message.AppendLine($"<p>Добрый вечер, {parent.Name} {parent.Patronymic}!</p>"); } if (marks.Count != 0) { message.AppendLine($"<p>Высылаем вам отчет об успеваемости, так как вы подписаны на рассылку.</p>"); message.AppendLine("<p>.</p>"); message.AppendLine($"<p><b>Ученик(ица)</b>: {pupil.Surname} {pupil.Name} {pupil.Patronymic}.</p>"); message.AppendLine($"<p><b>Класс</b>: {pupil.Class}.</p>"); DateTime from = LessonsDB.GetClassFirstLesson(ClassesDB.GetClassId(pupil.Class)); message.AppendLine($"<p><b>Оценки с {from.ToLongDateString()} по {DateTime.Now.ToLongDateString()}: </b></p>"); for (int i = 0; i < subjects.Count; i++) { message.Append("<p>" + subjects[i].Subject_Name + ": "); foreach (Mark mark in marks[i]) { if (mark.PupilMark != null) { message.Append($"{mark.PupilMark.ToString()} "); } else { message.Append("н "); } } message.Append("</p>"); message.AppendLine(); } message.AppendLine($"<p><b>Количество пропусков</b>: {PupilsDB.GetPupilAbsentCount(pupil.Pupil_ID)}.</p>"); List <KeyValuePair <string, double> > weakSubjects = PupilsDB.GetPupilWeakSubjects(pupil.Pupil_ID); List <KeyValuePair <string, double> > strongSubjects = PupilsDB.GetPupilStrongSubjects(pupil.Pupil_ID); if (weakSubjects.Count != 0) { message.AppendLine("<p><b>Слабые предметы</b>: </p>"); foreach (var subject in weakSubjects) { message.AppendLine($"<p>{subject.Key} (средний балл - {subject.Value.ToString()})</p>"); } message.AppendLine("Если вы хотите связаться с учителями по проблемным предметам ученика(ицы), то вы можете написать им по следующим <b>электронным адрессам</b>:"); foreach (var subject in weakSubjects) { int teacherID = SubjectsDB.GetSubjectTeacher(ClassesDB.GetClassId(pupil.Class), subject.Key); TeacherFullInformation teacher = TeachersDB.GetTeacherFullInformation(teacherID); message.AppendLine($"<p>{subject.Key}: {teacher.Surname} {teacher.Name} {teacher.Patronymic }. Почта: {teacher.Email}</p>"); } } else { message.AppendLine("У данного ученика(ицы) нет слабых предметов. Успеваемость на хорошем уровне."); } if (strongSubjects.Count != 0) { message.AppendLine("<p><b>Сильные предметы</b>: </p>"); foreach (var subject in strongSubjects) { message.AppendLine($"<p>{subject.Key} (средний балл - {subject.Value.ToString()})</p>"); } message.AppendLine("<p>(По данным предметам рекомендуется посетить олимпиады или турниры. Для более подробной информации необходимо связаться с классным руководителем.)</p>"); message.AppendLine($"<p><b>Классный руководитель: </b>{classManager.Surname} {classManager.Name} {classManager.Patronymic }. Почта: {classManager.Email}</p>"); } else { message.AppendLine("<p>У данного ученика нет сильных предметов.</p>"); } DateTime currentDate = DateTime.Now; int currentMonth = currentDate.Month; int Year = currentDate.Year; int allDayCurrentMonth = DateTime.DaysInMonth(Year, currentMonth); DateTime currentBegin = new DateTime(Year, currentMonth, 1); DateTime currentEnd = currentBegin.AddMonths(1).AddDays(-1); int previousMonth = currentMonth - 1; int allDayPreviousMonth = DateTime.DaysInMonth(Year, previousMonth); DateTime previousBegin = new DateTime(Year, previousMonth, 1); DateTime previousEnd = previousBegin.AddMonths(1).AddDays(-1); double previousMonthAvgMark = PupilsDB.GetPupilsAvgMarkInMonth(pupil.Pupil_ID, previousBegin, previousEnd); double currentMonthAvgMark = PupilsDB.GetPupilsAvgMarkInMonth(pupil.Pupil_ID, currentBegin, currentEnd); int change = Convert.ToInt32(((currentMonthAvgMark - previousMonthAvgMark) / previousMonthAvgMark) * 100); message.AppendLine("<p><b>Анализ успеваемости:</b></p>"); if (change >= 0) { message.AppendLine($"<p>По сравнению с прошлым месяцем успеваесмость выросла на {change}%. Продолжайте в том же духе!</p>"); } else { message.AppendLine($"<p>По сравнению с прошлым месяцем успеваесмость упала на {change}%. Стоит больше внимания уделить учебе!</p>"); } for (int i = 0; i < subjects.Count; i++) { message.Append("<p> Предположительная оценка в семестре по " + subjects[i].Subject_Name + ": " + Convert.ToUInt32(PupilsDB.GetPupilsSubjectAvgMark(pupil.Pupil_ID, subjects[i].Subject_ID)) + " "); message.Append("</p>"); message.AppendLine(); } } else { message.AppendLine("<p>.</p>"); message.AppendLine("<p>У данного ученика(ицы) нет оценок, поэтому мы не можем сформировать отчет. Возможно, Вам стоит связаться с классным руководителем по электронной почте.</p>"); message.AppendLine($"<p><b>Классный руководитель: </b>{classManager.Surname} {classManager.Name} {classManager.Patronymic }. Почта: {classManager.Email}</p>"); } message.AppendLine("<p>.</p>"); message.AppendLine("<p>С уважением, администрация школы!</p>"); EmailService emailService = new EmailService(); emailService.SendEmailAsync(parent.Email, $"Отчет об успеваемости {pupil.Surname} {pupil.Name[0]}. {pupil.Patronymic[0]}.", message.ToString()); } result.AppendLine("Рассылка прошла успешно!"); } catch { result.AppendLine("<h3> К сожалению, при рассылке проиошла ошибка. Возможно, отсутствует подключение к интернету. Попробуйте позжу! </h3>"); } ViewBag.Message = result.ToString(); return(View("~/Views/Some/Result.cshtml")); }