- wxBeginBusyCursor();
-
- strcpy(ListDB_Selection,"");
- strcpy(ListDB_Selection2,"");
- widgetPtrsSet = FALSE;
- lookup = 0;
- lookup2 = 0;
- noDisplayCols = (strlen(dispCol2) ? 2 : 1);
- col1Len = 0;
-
- // Build the dialog
- SetLabelPosition(wxVERTICAL);
-
- wxFont *ButtonFont = new wxFont(12,wxSWISS,wxNORMAL,wxBOLD);
- wxFont *TextFont = new wxFont(12,wxSWISS,wxNORMAL,wxNORMAL);
- wxFont *FixedFont = new wxFont(12,wxMODERN,wxNORMAL,wxNORMAL);
-
- SetButtonFont(ButtonFont);
- SetLabelFont(TextFont);
- SetLabelPosition(wxVERTICAL);
-
- // this is done with fixed font so that the second column (if any) will be left
- // justified in the second column
- SetButtonFont(FixedFont);
- pLookUpSelectList = new wxListBox(this, NULL, "", wxSINGLE|wxALWAYS_SB, 5, 15, 384, 195, 0, 0, 0, "LookUpSelectList");
- SetButtonFont(ButtonFont);
- pLookUpOkBtn = new wxButton(this, NULL, "&Ok", 113, 222, 70, 35, 0, "LookUpOkBtn");
- pLookUpCancelBtn = new wxButton(this, NULL, "C&ancel", 212, 222, 70, 35, 0, "LookUpCancelBtn");
-
- widgetPtrsSet = TRUE;
-
- // Query the lookup table and display the result set
- if (!(lookup2 = new Clookup2(tableName, dispCol1, dispCol2, pDb)))
- {
- wxMessageBox("Error allocating memory for 'Clookup2'object.","Error...");
- Close();
- return;
- }
-
- if (!lookup2->Open())
- {
- wxString tStr;
- tStr.sprintf("Unable to open the table '%s'.",tableName);
- wxMessageBox(tStr.GetData(),"ODBC Error...");
- Close();
- return;
- }
-
- // If displaying 2 columns, determine the maximum length of column1
- int maxColLen;
- if (maxLenCol1)
- maxColLen = col1Len = maxLenCol1; // user passed in max col length for column 1
- else
- {
- maxColLen = LOOKUP_COL_LEN;
- if (strlen(dispCol2))
- {
- wxString q = "SELECT MAX({fn LENGTH(";
- q += dispCol1;
- q += ")}), NULL";
- q += " FROM ";
- q += tableName;
- if (strlen(where))
- {
- q += " WHERE ";
- q += where;
- }
- if (!lookup2->QueryBySqlStmt(q.GetData()))
- {
- wxMessageBox("ODBC error during QueryBySqlStmt()","ODBC Error...");
- Close();
- return;
- }
- if (lookup2->GetNext())
- maxColLen = col1Len = atoi(lookup2->lookupCol1);
- else
- wxMessageBox("ODBC error during GetNext()","ODBC Error...");
- }
- }
-
- // Query the actual record set
- if (selectStmt && strlen(selectStmt)) // Query by sql stmt passed in
- {
- if (!lookup2->QueryBySqlStmt(selectStmt))
- {
- wxMessageBox("ODBC error during QueryBySqlStmt()","ODBC Error...");
- Close();
- return;
- }
- }
- else // Query using where and order by clauses
- {
- lookup2->orderBy = orderBy;
- lookup2->where = where;
- if (!lookup2->Query(FALSE, distinctValues))
- {
- wxMessageBox("ODBC error during Query()","ODBC Error...");
- Close();
- return;
- }
- }
-
- // Fill in the list box from the query result set
- wxString s;
- while (lookup2->GetNext())
- {
- s = lookup2->lookupCol1;
- if (strlen(dispCol2)) // Append the optional column 2
- {
- s.Append(' ', (maxColLen + LISTDB_NO_SPACES_BETWEEN_COLS - strlen(lookup2->lookupCol1)));
- s.Append(lookup2->lookupCol2);
- }
- pLookUpSelectList->Append(s.GetData());
- }
-
- // Highlight the first list item
- pLookUpSelectList->SetSelection(0);
-
- // Make the OK activate by pressing Enter
- if (pLookUpSelectList->Number())
- pLookUpOkBtn->SetDefault();
- else
- {
- pLookUpCancelBtn->SetDefault();
- pLookUpOkBtn->Enable(FALSE);
- }
-
- pLookUpOkBtn->Enable(allowOk);
-
- // Display the dialog window
- SetTitle(windowTitle);
- Centre(wxBOTH);
- wxEndBusyCursor();
- Show(TRUE);
+ wxBeginBusyCursor();
+
+ wxStrcpy(ListDB_Selection,wxT(""));
+ wxStrcpy(ListDB_Selection2,wxT(""));
+ widgetPtrsSet = FALSE;
+ lookup = 0;
+ lookup2 = 0;
+ noDisplayCols = (wxStrlen(dispCol2) ? 2 : 1);
+ col1Len = 0;
+
+ wxFont fixedFont(12,wxMODERN,wxNORMAL,wxNORMAL);
+
+ // this is done with fixed font so that the second column (if any) will be left
+ // justified in the second column
+ pLookUpSelectList = new wxListBox(this, LOOKUP_DIALOG_SELECT, wxPoint(5, 15), wxSize(384, 195), 0, 0, wxLB_SINGLE|wxLB_ALWAYS_SB, wxDefaultValidator, wxT("LookUpSelectList"));
+
+ pLookUpSelectList->SetFont(fixedFont);
+
+ pLookUpOkBtn = new wxButton(this, LOOKUP_DIALOG_OK, wxT("&Ok"), wxPoint(113, 222), wxSize(70, 35), 0, wxDefaultValidator, wxT("LookUpOkBtn"));
+ pLookUpCancelBtn = new wxButton(this, LOOKUP_DIALOG_CANCEL, wxT("C&ancel"), wxPoint(212, 222), wxSize(70, 35), 0, wxDefaultValidator, wxT("LookUpCancelBtn"));
+
+ widgetPtrsSet = TRUE;
+
+ // Query the lookup table and display the result set
+ lookup2 = new Clookup2(tableName, dispCol1, dispCol2, pDb, defDir);
+ if (!lookup2)
+ {
+ wxMessageBox(wxT("Error allocating memory for 'Clookup2' object."),wxT("Error..."));
+ Close();
+ return;
+ }
+
+ if (!lookup2->Open())
+ {
+ wxString tStr;
+ tStr.Printf(wxT("Unable to open the table '%s'."),tableName);
+ tStr += GetExtendedDBErrorMsg2(pDb,__FILE__,__LINE__);
+ wxMessageBox(tStr,wxT("ODBC Error..."));
+ Close();
+ return;
+ }
+
+ // If displaying 2 columns, determine the maximum length of column1
+ int maxColLen;
+ if (maxLenCol1)
+ maxColLen = col1Len = maxLenCol1; // user passed in max col length for column 1
+ else
+ {
+ maxColLen = LOOKUP_COL_LEN;
+ if (wxStrlen(dispCol2))
+ {
+ wxString q = wxT("SELECT MAX({fn LENGTH(");
+ q += dispCol1;
+ q += wxT(")}), NULL");
+ q += wxT(" FROM ");
+ q += tableName;
+ if (wxStrlen(where))
+ {
+ q += wxT(" WHERE ");
+ q += where;
+ }
+ if (!lookup2->QueryBySqlStmt(q))
+ {
+ wxMessageBox(wxT("ODBC error during QueryBySqlStmt()"),wxT("ODBC Error..."));
+ Close();
+ return;
+ }
+ if (lookup2->GetNext())
+ maxColLen = col1Len = atoi(lookup2->lookupCol1);
+ else
+ wxMessageBox(wxT("ODBC error during GetNext()"),wxT("ODBC Error..."));
+ }
+ }
+
+ // Query the actual record set
+ if (selectStmt && wxStrlen(selectStmt)) // Query by sql stmt passed in
+ {
+ if (!lookup2->QueryBySqlStmt(selectStmt))
+ {
+ wxMessageBox(wxT("ODBC error during QueryBySqlStmt()"),wxT("ODBC Error..."));
+ Close();
+ return;
+ }
+ }
+ else // Query using where and order by clauses
+ {
+ lookup2->SetOrderByClause(orderBy);
+ lookup2->SetWhereClause(where);
+ if (!lookup2->Query(FALSE, distinctValues))
+ {
+ wxMessageBox(wxT("ODBC error during Query()"),wxT("ODBC Error..."));
+ Close();
+ return;
+ }
+ }
+
+ // Fill in the list box from the query result set
+ wxString s;
+ while (lookup2->GetNext())
+ {
+ s = lookup2->lookupCol1;
+ if (wxStrlen(dispCol2)) // Append the optional column 2
+ {
+ s.Append(wxT(' '), (maxColLen + LISTDB_NO_SPACES_BETWEEN_COLS - wxStrlen(lookup2->lookupCol1)));
+ s.Append(lookup2->lookupCol2);
+ }
+ pLookUpSelectList->Append(s);
+ }
+
+ // Highlight the first list item
+ pLookUpSelectList->SetSelection(0);
+
+ // Make the OK activate by pressing Enter
+ if (pLookUpSelectList->Number())
+ pLookUpOkBtn->SetDefault();
+ else
+ {
+ pLookUpCancelBtn->SetDefault();
+ pLookUpOkBtn->Enable(FALSE);
+ }
+
+ pLookUpOkBtn->Enable(allowOk);
+
+ // Display the dialog window
+ SetTitle(windowTitle);
+ Centre(wxBOTH);
+ wxEndBusyCursor();
+ ShowModal();