public bool SetData()
        {
            if (_firstIteration)
            {
                foreach (var institution in _institutionRepo.GetAllInstitutions())
                {
                    institutionComboBox.Items.Add(institution.Name);
                }

                _firstIteration = false;
            }

            if (_memberRepo.GetAllMembers().Count == 0)
            {
                MessageBox.Show("No student or professor has been added yet", "Member not exists error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                nameTextBox.Text            = "";
                surnameTextBox.Text         = "";
                dateOfBirthPicker.Value     = DateTime.Now;
                institutionComboBox.Text    = "";
                isProfessorCheckBox.Checked = false;
                btnSave.Enabled             = false;
            }

            if (_memberRepo.GetAllMembers().Count <= _index || _index < 0)
            {
                return(false);
            }
            nameTextBox.Text            = _memberRepo.GetAllMembers()[_index].Person.Name;
            surnameTextBox.Text         = _memberRepo.GetAllMembers()[_index].Person.Surname;
            dateOfBirthPicker.Value     = _memberRepo.GetAllMembers()[_index].Person.DateOfBirth.Value;
            institutionComboBox.Text    = _memberRepo.GetAllMembers()[_index].Institution.Name;
            isProfessorCheckBox.Checked = _memberRepo.GetAllMembers()[_index].Professor;
            return(true);
        }
예제 #2
0
        private void NewForm()
        {
            dateOfBirthPicker.MaxDate = new DateTime(DateTime.Today.Year - 18, DateTime.Today.Month, DateTime.Today.Day);
            dateOfBirthPicker.Value   =
                new DateTime(DateTime.Today.Year - 18, DateTime.Today.Month, DateTime.Today.Day - 2);
            nameTextBox.Text    = "";
            surnameTextBox.Text = "";
            institutionComboBox.SelectedIndex = -1;
            isProfessorCheckBox.Checked       = false;
            if (!_firstIteration)
            {
                return;
            }
            var allInstitutions = _institutionRepo.GetAllInstitutions();

            if (allInstitutions.Count == 0)
            {
                MessageBox.Show("Please add Institutions before adding students and professors.",
                                "Institution not exists error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnSave.Enabled = false;
            }
            foreach (var institution in allInstitutions)
            {
                institutionComboBox.Items.Add(institution.Name);
            }

            _firstIteration = false;
        }
        public bool SetData()
        {
            if (_institutionRepo.GetAllInstitutions().Count == 0)
            {
                MessageBox.Show("No institution has been added yet", "Institution not exists error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                nameTextBox.Text    = "";
                addressTextBox.Text = "";
                btnSave.Enabled     = false;
            }

            if (_institutionRepo.GetAllInstitutions().Count <= _index || _index < 0)
            {
                return(false);
            }
            nameTextBox.Text    = _institutionRepo.GetAllInstitutions()[_index].Name;
            addressTextBox.Text = _institutionRepo.GetAllInstitutions()[_index].Address;
            return(true);
        }