+ wxString widgetName;
+
+ widgetName = win.GetName();
+
+ if (!widgetPtrsSet)
+ return;
+
+ if (widgetName == pCreateBtn->GetName())
+ {
+ wxGetApp().Contact->Initialize();
+ PutData();
+ SetMode( mCreate );
+ pNameTxt->SetValue(wxT(""));
+ pNameTxt->SetFocus();
+ return;
+ }
+
+ if (widgetName == pEditBtn->GetName())
+ {
+ saveName = wxGetApp().Contact->Name;
+ SetMode( mEdit );
+ pNameTxt->SetFocus();
+ return;
+ }
+
+ if (widgetName == pCopyBtn->GetName())
+ {
+ SetMode(mCreate);
+ pNameTxt->SetValue(wxT(""));
+ pNameTxt->SetFocus();
+ return;
+ }
+
+ if (widgetName == pDeleteBtn->GetName())
+ {
+ bool Ok = (wxMessageBox(wxT("Are you sure?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES);
+
+ if (!Ok)
+ return;
+
+ if (Ok && wxGetApp().Contact->Delete())
+ {
+ // NOTE: Deletions are not finalized until a CommitTrans() is performed.
+ // If the commit were not performed, the program will continue to
+ // show the table contents as if they were deleted until this instance
+ // of Ccontact is deleted. If the Commit wasn't performed, the
+ // database will automatically Rollback the changes when the database
+ // connection is terminated
+ wxGetApp().Contact->GetDb()->CommitTrans();
+
+ // Try to get the row that followed the just deleted row in the orderBy sequence
+ if (!GetNextRec())
+ {
+ // There was now row (in sequence) after the just deleted row, so get the
+ // row which preceded the just deleted row
+ if (!GetPrevRec())
+ {
+ // There are now no rows remaining, so clear the dialog widgets
+ wxGetApp().Contact->Initialize();
+ PutData();
+ }
+ }
+ SetMode(mode); // force reset of button enable/disable
+ }
+ else
+ // Delete failed
+ wxGetApp().Contact->GetDb()->RollbackTrans();
+
+ SetMode(mView);
+ return;
+ }
+
+ if (widgetName == pSaveBtn->GetName())
+ {
+ Save();
+ return;
+ }
+
+ if (widgetName == pCancelBtn->GetName())
+ {
+ bool Ok = (wxMessageBox(wxT("Are you sure?"),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES);
+
+ if (!Ok)
+ return;
+
+ if (saveName.IsEmpty())
+ {
+ wxGetApp().Contact->Initialize();
+ PutData();
+ SetMode(mView);
+ return;
+ }
+ else
+ {
+ // Requery previous record
+ if (wxGetApp().Contact->FetchByName(saveName))
+ {
+ PutData();
+ SetMode(mView);
+ return;
+ }
+ }
+
+ // Previous record not available, retrieve first record in table
+ if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES &&
+ wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL)
+ {
+ wxGetApp().Contact->whereStr = wxT("NAME = (SELECT MIN(NAME) FROM ");
+ wxGetApp().Contact->whereStr += wxGetApp().Contact->GetTableName();
+ wxGetApp().Contact->whereStr += wxT(")");
+ wxGetApp().Contact->SetWhereClause(wxGetApp().Contact->whereStr.c_str());
+ }
+ else
+ wxGetApp().Contact->SetWhereClause(wxT(""));
+
+ if (!wxGetApp().Contact->Query())
+ {
+ wxString tStr;
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
+ SetMode(mView);
+ return;
+ }
+ if (wxGetApp().Contact->GetNext()) // Successfully read first record
+ {
+ PutData();
+ SetMode(mView);
+ return;
+ }
+ // No contacts are available, clear dialog
+ wxGetApp().Contact->Initialize();
+ PutData();
+ SetMode(mView);
+ return;
+ } // Cancel Button
+
+ if (widgetName == pPrevBtn->GetName())
+ {
+ if (!GetPrevRec())
+ wxBell();
+ return;
+ } // Prev Button
+
+ if (widgetName == pNextBtn->GetName())
+ {
+ if (!GetNextRec())
+ wxBell();
+ return;
+ } // Next Button
+
+ if (widgetName == pQueryBtn->GetName())
+ {
+ // Display the query dialog box
+ wxChar qryWhere[DB_MAX_WHERE_CLAUSE_LEN+1];
+ wxStrcpy(qryWhere, (const wxChar*) wxGetApp().Contact->qryWhereStr);
+ wxChar *tblName[] = {(wxChar *)CONTACT_TABLE_NAME, 0};
+ new CqueryDlg(GetParent(), wxGetApp().Contact->GetDb(), tblName, qryWhere);
+
+ // Query the first record in the new record set and
+ // display it, if the query string has changed.
+ if (wxStrcmp(qryWhere, (const wxChar*) wxGetApp().Contact->qryWhereStr))
+ {
+ wxGetApp().Contact->whereStr.Empty();
+ wxGetApp().Contact->SetOrderByClause("NAME");
+
+ if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES &&
+ wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL)
+ {
+ wxGetApp().Contact->whereStr = wxT("NAME = (SELECT MIN(NAME) FROM ");
+ wxGetApp().Contact->whereStr += CONTACT_TABLE_NAME;
+ }
+
+ // Append the query where string (if there is one)
+ wxGetApp().Contact->qryWhereStr = qryWhere;
+ if (wxStrlen(qryWhere))
+ {
+ wxGetApp().Contact->whereStr += wxT(" WHERE ");
+ wxGetApp().Contact->whereStr += wxGetApp().Contact->qryWhereStr;
+ }
+ // Close the expression with a right paren
+ wxGetApp().Contact->whereStr += wxT(")");
+ // Requery the table
+ wxGetApp().Contact->SetWhereClause(wxGetApp().Contact->whereStr.c_str());
+ if (!wxGetApp().Contact->Query())
+ {
+ wxString tStr;
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+
+ return;
+ }
+ // Display the first record from the query set
+ if (!wxGetApp().Contact->GetNext())
+ wxGetApp().Contact->Initialize();
+ PutData();
+ }
+
+ // Enable/Disable the reset button
+ pResetBtn->Enable(!wxGetApp().Contact->qryWhereStr.IsEmpty());
+
+ return;
+ } // Query button
+
+
+ if (widgetName == pResetBtn->GetName())
+ {
+ // Clear the additional where criteria established by the query feature
+ wxGetApp().Contact->qryWhereStr = wxT("");
+ wxGetApp().Contact->SetOrderByClause(wxT("NAME"));
+
+ if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES &&
+ wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL)
+ {
+ wxGetApp().Contact->whereStr = wxT("NAME = (SELECT MIN(NAME) FROM ");
+ wxGetApp().Contact->whereStr += CONTACT_TABLE_NAME;
+ wxGetApp().Contact->whereStr += wxT(")");
+ }
+
+ wxGetApp().Contact->SetWhereClause(wxGetApp().Contact->whereStr.c_str());
+ if (!wxGetApp().Contact->Query())
+ {
+ wxString tStr;
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ return;
+ }
+ if (!wxGetApp().Contact->GetNext())
+ wxGetApp().Contact->Initialize();
+ PutData();
+ pResetBtn->Enable(FALSE);
+
+ return;
+ } // Reset button
+
+
+ if (widgetName == pNameListBtn->GetName())
+ {
+ new ClookUpDlg(/* wxWindow *parent */ this,
+ /* wxChar *windowTitle */ wxT("Select contact name"),
+ /* wxChar *tableName */ (wxChar *) CONTACT_TABLE_NAME,
+ /* wxChar *dispCol1 */ wxT("NAME"),
+ /* wxChar *dispCol2 */ wxT("JOINDATE"),
+ /* wxChar *where */ wxT(""),
+ /* wxChar *orderBy */ wxT("NAME"),
+ /* wxDb *pDb */ wxGetApp().READONLY_DB,
+ /* const wxString &defDir */ wxGetApp().DbConnectInf->GetDefaultDir(),
+ /* bool distinctValues */ TRUE);
+
+ if (ListDB_Selection && wxStrlen(ListDB_Selection))
+ {
+ wxString w = wxT("NAME = '");
+ w += ListDB_Selection;
+ w += wxT("'");
+ GetRec(w);
+ }
+
+ return;
+ }
+
+ if (widgetName == pDataTypesBtn->GetName())
+ {
+ CheckSupportForAllDataTypes(wxGetApp().READONLY_DB);
+ wxMessageBox("Support datatypes was dumped to stdout.");
+ return;
+ } // Data types Button
+
+ if (widgetName == pDbDiagsBtn->GetName())
+ {
+ DisplayDbDiagnostics(wxGetApp().READONLY_DB);
+ wxMessageBox("Diagnostics info was dumped to stdout.");
+ return;
+ }
+
+ if (widgetName == pCatalogBtn->GetName())
+ {
+ if (wxGetApp().Contact->GetDb()->Catalog("","catalog.txt"))
+ wxMessageBox("The file 'catalog.txt' was created.");
+ else
+ wxMessageBox("Creation of the file 'catalog.txt' was failed.");
+ return;
+ }
+
+} // CeditorDlg::OnCommand()
+
+
+bool CeditorDlg::Initialize()
+{
+ // Create the data structure and a new database connection.
+ // (As there is not a pDb being passed in the constructor, a new database
+ // connection is created)
+ wxGetApp().Contact = new Ccontact();
+
+ if (!wxGetApp().Contact)
+ {
+ wxMessageBox(wxT("Unable to instantiate an instance of Ccontact"),wxT("Error..."),wxOK | wxICON_EXCLAMATION);
+ return FALSE;
+ }
+
+ // Check if the table exists or not. If it doesn't, ask the user if they want to
+ // create the table. Continue trying to create the table until it exists, or user aborts
+ while (!wxGetApp().Contact->GetDb()->TableExists((wxChar *)CONTACT_TABLE_NAME,
+ wxGetApp().DbConnectInf->GetUserID(),
+ wxGetApp().DbConnectInf->GetDefaultDir()))
+ {
+ wxString tStr;
+ tStr.Printf(wxT("Unable to open the table '%s'. The table may\nneed to be created.\n\nDo you wish to try to create/clear the table?\n\n"),CONTACT_TABLE_NAME);
+ bool createTable = (wxMessageBox(tStr.c_str(),wxT("Confirm"),wxYES_NO|wxICON_QUESTION) == wxYES);
+
+ if (!createTable)
+ {
+// Close();
+ return FALSE;
+ }
+ else
+ wxGetApp().CreateDataTable(FALSE);
+ }
+
+ // Tables must be "opened" before anything other than creating/deleting table can be done
+ if (!wxGetApp().Contact->Open())
+ {
+ // Table does exist, or there was some problem opening it. Currently this should
+ // never fail, except in the case of the table not exisiting or the current
+ // user has insufficent privileges to access the table
+#if 1
+// This code is experimenting with a new function that will hopefully be available
+// in the 2.4 release. This check will determine whether the open failing was due
+// to the table not existing, or the users privileges being insufficient to
+// open the table.
+ if (!wxGetApp().Contact->GetDb()->TablePrivileges(CONTACT_TABLE_NAME, wxT("SELECT"),
+ wxGetApp().Contact->GetDb()->GetUsername(),
+ wxGetApp().Contact->GetDb()->GetUsername(),
+ wxGetApp().DbConnectInf->GetDefaultDir()))
+ {
+ wxString tStr;
+ tStr.Printf(wxT("Unable to open the table '%s' (likely due to\ninsufficient privileges of the logged in user).\n\n"),CONTACT_TABLE_NAME);
+
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ }
+ else
+#endif
+ if (!wxGetApp().Contact->GetDb()->TableExists(CONTACT_TABLE_NAME,
+ wxGetApp().Contact->GetDb()->GetUsername(),
+ wxGetApp().DbConnectInf->GetDefaultDir()))
+ {
+ wxString tStr;
+ tStr.Printf(wxT("Unable to open the table '%s' as the table\ndoes not appear to exist in the tablespace available\nto the currently logged in user.\n\n"),CONTACT_TABLE_NAME);
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ }
+
+ return FALSE;
+ }
+
+ // Build the dialog
+
+ (void)new wxStaticBox(this, EDITOR_DIALOG_FN_GROUP, wxT(""), wxPoint(15, 1), wxSize(497, 69), 0, wxT("FunctionGrp"));
+ (void)new wxStaticBox(this, EDITOR_DIALOG_SEARCH_GROUP, wxT(""), wxPoint(417, 1), wxSize(95, 242), 0, wxT("SearchGrp"));
+
+ pCreateBtn = new wxButton(this, EDITOR_DIALOG_CREATE, wxT("&Create"), wxPoint( 25, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CreateBtn"));
+ pEditBtn = new wxButton(this, EDITOR_DIALOG_EDIT, wxT("&Edit"), wxPoint(102, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("EditBtn"));
+ pDeleteBtn = new wxButton(this, EDITOR_DIALOG_DELETE, wxT("&Delete"), wxPoint(179, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DeleteBtn"));
+ pCopyBtn = new wxButton(this, EDITOR_DIALOG_COPY, wxT("Cop&y"), wxPoint(256, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CopyBtn"));
+ pSaveBtn = new wxButton(this, EDITOR_DIALOG_SAVE, wxT("&Save"), wxPoint(333, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("SaveBtn"));
+ pCancelBtn = new wxButton(this, EDITOR_DIALOG_CANCEL, wxT("C&ancel"), wxPoint(430, 21), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CancelBtn"));
+ pPrevBtn = new wxButton(this, EDITOR_DIALOG_PREV, wxT("<< &Prev"), wxPoint(430, 81), wxSize( 70, 35), 0, wxDefaultValidator, wxT("PrevBtn"));
+ pNextBtn = new wxButton(this, EDITOR_DIALOG_NEXT, wxT("&Next >>"), wxPoint(430, 121), wxSize( 70, 35), 0, wxDefaultValidator, wxT("NextBtn"));
+ pQueryBtn = new wxButton(this, EDITOR_DIALOG_QUERY, wxT("&Query"), wxPoint(430, 161), wxSize( 70, 35), 0, wxDefaultValidator, wxT("QueryBtn"));
+ pResetBtn = new wxButton(this, EDITOR_DIALOG_RESET, wxT("&Reset"), wxPoint(430, 200), wxSize( 70, 35), 0, wxDefaultValidator, wxT("ResetBtn"));
+ pNameMsg = new wxStaticText(this, EDITOR_DIALOG_NAME_MSG, wxT("Name:"), wxPoint( 17, 80), wxSize( -1, -1), 0, wxT("NameMsg"));
+ pNameTxt = new wxTextCtrl(this, EDITOR_DIALOG_NAME_TEXT, wxT(""), wxPoint( 17, 97), wxSize(308, 25), 0, wxDefaultValidator, wxT("NameTxt"));
+ pNameListBtn = new wxButton(this, EDITOR_DIALOG_LOOKUP, wxT("&Lookup"), wxPoint(333, 97), wxSize( 70, 24), 0, wxDefaultValidator, wxT("LookupBtn"));
+ pAddress1Msg = new wxStaticText(this, EDITOR_DIALOG_ADDRESS1_MSG, wxT("Address:"), wxPoint( 17, 130), wxSize( -1, -1), 0, wxT("Address1Msg"));
+ pAddress1Txt = new wxTextCtrl(this, EDITOR_DIALOG_ADDRESS2_TEXT, wxT(""), wxPoint( 17, 147), wxSize(308, 25), 0, wxDefaultValidator, wxT("Address1Txt"));
+ pAddress2Msg = new wxStaticText(this, EDITOR_DIALOG_ADDRESS2_MSG, wxT("Address:"), wxPoint( 17, 180), wxSize( -1, -1), 0, wxT("Address2Msg"));
+ pAddress2Txt = new wxTextCtrl(this, EDITOR_DIALOG_ADDRESS2_TEXT, wxT(""), wxPoint( 17, 197), wxSize(308, 25), 0, wxDefaultValidator, wxT("Address2Txt"));
+ pCityMsg = new wxStaticText(this, EDITOR_DIALOG_CITY_MSG, wxT("City:"), wxPoint( 17, 230), wxSize( -1, -1), 0, wxT("CityMsg"));
+ pCityTxt = new wxTextCtrl(this, EDITOR_DIALOG_CITY_TEXT, wxT(""), wxPoint( 17, 247), wxSize(225, 25), 0, wxDefaultValidator, wxT("CityTxt"));
+ pStateMsg = new wxStaticText(this, EDITOR_DIALOG_STATE_MSG, wxT("State:"), wxPoint(250, 230), wxSize( -1, -1), 0, wxT("StateMsg"));
+ pStateTxt = new wxTextCtrl(this, EDITOR_DIALOG_STATE_TEXT, wxT(""), wxPoint(250, 247), wxSize(153, 25), 0, wxDefaultValidator, wxT("StateTxt"));
+ pCountryMsg = new wxStaticText(this, EDITOR_DIALOG_COUNTRY_MSG, wxT("Country:"), wxPoint( 17, 280), wxSize( -1, -1), 0, wxT("CountryMsg"));
+ pCountryTxt = new wxTextCtrl(this, EDITOR_DIALOG_COUNTRY_TEXT, wxT(""), wxPoint( 17, 297), wxSize(225, 25), 0, wxDefaultValidator, wxT("CountryTxt"));
+ pPostalCodeMsg = new wxStaticText(this, EDITOR_DIALOG_POSTAL_MSG, wxT("Postal Code:"),wxPoint(250, 280), wxSize( -1, -1), 0, wxT("PostalCodeMsg"));
+ pPostalCodeTxt = new wxTextCtrl(this, EDITOR_DIALOG_POSTAL_TEXT, wxT(""), wxPoint(250, 297), wxSize(153, 25), 0, wxDefaultValidator, wxT("PostalCodeTxt"));
+
+ wxString choice_strings[5];
+ choice_strings[0] = wxT("English");
+ choice_strings[1] = wxT("French");
+ choice_strings[2] = wxT("German");
+ choice_strings[3] = wxT("Spanish");
+ choice_strings[4] = wxT("Other");
+
+ pNativeLangChoice = new wxChoice(this, EDITOR_DIALOG_LANG_CHOICE, wxPoint( 17, 346), wxSize(277, -1), 5, choice_strings);
+ pNativeLangMsg = new wxStaticText(this, EDITOR_DIALOG_LANG_MSG, wxT("Native language:"), wxPoint( 17, 330), wxSize( -1, -1), 0, wxT("NativeLangMsg"));
+
+ wxString radio_strings[2];
+ radio_strings[0] = wxT("No");
+ radio_strings[1] = wxT("Yes");
+ pDeveloperRadio = new wxRadioBox(this,EDITOR_DIALOG_DEVELOPER, wxT("Developer:"), wxPoint(303, 330), wxSize( -1, -1), 2, radio_strings, 2, wxHORIZONTAL);
+ pJoinDateMsg = new wxStaticText(this, EDITOR_DIALOG_JOIN_MSG, wxT("Date joined:"), wxPoint( 17, 380), wxSize( -1, -1), 0, wxT("JoinDateMsg"));
+ pJoinDateTxt = new wxTextCtrl(this, EDITOR_DIALOG_JOIN_TEXT, wxT(""), wxPoint( 17, 397), wxSize(150, 25), 0, wxDefaultValidator, wxT("JoinDateTxt"));
+ pContribMsg = new wxStaticText(this, EDITOR_DIALOG_CONTRIB_MSG,wxT("Contributions:"), wxPoint(175, 380), wxSize( -1, -1), 0, wxT("ContribMsg"));
+ pContribTxt = new wxTextCtrl(this, EDITOR_DIALOG_CONTRIB_TEXT, wxT(""), wxPoint(175, 397), wxSize(120, 25), 0, wxDefaultValidator, wxT("ContribTxt"));
+ pLinesMsg = new wxStaticText(this, EDITOR_DIALOG_LINES_MSG, wxT("Lines of code:"), wxPoint(303, 380), wxSize( -1, -1), 0, wxT("LinesMsg"));
+ pLinesTxt = new wxTextCtrl(this, EDITOR_DIALOG_LINES_TEXT, wxT(""), wxPoint(303, 397), wxSize(100, 25), 0, wxDefaultValidator, wxT("LinesTxt"));
+
+ pCatalogBtn = new wxButton(this, EDITOR_DIALOG_CATALOG, wxT("Catalo&g"), wxPoint(430, 287), wxSize( 70, 35), 0, wxDefaultValidator, wxT("CatalogBtn"));
+ pDataTypesBtn = new wxButton(this, EDITOR_DIALOG_DATATYPES, wxT("Data&types"), wxPoint(430, 337), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DataTypesBtn"));
+ pDbDiagsBtn = new wxButton(this, EDITOR_DIALOG_DB_DIAGS, wxT("DB Dia&gs"), wxPoint(430, 387), wxSize( 70, 35), 0, wxDefaultValidator, wxT("DbDiagsBtn"));
+
+ // Now that all the widgets on the panel are created, its safe to allow ::OnCommand() to
+ // handle all widget processing
+ widgetPtrsSet = TRUE;
+
+ // Setup the orderBy and where clauses to return back a single record as the result set,
+ // as there will only be one record being shown on the dialog at a time, this optimizes
+ // network traffic by only returning a one row result
+
+ wxGetApp().Contact->SetOrderByClause(wxT("NAME")); // field name to sort by
+
+ // The wxString "whereStr" is not a member of the wxDbTable object, it is a member variable
+ // specifically in the Ccontact class. It is used here for simpler construction of a varying
+ // length string, and then after the string is built, the wxDbTable member variable "where" is
+ // assigned the pointer to the constructed string.
+ //
+ // The constructed where clause below has a sub-query within it "SELECT MIN(NAME) FROM %s"
+ // to achieve a single row (in this case the first name in alphabetical order).
+
+ if (wxGetApp().Contact->GetDb()->Dbms() != dbmsPOSTGRES &&
+ wxGetApp().Contact->GetDb()->Dbms() != dbmsMY_SQL)
+ {
+ wxGetApp().Contact->whereStr.Printf(wxT("NAME = (SELECT MIN(NAME) FROM %s)"),
+ wxGetApp().Contact->GetTableName().c_str());
+ // NOTE: (const wxChar*) returns a pointer which may not be valid later, so this is short term use only
+ wxGetApp().Contact->SetWhereClause(wxGetApp().Contact->whereStr);
+ }
+ else
+ wxGetApp().Contact->SetWhereClause(wxT(""));
+
+ // Perform the Query to get the result set.
+ // NOTE: If there are no rows returned, that is a valid result, so Query() would return TRUE.
+ // Only if there is a database error will Query() come back as FALSE
+ if (!wxGetApp().Contact->Query())
+ {
+ wxString tStr;
+ tStr = wxT("ODBC error during Query()\n\n");
+ wxMessageBox(wxDbLogExtendedErrorMsg(tStr.c_str(),wxGetApp().Contact->GetDb(),__FILE__,__LINE__),
+ wxT("ODBC Error..."),wxOK | wxICON_EXCLAMATION);
+ return FALSE;
+ }
+
+ // Since Query succeeded, now get the row that was returned
+ if (!wxGetApp().Contact->GetNext())
+ // If the GetNext() failed at this point, then there are no rows to retrieve,
+ // so clear the values in the members of "Contact" so that PutData() blanks the
+ // widgets on the dialog
+ wxGetApp().Contact->Initialize();