private void btnAddStaff_Click(object sender, EventArgs e) { if (txtFirstName.isEmptyOrHint()) { txtFirstName.Focus(); return; } if (txtLastName.isEmptyOrHint()) { txtLastName.Focus(); return; } if (txtAddress1.isEmptyOrHint()) { txtAddress1.Focus(); return; } if (txtAddress2.isEmptyOrHint()) { txtAddress2.Focus(); return; } if (txtCity.isEmptyOrHint()) { txtCity.Focus(); return; } if (txtCountry.isEmptyOrHint()) { txtCountry.Focus(); return; } if (txtPostalCode.isEmptyOrHint()) { txtPostalCode.Focus(); return; } if (txtPhoneNumber.isEmptyOrHint()) { txtPhoneNumber.Focus(); return; } if (txtQualification.isEmptyOrHint()) { txtQualification.Focus(); return; } Staff newStaff = new Staff() { FirstName = txtFirstName.Text.Trim(), LastName = txtLastName.Text.Trim(), Address1 = txtAddress1.Text.Trim(), Address2 = txtAddress2.Text.Trim(), City = txtCity.Text.Trim(), Country = txtCountry.Text.Trim(), PostalCode = txtPostalCode.Text.Trim(), PhoneNumber = txtPhoneNumber.Text.Trim(), Qualification = txtQualification.Text.Trim(), Password = txtPassword.Text.Trim(), Username = txtUsername.Text.Trim(), }; if (_isUpdate) { if (_updatedStaff == null) { MessageBox.Show("Error in system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } newStaff.Id = _updatedStaff.Id; int res = _sr.UpdateStaff(newStaff); if (res < 0) { MessageBox.Show("Error In Update!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ActionPerformed?.Invoke(newStaff, ActionType.Updated); Hide(); } } else { int res = _sr.AddStaffMember(newStaff); if (res < 0) { MessageBox.Show("Error In Adding New Staff!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { newStaff.Id = res; ActionPerformed?.Invoke(newStaff, ActionType.Added); Hide(); } } Clear(); }