private void AddOrUpdate(StaffDetail item) { var saveItem = _id == "" ? _repo.AddStaff(item) : _repo.UpdateStaff(item); if (saveItem == string.Empty) { Base.ShowSuccess("Success", "Staff saved successfully"); this.Close(); } else { Base.ShowError("Failed", saveItem); } }
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 (comboPosition.Text == "") { MessageBox.Show("Please choose an position for this person before clicking save", "Position empty error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!_staffRepo.AddStaff(nameTextBox.Text, surnameTextBox.Text, dateOfBirthPicker.Value, (StaffPosition)Enum.Parse(typeof(StaffPosition), comboPosition.Text))) { MessageBox.Show("There's person is already a staff member", "Staff member exists error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } NewForm(); }