Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmContactEditor: Check if there is values in certain text boxes
[xestiaab/.git] / source / contacteditor / frmContactEditor-Save.cpp
index f00c739..baeeae5 100644 (file)
@@ -50,6 +50,19 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
         
        }
     
+       // 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;
@@ -345,7 +358,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
                        FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
                 
                }
-            
+        
                if (AnniversaryYear == 0){
                 
                        FinalAnniversaryYear = wxT("--");
@@ -534,23 +547,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event )
        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);
-    
 }
 
 void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy