if (boolUnsupportedAccount == true){
- wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR);
+ wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR);
+ saveSuccess = false;
return;
}
if (cmbDisplayAsValue.IsEmpty()){
wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
+ saveSuccess = false;
return;
}
+ // Check if a value has been entered either in the Title,
+ // Forename, Surname, Other Names and Suffix text boxes.
+
+ if (txtTitle->IsEmpty() && txtForename->IsEmpty() && txtSurname->IsEmpty()
+ && txtOtherNames->IsEmpty() && txtSuffix->IsEmpty())
+ {
+
+ wxMessageBox(_("A value must be as minimum eithered in either the Title, Forename, Surname, Other Names or Suffix text boxes."), _("No name information entered"), wxICON_ERROR);
+ saveSuccess = false;
+ return;
+
+ }
+
// Save the updated contact data.
//vCard ContactData;
NameData.Title = txtTitle->GetValue();
NameData.Suffix = txtSuffix->GetValue();
- ucd->ContactAccount = wxSContactAccount;
- ucd->ContactFilename = FilenameFinal;
- ucd->ContactName = cmbDisplayAs->GetValue();
- ucd->ContactNameArray = NameData;
+ if (this->GetParent() != nullptr)
+ {
+ ucd->ContactAccount = wxSContactAccount;
+ ucd->ContactFilename = FilenameFinal;
+ ucd->ContactName = cmbDisplayAs->GetValue();
+ ucd->ContactNameArray = NameData;
- for (std::map<int,wxString>::iterator gniter = ContactEditorData.GeneralNicknamesList.begin();
- gniter != ContactEditorData.GeneralNicknamesList.end(); gniter++){
+ for (std::map<int,wxString>::iterator gniter = ContactEditorData.GeneralNicknamesList.begin();
+ gniter != ContactEditorData.GeneralNicknamesList.end(); gniter++){
- ucd->ContactNickname = gniter->second;
- break;
+ ucd->ContactNickname = gniter->second;
+ break;
+ }
+
+ wxCommandEvent event2(CE_UPDATECONTACTLIST);
+ event2.SetClientData(ucd);
+ wxPostEvent(MainPtr, event2);
}
-
- wxCommandEvent event2(CE_UPDATECONTACTLIST);
- event2.SetClientData(ucd);
- wxPostEvent(MainPtr, event2);
+
+ saveSuccess = true;
}
wxCommandEvent NullEvent;
this->SaveContact(NullEvent);
- this->Close();
+ if (saveSuccess)
+ {
+ this->Close();
+ }
}
\ No newline at end of file