示例#1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (EmptyChecker.TryTextFieldsEmpty(Controls))
     {
         MessageBox.Show("Please make sure you enter a value for all text fields", "Value empty error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     TextBoxParser.TextBoxChecker(Controls);
     if (institutionComboBox.Text == "")
     {
         MessageBox.Show("Please pick an institution before trying to save", "Institution empty error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (!_memberRepo.AddMember(nameTextBox.Text, surnameTextBox.Text, dateOfBirthPicker.Value,
                                isProfessorCheckBox.Checked,
                                _institutionRepo.GetInstitutionByName(institutionComboBox.Text)))
     {
         MessageBox.Show("This person is already an member.", "Member exists error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     NewForm();
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (EmptyChecker.TryTextFieldsEmpty(Controls))
     {
         MessageBox.Show("Please make sure you enter a value for all text fields", "Value empty error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     TextBoxParser.TextBoxChecker(Controls);
     if (!_memberRepo.EditMember(_memberRepo.GetAllMembers()[_index].MemberId, nameTextBox.Text,
                                 surnameTextBox.Text,
                                 dateOfBirthPicker.Value, isProfessorCheckBox.Checked,
                                 _institutionRepo.GetInstitutionByName(institutionComboBox.Text)))
     {
         MessageBox.Show("This person is already an member", "Member exists error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
         return;
     }
     SetData();
 }