Ejemplo n.º 1
0
        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 }));
        }
Ejemplo n.º 2
0
        // Редактирование информации про ученика.
        public ActionResult EditPupilInformation(int action)
        {
            PupilFullInformation p           = PupilsDB.GetPupilsFullInformation(action);
            List <Class>         classesList = ClassesDB.GetClassesWithoutCurr(p.Class);
            SelectList           classesSL   = new SelectList(classesList, "Class_ID", "Class_Name");

            ViewBag.Classes = classesSL;
            return(View(p));
        }
Ejemplo n.º 3
0
        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 }));
        }
Ejemplo n.º 4
0
        public FileResult GetPupilReport(int action)
        {
            PupilFullInformation p = PupilsDB.GetPupilsFullInformation(action);
            string age             = p.Age.ToString() + " лет";

            new Models.GeneratedCode.GenerateReport().CreatePackage(@"E:\Uni\Course Project\ElectronicJournnal\ElectronicJournnal\Files\CurrentPupilReport.docx", p.Name, p.Surname, p.Patronymic, p.Class, p.Date_Of_Birth.ToLongDateString(), age, p.Parent_Phone_Number, p.Pupil_Phone_Number, p.Address);
            string file_path = Server.MapPath("~/Files/CurrentPupilReport.docx");;
            string file_type = "application/docx";
            string name      = "Анкета " + p.Surname + " " + p.Name + ".docx";
            string file_name = name;

            return(File(file_path, file_type, file_name));
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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());
        }
Ejemplo n.º 7
0
        public ActionResult PupilFullInf(int id)
        {
            PupilFullInformation p = PupilsDB.GetPupilsFullInformation(id);

            return(View(p));
        }
Ejemplo n.º 8
0
        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"));
        }