Reformatted source to normalize spacing/indentation - no code changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7948 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
George Tasker
2000-08-05 18:34:44 +00:00
parent 3c8c835c23
commit 2941f53242
3 changed files with 164 additions and 173 deletions

View File

@@ -82,7 +82,8 @@ wxDb *READONLY_DB;
/*
* This function will return the exact string(s) from the database engine
* indicating all error conditions which have just occured during the
* last call to the database engine.
* last call to the database engine for the database connection pointed
* to by pDb.
*
* This demo uses the returned string by displaying it in a wxMessageBox. The
* formatting therefore is not the greatest, but this is just a demo, not a
@@ -91,7 +92,7 @@ wxDb *READONLY_DB;
* NOTE: The value returned by this function is for temporary use only and
* should be copied for long term use
*/
const char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine)
const char *GetExtendedDBErrorMsg(wxDb *pDb, char *ErrFile, int ErrLine)
{
static wxString msg;
msg = "";
@@ -111,32 +112,23 @@ const char *GetExtendedDBErrorMsg(char *ErrFile, int ErrLine)
msg.Append ("\nODBC errors:\n");
msg += "\n";
/* Scan through each database connection displaying
* any ODBC errors that have occured. */
wxDbList *pDbList;
for (pDbList = PtrBegDbList; pDbList; pDbList = pDbList->PtrNext)
{
// Skip over any free connections
if (pDbList->Free)
continue;
// Display errors for this connection
int i;
for (i = 0; i < DB_MAX_ERROR_HISTORY; i++)
{
if (pDbList->PtrDb->errorList[i])
if (pDb->errorList[i])
{
msg.Append(pDbList->PtrDb->errorList[i]);
if (wxStrcmp(pDbList->PtrDb->errorList[i],"") != 0)
msg.Append(pDb->errorList[i]);
if (wxStrcmp(pDb->errorList[i],"") != 0)
msg.Append("\n");
// Clear the errmsg buffer so the next error will not
// end up showing the previous error that have occurred
wxStrcpy(pDbList->PtrDb->errorList[i],"");
}
wxStrcpy(pDb->errorList[i],"");
}
}
msg += "\n";
return /*(char*) (const char*) msg*/msg.c_str();
return msg.c_str();
} // GetExtendedDBErrorMsg
@@ -235,11 +227,11 @@ bool DatabaseDemoApp::OnInit()
// Show the frame
DemoFrame->Refresh();
// DemoFrame->Show(TRUE);
return TRUE;
} // DatabaseDemoApp::OnInit()
BEGIN_EVENT_TABLE(DatabaseDemoFrame, wxFrame)
EVT_MENU(FILE_CREATE, DatabaseDemoFrame::OnCreate)
EVT_MENU(FILE_RECREATE_TABLE, DatabaseDemoFrame::OnRecreateTable)
@@ -250,6 +242,7 @@ BEGIN_EVENT_TABLE(DatabaseDemoFrame, wxFrame)
EVT_CLOSE(DatabaseDemoFrame::OnCloseWindow)
END_EVENT_TABLE()
// DatabaseDemoFrame constructor
DatabaseDemoFrame::DatabaseDemoFrame(wxFrame *frame, const wxString& title,
const wxPoint& pos, const wxSize& size):
@@ -258,17 +251,20 @@ DatabaseDemoFrame::DatabaseDemoFrame(wxFrame *frame, const wxString& title,
// Put any code in necessary for initializing the main frame here
pEditorDlg = NULL;
pParamDlg = NULL;
}
} // DatabaseDemoFrame constructor
void DatabaseDemoFrame::OnCreate(wxCommandEvent& event)
{
CreateDataTable(FALSE);
}
} // DatabaseDemoFrame::OnCreate()
void DatabaseDemoFrame::OnRecreateTable(wxCommandEvent& event)
{
CreateDataTable(TRUE);
}
} // DatabaseDemoFrame::OnRecreate()
void DatabaseDemoFrame::OnRecreateIndexes(wxCommandEvent& event)
{
@@ -288,18 +284,19 @@ void DatabaseDemoFrame::OnRecreateIndexes(wxCommandEvent& event)
wxEndBusyCursor();
wxString tStr;
tStr = "Error creating CONTACTS indexes.\nNew indexes will be unavailable.\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
}
delete Contact;
Contact = NULL;
}
} // DatabaseDemoFrame::OnRecreateIndexes()
void DatabaseDemoFrame::OnExit(wxCommandEvent& event)
{
Close();
}
} // DatabaseDemoFrame::OnExit()
void DatabaseDemoFrame::OnEditParameters(wxCommandEvent& event)
{
@@ -307,12 +304,14 @@ void DatabaseDemoFrame::OnEditParameters(wxCommandEvent& event)
BuildParameterDialog(this);
else
wxMessageBox("Cannot change database parameters while creating or editing a record","Notice...",wxOK | wxICON_INFORMATION);
}
} // DatabaseDemoFrame::OnEditParameters()
void DatabaseDemoFrame::OnAbout(wxCommandEvent& event)
{
wxMessageBox("wxWindows sample program for database classes\n\nContributed on 27 July 1998","About...",wxOK | wxICON_INFORMATION);
}
} // DatabaseDemoFrame::OnAbout()
void DatabaseDemoFrame::OnCloseWindow(wxCloseEvent& event)
{
@@ -369,7 +368,7 @@ void DatabaseDemoFrame::CreateDataTable(bool recreate)
wxEndBusyCursor();
wxString tStr;
tStr = "Error creating CONTACTS table.\nTable was not created.\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
success = FALSE;
}
@@ -380,7 +379,7 @@ void DatabaseDemoFrame::CreateDataTable(bool recreate)
wxEndBusyCursor();
wxString tStr;
tStr = "Error creating CONTACTS indexes.\nIndexes will be unavailable.\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
success = FALSE;
}
@@ -410,7 +409,8 @@ void DatabaseDemoFrame::BuildEditorDialog()
wxMessageBox("Unable to initialize the editor dialog for some reason","Error...",wxOK | wxICON_EXCLAMATION);
DemoFrame->Close();
}
} else
}
else
{
wxMessageBox("Unable to create the editor dialog for some reason","Error...",wxOK | wxICON_EXCLAMATION);
DemoFrame->Close();
@@ -483,7 +483,7 @@ Ccontact::~Ccontact()
{
wxString tStr;
tStr = "Unable to Free the Ccontact data table handle\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
}
}
@@ -617,7 +617,7 @@ void CeditorDlg::OnButton( wxCommandEvent &event )
{
wxWindow *win = (wxWindow*) event.GetEventObject();
OnCommand( *win, event );
}
} // CeditorDlg::OnButton()
void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
@@ -741,7 +741,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString tStr;
tStr = "ODBC error during Query()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
SetMode(mView);
return;
@@ -785,7 +785,6 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
// display it, if the query string has changed.
if (wxStrcmp(qryWhere, (const char*) Contact->qryWhereStr))
{
Contact->whereStr = "";
Contact->SetOrderByClause("NAME");
@@ -810,7 +809,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString tStr;
tStr = "ODBC error during Query()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
return;
}
@@ -845,7 +844,7 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString tStr;
tStr = "ODBC error during Query()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
return;
}
@@ -879,7 +878,6 @@ void CeditorDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
return;
}
} // CeditorDlg::OnCommand()
@@ -902,7 +900,7 @@ bool CeditorDlg::Initialize()
{
wxString tStr;
tStr.Printf("Unable to open the table '%s'.\n\nTable may need to be created...?\n\n",CONTACT_TABLE_NAME);
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
bool createTable = (wxMessageBox("Do you wish to try to create/clear the CONTACTS table?","Confirm",wxYES_NO|wxICON_QUESTION) == wxYES);
@@ -923,7 +921,6 @@ bool CeditorDlg::Initialize()
// never fail, except in the case of the table not exisiting or the current
// user has insufficent privileges to access the table
#if 0
// 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
@@ -932,7 +929,7 @@ bool CeditorDlg::Initialize()
{
wxString tStr;
tStr.Printf("Unable to open the table '%s'.\n\n",CONTACT_TABLE_NAME);
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
}
else
@@ -941,7 +938,7 @@ bool CeditorDlg::Initialize()
{
wxString tStr;
tStr.Printf("Unable to open the table '%s'.\n\n",CONTACT_TABLE_NAME);
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
}
@@ -1034,7 +1031,7 @@ bool CeditorDlg::Initialize()
{
wxString tStr;
tStr = "ODBC error during Query()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
// GetParent()->Close();
return FALSE;
@@ -1282,7 +1279,7 @@ bool CeditorDlg::Save()
{
wxString tStr;
tStr = "A duplicate key value already exists in the table.\nUnable to save record\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
}
else
@@ -1290,7 +1287,7 @@ bool CeditorDlg::Save()
// Some other unexpexted error occurred
wxString tStr;
tStr = "Database insert failed\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
}
}
@@ -1301,7 +1298,7 @@ bool CeditorDlg::Save()
{
wxString tStr;
tStr = "Database update failed\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
failed = TRUE;
}
@@ -1406,7 +1403,7 @@ bool CeditorDlg::GetRec(char *whereStr)
{
wxString tStr;
tStr = "ODBC error during Query()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(Contact->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
return(FALSE);
@@ -1500,6 +1497,7 @@ void CparameterDlg::OnButton( wxCommandEvent &event )
OnCommand( *win, event );
}
void CparameterDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
wxString widgetName;
@@ -1657,6 +1655,7 @@ BEGIN_EVENT_TABLE(CqueryDlg, wxDialog)
EVT_CLOSE(CqueryDlg::OnCloseWindow)
END_EVENT_TABLE()
// CqueryDlg() constructor
CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, char *tblName[], char *pWhereArg) : wxDialog (parent, QUERY_DIALOG, "Query", wxPoint(-1, -1), wxSize(480, 360))
{
@@ -1727,7 +1726,7 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, char *tblName[], char *pWhereA
wxEndBusyCursor();
wxString tStr;
tStr = "ODBC error during GetColumns()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(pDb,__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
return;
}
@@ -1766,7 +1765,6 @@ CqueryDlg::CqueryDlg(wxWindow *parent, wxDb *pDb, char *tblName[], char *pWhereA
// Display the dialog window
Centre(wxBOTH);
ShowModal();
} // CqueryDlg() constructor
@@ -1779,7 +1777,8 @@ void CqueryDlg::OnButton( wxCommandEvent &event )
{
wxWindow *win = (wxWindow*) event.GetEventObject();
OnCommand( *win, event );
}
} // CqueryDlg::OnButton()
void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
@@ -1905,7 +1904,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
pQueryValue1Txt->SetFocus();
}
return;
} // Column 2 choice
// Add button
@@ -1913,7 +1911,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
ProcessAddBtn();
return;
} // Add button
// And button
@@ -1921,7 +1918,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
AppendToWhere(" AND\n");
return;
} // And button
// Or button
@@ -1929,7 +1925,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
AppendToWhere(" OR\n");
return;
} // Or button
// Left Paren button
@@ -1937,7 +1932,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
AppendToWhere("(");
return;
} // Left Paren button
// Right paren button
@@ -1945,7 +1939,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
{
AppendToWhere(")");
return;
} // Right Paren button
// Done button
@@ -1966,7 +1959,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
wxStrcpy(pWhere, pQuerySqlWhereMtxt->GetValue());
Close();
return;
} // Done button
// Clear button
@@ -1977,7 +1969,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
if (Ok)
pQuerySqlWhereMtxt->SetValue("");
return;
} // Clear button
// Count button
@@ -1987,7 +1978,6 @@ void CqueryDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
ProcessCountBtn();
wxEndBusyCursor();
return;
} // Count button
} // CqueryDlg::OnCommand
@@ -2024,7 +2014,6 @@ void CqueryDlg::AppendToWhere(char *s)
wxString whereStr = pQuerySqlWhereMtxt->GetValue();
whereStr += s;
pQuerySqlWhereMtxt->SetValue(whereStr);
} // CqueryDlg::AppendToWhere()
@@ -2145,7 +2134,7 @@ void CqueryDlg::ProcessCountBtn()
{
wxString tStr;
tStr = "ODBC error during Open()\n\n";
tStr += GetExtendedDBErrorMsg(__FILE__,__LINE__);
tStr += GetExtendedDBErrorMsg(dbTable->GetDb(),__FILE__,__LINE__);
wxMessageBox(tStr,"ODBC Error...",wxOK | wxICON_EXCLAMATION);
return;
}

View File

@@ -411,6 +411,8 @@ void ClookUpDlg::OnClose(wxCloseEvent& event)
if (lookup2)
delete lookup2;
SetReturnCode(1);
while (wxIsBusy()) wxEndBusyCursor();
event.Skip();