Ejemplo n.º 1
0
        private void ChangeDebtProfessor_Click(object sender, EventArgs e)
        {
            int index = infoListBox.SelectedIndex;

            if (institute.GetPerson(index) is Student)
            {
                Student student = (Student)institute.GetPerson(index);
                if (student.Debt != null)
                {
                    if (!System.Text.RegularExpressions.Regex.IsMatch(textBoxDebt.Text, Globals.lastNamePattern))
                    {
                        MessageBox.Show("Неверный формат фамилии", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBoxDebt.Clear();
                    }
                    else
                    {
                        string DebtProfessor = textBoxDebt.Text;

                        bool      match     = false;
                        int       i         = 0;
                        Professor professor = null;
                        while (i <= institute.Count - 1 && !match)
                        {
                            if (institute.GetPerson(i) is Professor)
                            {
                                professor = (Professor)institute.GetPerson(i);
                                if (professor.LastName == DebtProfessor && professor.Subject == student.Debt)
                                {
                                    match = true;
                                }
                            }
                            i++;
                        }
                        if (match)
                        {
                            if (professor.Subject == student.Debt)
                            {
                                student.DebtProfessor = DebtProfessor;
                                ShowAllPersons();
                                textBoxDebt.Clear();
                            }
                            else
                            {
                                MessageBox.Show("Нет преподавателя с такой фамилией по такому предмету", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Нет преподавателя с такой фамилией", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            textBoxDebt.Clear();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("У данного студента нет долгов", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Выбранный человек не является студентом", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 2
0
        private void Setprofessor_Click(object sender, EventArgs e)
        {
            bool match, match_total = false, unmatch_total = false;
            bool v1 = false, v2 = false, v3 = false;

            if (institute.Count == 0)
            {
                MessageBox.Show("В институте нет преподавателей и студентов", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                for (int index = 0; index <= institute.Count - 1; index++)
                {
                    match = false;
                    if (institute.GetPerson(index) is Student)
                    {
                        v1 = true;
                        Student student = (Student)institute.GetPerson(index);
                        if (student.Debt != null)
                        {
                            v2 = true;
                            if (student.DebtProfessor == null)
                            {
                                v3 = true;
                                string debt = student.Debt;

                                int       i         = 0;
                                Professor professor = null;
                                while (i <= institute.Count - 1 && !match)
                                {
                                    if (institute.GetPerson(i) is Professor)
                                    {
                                        professor = (Professor)institute.GetPerson(i);
                                        if (professor.Subject == debt)
                                        {
                                            match       = true;
                                            match_total = true;
                                        }
                                    }
                                    i++;
                                }

                                if (match)
                                {
                                    student.DebtProfessor = professor.LastName;
                                    ShowAllPersons();
                                }
                                else
                                {
                                    unmatch_total = true;
                                    MessageBox.Show("Нет преподавателя по предмету \"" + debt + "\"" + ", по которому задолженность у студента - "
                                                    + student.LastName, "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    textBoxDebt.Clear();
                                }
                            }
                        }
                    }
                }
                if (!v1)
                {
                    MessageBox.Show("В институте нет студентов", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (v1 && !v2)
                {
                    MessageBox.Show("В институте нет студентов с долгами", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (v2 && !v3)
                {
                    MessageBox.Show("В институте нет студентов-должников, у которых не назначены преподаватели на пересдачу", "",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (v1 && v2 && v3 && match_total && !unmatch_total)
                {
                    MessageBox.Show("Преподаватели на пересдачу успешно назначены", "",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                if (v1 && v2 && v3 && match_total && unmatch_total)
                {
                    MessageBox.Show("Преподаватели на пересдачу успешно назначены" +
                                    " \nтем студентам, для которых по их предметам с задолженностями удалось найти преподавателей с таким же предметом ", "",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Ejemplo n.º 3
0
 internal void Add(Professor professor, string text)
 {
     throw new NotImplementedException();
 }