Ejemplo n.º 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)
            {
                Lector     lector     = new Lector();
                Discipline discipline = new Discipline();
                lector.fullname           = LectorsFullname.Text;
                lector.department         = LectorsDepartment.Text;
                lector.auditory           = LectorsAuditory.Text;
                discipline.disciplineName = DisciplineName.Text;
                foreach (RadioButton rb in SemestrPanel.Controls)
                {
                    if (rb.Checked)
                    {
                        discipline.semestr = rb.Text;
                    }
                }
                discipline.cours                      = DisciplineCours.Text;
                discipline.speciality                 = DisciplineSpeciality.Text;
                discipline.numberOfLectures           = NumberOfLectures.Text;
                discipline.numberOfLabratoryExercises = NumberOfLabratoryExercises.Text;
                foreach (RadioButton rb in TypeOfControlPanel.Controls)
                {
                    if (rb.Checked)
                    {
                        discipline.typeOfControl = rb.Text;
                    }
                }

                Serialize(lector, discipline);
            }
            else
            {
                MessageBox.Show(
                    "Вы не заполнили все необходимые поля!",
                    "Сообщение об ошибке",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                    );
            }
        }
Ejemplo n.º 2
0
        public void Serialize(Lector lector, Discipline discipline)
        {
            DisciplineForSerialize        serializeMe = new DisciplineForSerialize(lector, discipline);
            List <DisciplineForSerialize> disciplinesForSerialize;

            if (File.Exists("data.xml"))
            {
                disciplinesForSerialize = Deserialize();
            }
            else
            {
                disciplinesForSerialize = new List <DisciplineForSerialize>();
            }
            disciplinesForSerialize.Add(serializeMe);
            XmlSerializer xmlf = new XmlSerializer(disciplinesForSerialize.GetType());

            using (FileStream fs = new FileStream("data.xml", FileMode.OpenOrCreate))
            {
                xmlf.Serialize(fs, disciplinesForSerialize);
            }
        }
Ejemplo n.º 3
0
 public DisciplineForSerialize(Lector lector, Discipline discipline)
 {
     Lector     = lector;
     Discipline = discipline;
 }