Esempio n. 1
0
 public Дисциплина()
 {
     InitializeComponent();
     lector                  = new Lector();
     discipline              = new Discipline(lector);
     _xmlSerializer          = new XmlSerializer <List <Discipline> >("data.xml");
     comboBox1.SelectedIndex = 0;
 }
Esempio n. 2
0
 public Дисциплина()
 {
     InitializeComponent();
     lector                  = new Lector();
     discipline              = new Discipline(lector);
     _jsonSerializer         = new JsonSerializer <Discipline>("data.json");
     comboBox1.SelectedIndex = 0;
 }
Esempio n. 3
0
        private bool Validate(Lector model)
        {
            var results = new List <ValidationResult>();
            var context = new ValidationContext(model);

            if (!Validator.TryValidateObject(model, context, results, true))
            {
                string strWithErrroe = "";
                foreach (var error in results)
                {
                    strWithErrroe += $"{error.ErrorMessage}\n";
                }
                MessageBox.Show(strWithErrroe);
            }

            return(!results.Any());
        }
Esempio n. 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            var model = new Lector();

            model.Name       = textBox1.Text;
            model.Surname    = textBox2.Text;
            model.Patronomyc = textBox3.Text;
            model.Department = comboBox1.SelectedItem.ToString();
            model.Auditory   = textBox4.Text;
            model.Number     = maskedTextBox1.Text;

            if (!Validate(model))
            {
                return;
            }

            Lector.Name       = model.Name;
            Lector.Surname    = model.Surname;
            Lector.Patronomyc = model.Patronomyc;
            Lector.Department = model.Department;
            Lector.Auditory   = model.Auditory;
            Lector.Number     = model.Number;
            this.Close();
        }
Esempio n. 5
0
 public Discipline(Lector lect) : this()
 {
     lector = lect;
 }
Esempio n. 6
0
        private void AddSubject_button_Click(object sender, EventArgs e)
        {
            try
            {
                if (Name_textBox.Text == "")
                {
                    throw new Exception("Empty fields");
                }
                else
                {
                    foreach (var item in subjects)
                    {
                        if (item.Name == Name_textBox.Text)
                        {
                            throw new Exception("Name with this value already exists");
                        }
                    }

                    #region Write and validatie oobjects

                    var lecturer = new Lector()
                    {
                        Initials   = LectorInicials_textBox.Text,
                        Birthday   = Birthday_dateTimePicker.Value,
                        Experience = Convert.ToInt32(Experience_numericUpDown.Value),
                        Phone      = PhoneNumber_maskedTextBox.Text
                    };



                    var subject = new Subject
                    {
                        Name             = Name_textBox.Text,
                        Year             = Convert.ToInt32(Year_numericUpDown.Value),
                        Semester         = Convert.ToInt32(Semester_numericUpDown.Value),
                        Specialty        = Subject.AddSpeciality(Specialty_textBox.Text),
                        NumberOfLectures = NumberOfLabs_trackBar.Value,
                        NumberOfLabs     = NumberOfLabs_trackBar.Value,
                        Control          = Exam_radioButton.Checked ? Subject.ControlType.Exam : Subject.ControlType.Credit,
                        Lecturer         = lecturer
                    };

                    #endregion

                    if (checkValidationObject(lecturer) && checkValidationObject(subject))
                    {
                        subjects.Add(subject);

                        listViewOutput.Items.Clear();

                        ShowSubjectCollection(subjects);

                        if (!SaveToXML_button.Enabled)
                        {
                            SaveToXML_button.Enabled = true;
                        }

                        GlobalEventTracker("Добавлен элемент в коллекцию", subjects);
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message, "Error!");
            }
        }
Esempio n. 7
0
 public Discipline(Lector lect)
 {
     lector    = lect;
     Specialty = new List <string>();
 }