Пример #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (
                LectorsFullname.Text.Length > 0 && LectorsDepartment.Text.Length > 0 &&
                LectorsAuditory.Text.Length > 0 && DisciplineName.Text.Length > 0 &&
                (ExamRadioBtn.Checked || OffsetRadioBtn.Checked) &&
                DisciplineCours.Text.Length > 0 && DisciplineSpeciality.Text.Length > 0 &&
                NumberOfLectures.Text.Length > 0 &&
                NumberOfLabratoryExercises.Text.Length > 0 &&
                (FirstSemestrRadioBtn.Checked || SecondSemestrRadioBtn.Checked) && LectorsAuditory.Text.Length == 5
                )
            {
                completenessFlag = true;
            }


            if (completenessFlag)
            {
                DisciplineFactory disFactory = new DisciplineFactory();

                LectorBuilder  lectorBuilder  = new LectorBuilder();
                LectorDirector lectorDirector = new LectorDirector(lectorBuilder);
                lectorDirector.makeStandartLector(LectorsFullname.Text, LectorsAuditory.Text, LectorsDepartment.Text);
                Lector lector = lectorBuilder.getLector();

                //Lector lector = disFactory.createLector(LectorsFullname.Text, LectorsAuditory.Text, LectorsDepartment.Text);
                Discipline discipline = disFactory.createDiscipline(DisciplineName.Text, DisciplineCours.Text, DisciplineSpeciality.Text, NumberOfLectures.Text, NumberOfLabratoryExercises.Text);
                foreach (RadioButton rb in SemestrPanel.Controls)
                {
                    if (rb.Checked)
                    {
                        discipline.semestr = rb.Text;
                    }
                }
                foreach (RadioButton rb in TypeOfControlPanel.Controls)
                {
                    if (rb.Checked)
                    {
                        discipline.typeOfControl = rb.Text;
                    }
                }

                Serialize(lector, discipline);
            }
            else
            {
                MessageBox.Show(
                    "Вы не заполнили все необходимые поля!",
                    "Сообщение об ошибке",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
        }