Пример #1
0
        private void OkButton_Click(object sender, EventArgs e)
        {
            discipline = new DisciplineInfo(
                NameDis.Text,
                int.Parse(Course.Text),
                int.Parse(FirstSemestr.Checked ? FirstSemestr.Text : SecondSemestr.Text),
                Spec.Text,
                Credit.Checked ? Credit.Text : Exam.Text,
                int.Parse(NumLec.Text),
                int.Parse(NumLab.Text)
                );

            var results = new List <ValidationResult>();
            var context = new ValidationContext(discipline);

            if (!Validator.TryValidateObject(discipline, context, results, true))
            {
                foreach (var error in results)
                {
                    DisciplineMessage.Text += error.ErrorMessage + "\r\n";
                }
            }
            else
            {
                actionForm.discplineList.Add(discipline);
                this.Hide();
                disLecturer.Show();
            }
        }
Пример #2
0
        private bool Validate(DisciplineInfo discipline)
        {
            var results = new List <ValidationResult>();
            var context = new ValidationContext(discipline);

            if (!Validator.TryValidateObject(discipline, context, results, true))
            {
                foreach (var error in results)
                {
                    DisciplineMessage.Text += error.ErrorMessage + "\r\n";
                }

                return(false);
            }

            return(true);
        }
Пример #3
0
 public void outDisciplineFields(int Lenth)
 {
     for (int j = 0; j < Lenth; j++)
     {
         DisciplineInfo el = discplineList[j];
         OutFindInf.Text += "Название дисциплины: " + el.name + "\r\n" +
                            "Специальность: " + el.specialty + "\r\n" +
                            "Курс: " + el.course + "\r\n" +
                            "Семестр: " + el.semester + "\r\n" +
                            "Тип контроля: " + el.controlType + "\r\n" +
                            "Количество лаб: " + el.numLab + "\r\n" +
                            "Количество лекций: " + el.numLectures + "\r\n" +
                            "Имя лектора: " + el.lecturer.nameLecturer + "\r\n" +
                            "Кафедра: " + el.lecturer.departament + "\r\n" +
                            "кабинет: " + el.lecturer.office + "\r\n" +
                            "-------------------------" + "\r\n";
     }
 }