]>
Commit | Line | Data |
---|---|---|
108106cf JS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: dbtest.h | |
be5a51fb | 3 | // Purpose: wxWidgets database demo app |
108106cf JS |
4 | // Author: George Tasker |
5 | // Modified by: | |
6 | // Created: 1998 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Remstar International, Inc. | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
52ad8c7d | 12 | #if defined(__GNUG__) && !defined(__APPLE__) |
108106cf | 13 | #pragma interface "dbtest.h" |
1fc5dd6f | 14 | #endif |
108106cf | 15 | |
fb86524f GD |
16 | #include "wx/string.h" |
17 | #include "wx/dbtable.h" | |
108106cf | 18 | |
e70e8f4c | 19 | enum DialogModes {mView,mCreate,mEdit,mSearch}; |
108106cf JS |
20 | |
21 | // ID for the menu quit command | |
74de91cc | 22 | #define FILE_CREATE_ID 100 |
3ca6a5f0 BP |
23 | #define FILE_RECREATE_TABLE 110 |
24 | #define FILE_RECREATE_INDEXES 120 | |
9b12bd99 GT |
25 | |
26 | #if wxUSE_GRID | |
f21b2fd8 GT |
27 | #define FILE_DBGRID_TABLE 130 |
28 | #endif | |
3ca6a5f0 BP |
29 | #define FILE_EXIT 199 |
30 | #define EDIT_PARAMETERS 200 | |
ea24eeb2 | 31 | #define HELP_ABOUT 300 |
108106cf | 32 | |
e115e771 | 33 | // this seems to be missing, Robert Roebling (?) |
d433a26f | 34 | #ifndef MAX_PATH |
049977d0 GT |
35 | #if defined(__WXMAC__) |
36 | #define MAX_PATH 260 /* max. length of full pathname */ | |
37 | #else /* _MAC */ | |
38 | #define MAX_PATH 256 /* max. length of full pathname */ | |
39 | #endif | |
d433a26f | 40 | #endif |
108106cf JS |
41 | |
42 | // Name of the table to be created/opened | |
74de91cc | 43 | const wxChar CONTACT_TABLE_NAME[] = wxT("contacts"); |
108106cf | 44 | |
dd5b579c | 45 | #define wxODBC_BLOB_SUPPORT |
3fe813a9 | 46 | |
049977d0 | 47 | // Number of columns in the CONTACT table |
dd5b579c GT |
48 | #ifdef wxODBC_BLOB_SUPPORT |
49 | const int CONTACT_NO_COLS = 13; // 0-12 | |
3fe813a9 | 50 | #else |
dd5b579c | 51 | const int CONTACT_NO_COLS = 12; // 0-11 |
3fe813a9 | 52 | #endif |
049977d0 | 53 | |
74de91cc | 54 | const wxChar PARAM_FILENAME[] = wxT("dbtest.cfg"); |
108106cf | 55 | |
108106cf JS |
56 | |
57 | enum Language {langENGLISH, langFRENCH, langGERMAN, langSPANISH, langOTHER}; | |
58 | ||
59 | // Forward class declarations | |
60 | class CeditorDlg; | |
61 | class CparameterDlg; | |
62 | ||
3f030b48 GT |
63 | |
64 | // Used for displaying many of the database capabilites | |
65 | // and usage statistics on a database connection | |
66 | void DisplayDbDiagnostics(wxDb *pDb); | |
67 | ||
68 | ||
049977d0 GT |
69 | // |
70 | // This class contains the actual data members that are used for transferring | |
925e9792 | 71 | // data back and forth from the database to the program. |
049977d0 GT |
72 | // |
73 | // NOTE: The object described in this class is just for example purposes, and has no | |
74 | // real meaning other than to show each type of field being used by the database | |
75 | // | |
108106cf JS |
76 | class CstructContact : public wxObject |
77 | { | |
e70e8f4c | 78 | public: |
049977d0 GT |
79 | wxChar Name[50+1]; // Contact's name |
80 | wxChar Addr1[50+1]; | |
81 | wxChar Addr2[50+1]; | |
82 | wxChar City[25+1]; | |
83 | wxChar State[25+1]; | |
84 | wxChar PostalCode[15+1]; | |
85 | wxChar Country[20+1]; | |
be5a51fb | 86 | TIMESTAMP_STRUCT JoinDate; // Date on which this person joined the wxWidgets project |
e70e8f4c | 87 | Language NativeLanguage; // Enumerated type indicating person's native language |
3fe813a9 | 88 | wxChar Picture[50000]; |
be5a51fb | 89 | bool IsDeveloper; // Is this person a developer for wxWidgets, or just a subscriber |
e70e8f4c GT |
90 | UCHAR Contributions; // Something to show off an integer field |
91 | ULONG LinesOfCode; // Something to show off a 'long' field | |
108106cf JS |
92 | }; // CstructContact |
93 | ||
94 | ||
95 | // | |
049977d0 GT |
96 | // The Ccontact class derives from wxDbTable, so we have access to all |
97 | // of the database table functions and the local memory variables that | |
98 | // the database classes will store the data into (and read the data from) | |
99 | // all combined in this one class. | |
108106cf | 100 | // |
f6bcfd97 | 101 | class Ccontact : public wxDbTable, public CstructContact |
925e9792 | 102 | { |
e70e8f4c | 103 | private: |
049977d0 | 104 | // Used to keep track of whether this class had a wxDb instance |
925e9792 | 105 | // passed in to it or not. If an existing wxDb instance was not |
049977d0 GT |
106 | // passed in at Ccontact creation time, then when the Ccontact |
107 | // instance is deleted, the connection will be freed as Ccontact | |
108 | // created its own connection when it was created. | |
e70e8f4c | 109 | bool freeDbConn; |
049977d0 GT |
110 | |
111 | // Calls wxDbTable::SetColDefs() once for each column that is | |
112 | // to be associated with some member variable for use with | |
113 | // this database object. | |
e70e8f4c | 114 | void SetupColumns(); |
108106cf | 115 | |
e70e8f4c | 116 | public: |
925e9792 | 117 | // Used in places where we need to construct a WHERE clause to |
049977d0 GT |
118 | // be passed to the SetWhereClause() function. From example, |
119 | // where building the WHERE clause requires using ::Printf() | |
120 | // to build the string. | |
e70e8f4c | 121 | wxString whereStr; |
049977d0 GT |
122 | |
123 | // WHERE string returned from the query dialog | |
124 | wxString qryWhereStr; | |
108106cf | 125 | |
f6bcfd97 | 126 | Ccontact(wxDb *pwxDb=NULL); |
e70e8f4c | 127 | ~Ccontact(); |
108106cf | 128 | |
e70e8f4c | 129 | void Initialize(); |
049977d0 GT |
130 | |
131 | // Contains all the index definitions and calls to wxDbTable::CreateIndex() | |
132 | // required to create all the indexes we wish to define for this table. | |
69a2b59d | 133 | bool CreateIndexes(bool recreate); |
049977d0 GT |
134 | |
135 | // Since we do not wish to have duplicate code blocks all over our program | |
136 | // for a common query/fetch that we will need to do in many places, we | |
137 | // include this member function that does it all for us in one place. | |
138 | bool FetchByName(const wxString &name); | |
108106cf JS |
139 | |
140 | }; // Ccontact class definition | |
141 | ||
142 | ||
143 | typedef struct Cparameters | |
144 | { | |
049977d0 GT |
145 | wxChar ODBCSource[SQL_MAX_DSN_LENGTH+1]; |
146 | wxChar UserName[SQL_MAX_USER_NAME_LEN+1]; | |
147 | wxChar Password[SQL_MAX_AUTHSTR_LEN+1]; | |
94613352 | 148 | wxChar DirPath[MAX_PATH+1]; |
108106cf JS |
149 | } Cparameters; |
150 | ||
151 | ||
108106cf JS |
152 | // Define a new frame type |
153 | class DatabaseDemoFrame: public wxFrame | |
925e9792 | 154 | { |
e70e8f4c GT |
155 | private: |
156 | CeditorDlg *pEditorDlg; | |
157 | CparameterDlg *pParamDlg; | |
108106cf | 158 | |
e70e8f4c GT |
159 | public: |
160 | DatabaseDemoFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& sz); | |
3f030b48 | 161 | ~DatabaseDemoFrame(); |
108106cf | 162 | |
e70e8f4c | 163 | void OnCloseWindow(wxCloseEvent& event); |
1fc5dd6f | 164 | void OnCreate(wxCommandEvent& event); |
3ca6a5f0 BP |
165 | void OnRecreateTable(wxCommandEvent& event); |
166 | void OnRecreateIndexes(wxCommandEvent& event); | |
1fc5dd6f JS |
167 | void OnExit(wxCommandEvent& event); |
168 | void OnEditParameters(wxCommandEvent& event); | |
169 | void OnAbout(wxCommandEvent& event); | |
9b12bd99 | 170 | #if wxUSE_GRID |
f21b2fd8 | 171 | void OnDbGridTable( wxCommandEvent& ); |
925e9792 | 172 | #endif |
f21b2fd8 | 173 | void CreateDataTable(bool recreate); |
e70e8f4c GT |
174 | void BuildEditorDialog(); |
175 | void BuildParameterDialog(wxWindow *parent); | |
1fc5dd6f JS |
176 | |
177 | DECLARE_EVENT_TABLE() | |
108106cf JS |
178 | }; // DatabaseDemoFrame |
179 | ||
180 | ||
9b12bd99 | 181 | #if wxUSE_GRID |
f21b2fd8 GT |
182 | |
183 | // *************************** DBGridFrame *************************** | |
184 | ||
185 | class DbGridFrame : public wxFrame | |
186 | { | |
187 | public: | |
2f6c54eb | 188 | bool initialized; |
f21b2fd8 | 189 | |
2f6c54eb | 190 | DbGridFrame(wxWindow *parent); |
f21b2fd8 | 191 | |
2f6c54eb VZ |
192 | void OnCloseWindow(wxCloseEvent& event); |
193 | bool Initialize(); | |
f21b2fd8 | 194 | |
2f6c54eb | 195 | DECLARE_EVENT_TABLE() |
f21b2fd8 GT |
196 | }; |
197 | ||
198 | #endif | |
199 | ||
049977d0 GT |
200 | // Define a new application type |
201 | class DatabaseDemoApp: public wxApp | |
202 | { | |
203 | public: | |
204 | // These are the parameters that are stored in the "PARAM_FILENAME" file | |
205 | // that are read in at startup of the program that indicate the connection | |
206 | // parameters to be used for connecting to the ODBC data source. | |
207 | Cparameters params; | |
208 | ||
209 | // Pointer to the main frame used by the App | |
210 | DatabaseDemoFrame *DemoFrame; | |
211 | ||
212 | // Pointer to the main database connection used in the program. This | |
213 | // pointer would normally be used for doing things as database lookups | |
214 | // for user login names and passwords, getting workstation settings, etc. | |
925e9792 | 215 | // |
049977d0 | 216 | // ---> IMPORTANT <--- |
925e9792 | 217 | // |
049977d0 GT |
218 | // For each database object created which uses this wxDb pointer |
219 | // connection to the database, when a CommitTrans() or RollBackTrans() | |
220 | // will commit or rollback EVERY object which uses this wxDb pointer. | |
925e9792 WS |
221 | // |
222 | // To allow each table object (those derived from wxDbTable) to be | |
049977d0 | 223 | // individually committed or rolled back, you MUST use a different |
925e9792 | 224 | // instance of wxDb in the constructor of the table. Doing so creates |
049977d0 GT |
225 | // more overhead, and will use more database connections (some DBs have |
226 | // connection limits...), so use connections sparringly. | |
925e9792 | 227 | // |
049977d0 GT |
228 | // It is recommended that one "main" database connection be created for |
229 | // the entire program to use for READ-ONLY database accesses, but for each | |
230 | // table object which will do a CommitTrans() or RollbackTrans() that a | |
231 | // new wxDb object be created and used for it. | |
232 | wxDb *READONLY_DB; | |
233 | ||
925e9792 | 234 | // Contains the ODBC connection information used by |
049977d0 GT |
235 | // all database connections |
236 | wxDbConnectInf *DbConnectInf; | |
237 | ||
238 | bool OnInit(); | |
239 | ||
240 | // Read/Write ODBC connection parameters to the "PARAM_FILENAME" file | |
241 | bool ReadParamFile(Cparameters ¶ms); | |
242 | bool WriteParamFile(Cparameters ¶ms); | |
243 | ||
244 | void CreateDataTable(bool recreate); | |
ea24eeb2 GT |
245 | |
246 | // Pointer to the wxDbTable instance that is used to manipulate | |
247 | // the data in memory and in the database | |
248 | Ccontact *Contact; | |
249 | ||
049977d0 GT |
250 | }; // DatabaseDemoApp |
251 | ||
252 | ||
253 | DECLARE_APP(DatabaseDemoApp) | |
254 | ||
108106cf JS |
255 | |
256 | // *************************** CeditorDlg *************************** | |
257 | ||
258 | class CeditorDlg : public wxPanel | |
259 | { | |
e70e8f4c | 260 | private: |
049977d0 | 261 | // Used to indicate whether all of the widget pointers (defined |
925e9792 | 262 | // below) have been initialized to point to the memory for |
049977d0 GT |
263 | // the named widget. Used as a safeguard from using the widget |
264 | // before it has been initialized. | |
3ca6a5f0 | 265 | bool widgetPtrsSet; |
049977d0 | 266 | |
925e9792 WS |
267 | // Used when the EDIT button has been pressed to maintain the |
268 | // original name that was displayed in the editor before the | |
049977d0 GT |
269 | // EDIT button was pressed, so that if CANCEL is pressed, a |
270 | // FetchByName() can be done to retrieve the original data | |
271 | // to repopulate the dialog. | |
3ca6a5f0 | 272 | wxString saveName; |
e70e8f4c GT |
273 | |
274 | // Pointers to all widgets on the dialog | |
275 | wxButton *pCreateBtn, *pEditBtn, *pDeleteBtn, *pCopyBtn, *pSaveBtn, *pCancelBtn; | |
276 | wxButton *pPrevBtn, *pNextBtn, *pQueryBtn, *pResetBtn, *pDoneBtn, *pHelpBtn; | |
277 | wxButton *pNameListBtn; | |
69a2b59d | 278 | wxButton *pCatalogBtn, *pDataTypesBtn, *pDbDiagsBtn; |
e70e8f4c GT |
279 | wxTextCtrl *pNameTxt, *pAddress1Txt, *pAddress2Txt,*pCityTxt, *pStateTxt, *pCountryTxt,*pPostalCodeTxt; |
280 | wxStaticText *pNameMsg, *pAddress1Msg, *pAddress2Msg,*pCityMsg, *pStateMsg, *pCountryMsg,*pPostalCodeMsg; | |
281 | wxTextCtrl *pJoinDateTxt,*pContribTxt, *pLinesTxt; | |
282 | wxStaticText *pJoinDateMsg,*pContribMsg, *pLinesMsg; | |
283 | wxRadioBox *pDeveloperRadio; | |
284 | wxChoice *pNativeLangChoice; | |
285 | wxStaticText *pNativeLangMsg; | |
286 | ||
287 | public: | |
049977d0 GT |
288 | // Indicates if the editor dialog has been initialized yet (used to |
289 | // help trap if the Initialize() function failed to load all required | |
290 | // resources or not. | |
3ca6a5f0 | 291 | bool initialized; |
049977d0 | 292 | |
3ca6a5f0 | 293 | enum DialogModes mode; |
049977d0 | 294 | |
e70e8f4c GT |
295 | CeditorDlg(wxWindow *parent); |
296 | ||
297 | void OnCloseWindow(wxCloseEvent& event); | |
298 | void OnButton( wxCommandEvent &event ); | |
299 | void OnCommand(wxWindow& win, wxCommandEvent& event); | |
300 | void OnActivate(bool) {}; // necessary for hot keys | |
301 | ||
3ca6a5f0 | 302 | bool Initialize(); |
049977d0 GT |
303 | |
304 | // Sets wxStaticText fields to be editable or not depending | |
305 | // on the current value of 'mode' | |
e70e8f4c | 306 | void FieldsEditable(); |
049977d0 GT |
307 | |
308 | // Sets the editor mode, determining what state widgets | |
309 | // on the dialog are to be in based on the operation | |
310 | // being performed. | |
e70e8f4c | 311 | void SetMode(enum DialogModes m); |
049977d0 GT |
312 | |
313 | // Update/Retrieve data from the widgets on the dialog | |
e70e8f4c GT |
314 | bool PutData(); |
315 | bool GetData(); | |
049977d0 GT |
316 | |
317 | // Inserts/updates the database with the current data | |
318 | // retrieved from the editor dialog | |
e70e8f4c | 319 | bool Save(); |
049977d0 | 320 | |
925e9792 | 321 | // Database functions for changing the data that is to |
049977d0 GT |
322 | // be displayed on the dialog. GetNextRec()/GetPrevRec() |
323 | // provide database independent methods that do not require | |
324 | // backward scrolling cursors to obtain the record that | |
325 | // is prior to the current record in the search sequence. | |
e70e8f4c GT |
326 | bool GetNextRec(); |
327 | bool GetPrevRec(); | |
049977d0 | 328 | bool GetRec(const wxString &whereStr); |
925e9792 | 329 | |
f6fcbb63 | 330 | DECLARE_EVENT_TABLE() |
108106cf JS |
331 | }; // CeditorDlg |
332 | ||
1fc5dd6f JS |
333 | #define EDITOR_DIALOG 199 |
334 | ||
335 | // Editor dialog control ids | |
336 | #define EDITOR_DIALOG_FN_GROUP 200 | |
337 | #define EDITOR_DIALOG_SEARCH_GROUP 201 | |
338 | #define EDITOR_DIALOG_CREATE 202 | |
339 | #define EDITOR_DIALOG_EDIT 203 | |
340 | #define EDITOR_DIALOG_DELETE 204 | |
341 | #define EDITOR_DIALOG_COPY 205 | |
342 | #define EDITOR_DIALOG_SAVE 206 | |
343 | #define EDITOR_DIALOG_CANCEL 207 | |
344 | #define EDITOR_DIALOG_PREV 208 | |
345 | #define EDITOR_DIALOG_NEXT 209 | |
346 | #define EDITOR_DIALOG_QUERY 211 | |
347 | #define EDITOR_DIALOG_RESET 212 | |
348 | #define EDITOR_DIALOG_NAME_MSG 213 | |
349 | #define EDITOR_DIALOG_NAME_TEXT 214 | |
350 | #define EDITOR_DIALOG_LOOKUP 215 | |
351 | #define EDITOR_DIALOG_ADDRESS1_MSG 216 | |
352 | #define EDITOR_DIALOG_ADDRESS1_TEXT 217 | |
353 | #define EDITOR_DIALOG_ADDRESS2_MSG 218 | |
354 | #define EDITOR_DIALOG_ADDRESS2_TEXT 219 | |
355 | #define EDITOR_DIALOG_CITY_MSG 220 | |
356 | #define EDITOR_DIALOG_CITY_TEXT 221 | |
357 | #define EDITOR_DIALOG_COUNTRY_MSG 222 | |
358 | #define EDITOR_DIALOG_COUNTRY_TEXT 223 | |
359 | #define EDITOR_DIALOG_POSTAL_MSG 224 | |
360 | #define EDITOR_DIALOG_POSTAL_TEXT 225 | |
361 | #define EDITOR_DIALOG_LANG_MSG 226 | |
362 | #define EDITOR_DIALOG_LANG_CHOICE 227 | |
363 | #define EDITOR_DIALOG_DATE_MSG 228 | |
364 | #define EDITOR_DIALOG_DATE_TEXT 229 | |
365 | #define EDITOR_DIALOG_CONTRIB_MSG 230 | |
366 | #define EDITOR_DIALOG_CONTRIB_TEXT 231 | |
367 | #define EDITOR_DIALOG_LINES_MSG 232 | |
368 | #define EDITOR_DIALOG_LINES_TEXT 233 | |
369 | #define EDITOR_DIALOG_STATE_MSG 234 | |
370 | #define EDITOR_DIALOG_STATE_TEXT 235 | |
371 | #define EDITOR_DIALOG_DEVELOPER 236 | |
372 | #define EDITOR_DIALOG_JOIN_MSG 237 | |
373 | #define EDITOR_DIALOG_JOIN_TEXT 238 | |
69a2b59d | 374 | #define EDITOR_DIALOG_CATALOG 240 |
3f030b48 GT |
375 | #define EDITOR_DIALOG_DATATYPES 250 |
376 | #define EDITOR_DIALOG_DB_DIAGS 260 | |
108106cf JS |
377 | |
378 | // *************************** CparameterDlg *************************** | |
379 | ||
1fc5dd6f | 380 | class CparameterDlg : public wxDialog |
108106cf | 381 | { |
e70e8f4c | 382 | private: |
049977d0 | 383 | // Used to indicate whether all of the widget pointers (defined |
925e9792 | 384 | // below) have been initialized to point to the memory for |
049977d0 GT |
385 | // the named widget. Used as a safeguard from using the widget |
386 | // before it has been initialized. | |
e70e8f4c | 387 | bool widgetPtrsSet; |
049977d0 | 388 | |
e70e8f4c | 389 | enum DialogModes mode; |
049977d0 | 390 | |
925e9792 | 391 | // Have the parameters been saved yet, or do they |
049977d0 | 392 | // need to be saved to update the params on disk |
e70e8f4c | 393 | bool saved; |
049977d0 GT |
394 | |
395 | // Original params | |
e70e8f4c GT |
396 | Cparameters savedParamSettings; |
397 | ||
398 | // Pointers to all widgets on the dialog | |
399 | wxStaticText *pParamODBCSourceMsg; | |
400 | wxListBox *pParamODBCSourceList; | |
401 | wxStaticText *pParamUserNameMsg, *pParamPasswordMsg, *pParamDirPathMsg; | |
402 | wxTextCtrl *pParamUserNameTxt, *pParamPasswordTxt, *pParamDirPathTxt; | |
403 | wxButton *pParamSaveBtn, *pParamCancelBtn; | |
404 | ||
405 | public: | |
406 | CparameterDlg(wxWindow *parent); | |
407 | ||
408 | void OnCloseWindow(wxCloseEvent& event); | |
409 | void OnButton( wxCommandEvent &event ); | |
410 | void OnCommand(wxWindow& win, wxCommandEvent& event); | |
411 | void OnActivate(bool) {}; // necessary for hot keys | |
412 | ||
049977d0 | 413 | // Update/Retrieve data from the widgets on the dialog |
e70e8f4c GT |
414 | bool PutData(); |
415 | bool GetData(); | |
049977d0 GT |
416 | |
417 | // Stores the defined parameter for connecting to the selected ODBC | |
418 | // data source to the config file name in "PARAM_FILENAME" | |
e70e8f4c | 419 | bool Save(); |
049977d0 GT |
420 | |
421 | // Populates the 'pParamODBCSourceList' listbox with the names of all | |
422 | // ODBC datasource defined for use at the current workstation | |
e70e8f4c | 423 | void FillDataSourceList(); |
108106cf | 424 | |
e3065973 | 425 | DECLARE_EVENT_TABLE() |
108106cf JS |
426 | }; // CparameterDlg |
427 | ||
1fc5dd6f JS |
428 | #define PARAMETER_DIALOG 400 |
429 | ||
430 | // Parameter dialog control ids | |
431 | #define PARAMETER_DIALOG_SOURCE_MSG 401 | |
432 | #define PARAMETER_DIALOG_SOURCE_LISTBOX 402 | |
433 | #define PARAMETER_DIALOG_NAME_MSG 403 | |
434 | #define PARAMETER_DIALOG_NAME_TEXT 404 | |
435 | #define PARAMETER_DIALOG_PASSWORD_MSG 405 | |
436 | #define PARAMETER_DIALOG_PASSWORD_TEXT 406 | |
e70e8f4c GT |
437 | #define PARAMETER_DIALOG_DIRPATH_MSG 407 |
438 | #define PARAMETER_DIALOG_DIRPATH_TEXT 408 | |
65d7ddc4 GT |
439 | #define PARAMETER_DIALOG_SAVE 409 |
440 | #define PARAMETER_DIALOG_CANCEL 410 | |
108106cf JS |
441 | |
442 | // *************************** CqueryDlg *************************** | |
443 | ||
444 | ||
445 | // QUERY DIALOG | |
446 | enum qryOp | |
447 | { | |
e70e8f4c GT |
448 | qryOpEQ, |
449 | qryOpLT, | |
450 | qryOpGT, | |
451 | qryOpLE, | |
452 | qryOpGE, | |
453 | qryOpBEGINS, | |
454 | qryOpCONTAINS, | |
455 | qryOpLIKE, | |
456 | qryOpBETWEEN | |
108106cf JS |
457 | }; |
458 | ||
459 | ||
460 | // Query strings | |
74de91cc JS |
461 | wxChar * const langQRY_EQ = wxT("column = column | value"); |
462 | wxChar * const langQRY_LT = wxT("column < column | value"); | |
463 | wxChar * const langQRY_GT = wxT("column > column | value"); | |
464 | wxChar * const langQRY_LE = wxT("column <= column | value"); | |
465 | wxChar * const langQRY_GE = wxT("column >= column | value"); | |
466 | wxChar * const langQRY_BEGINS = wxT("columns that BEGIN with the string entered"); | |
467 | wxChar * const langQRY_CONTAINS = wxT("columns that CONTAIN the string entered"); | |
468 | wxChar * const langQRY_LIKE = wxT("% matches 0 or more of any char; _ matches 1 char"); | |
469 | wxChar * const langQRY_BETWEEN = wxT("column BETWEEN value AND value"); | |
108106cf JS |
470 | |
471 | ||
1fc5dd6f | 472 | class CqueryDlg : public wxDialog |
108106cf | 473 | { |
e70e8f4c | 474 | private: |
049977d0 GT |
475 | wxDbColInf *colInf; // Column inf. returned by db->GetColumns() |
476 | wxDbTable *dbTable; // generic wxDbTable object for attaching to the table to query | |
477 | wxChar *masterTableName; // Name of the table that 'dbTable' will be associated with | |
d3358961 | 478 | wxString pWhere; // A pointer to the storage for the resulting where clause |
f6bcfd97 | 479 | wxDb *pDB; |
e70e8f4c GT |
480 | |
481 | public: | |
049977d0 | 482 | // Used to indicate whether all of the widget pointers (defined |
925e9792 | 483 | // below) have been initialized to point to the memory for |
049977d0 GT |
484 | // the named widget. Used as a safeguard from using the widget |
485 | // before it has been initialized. | |
e70e8f4c GT |
486 | bool widgetPtrsSet; |
487 | ||
488 | // Widget pointers | |
489 | wxStaticText *pQueryCol1Msg; | |
490 | wxChoice *pQueryCol1Choice; | |
491 | wxStaticText *pQueryNotMsg; | |
492 | wxCheckBox *pQueryNotCheck; | |
493 | wxStaticText *pQueryOperatorMsg; | |
494 | wxChoice *pQueryOperatorChoice; | |
495 | wxStaticText *pQueryCol2Msg; | |
496 | wxChoice *pQueryCol2Choice; | |
497 | wxStaticText *pQueryValue1Msg; | |
498 | wxTextCtrl *pQueryValue1Txt; | |
499 | wxStaticText *pQueryValue2Msg; | |
500 | wxTextCtrl *pQueryValue2Txt; | |
501 | wxStaticText *pQuerySqlWhereMsg; | |
502 | wxTextCtrl *pQuerySqlWhereMtxt; | |
503 | wxButton *pQueryAddBtn; | |
504 | wxButton *pQueryAndBtn; | |
505 | wxButton *pQueryOrBtn; | |
506 | wxButton *pQueryLParenBtn; | |
507 | wxButton *pQueryRParenBtn; | |
508 | wxButton *pQueryDoneBtn; | |
509 | wxButton *pQueryClearBtn; | |
510 | wxButton *pQueryCountBtn; | |
511 | wxButton *pQueryHelpBtn; | |
512 | wxStaticBox *pQueryHintGrp; | |
513 | wxStaticText *pQueryHintMsg; | |
514 | ||
3ca6a5f0 | 515 | wxTextCtrl *pFocusTxt; |
e70e8f4c | 516 | |
d3358961 | 517 | CqueryDlg(wxWindow *parent, wxDb *pDb, wxChar *tblName[], const wxString &pWhereArg); |
925e9792 | 518 | ~CqueryDlg(){}; |
e70e8f4c GT |
519 | |
520 | void OnButton( wxCommandEvent &event ); | |
521 | void OnCommand(wxWindow& win, wxCommandEvent& event); | |
522 | void OnCloseWindow(wxCloseEvent& event); | |
523 | void OnActivate(bool) {}; // necessary for hot keys | |
524 | ||
94613352 | 525 | void AppendToWhere(wxChar *s); |
e70e8f4c GT |
526 | void ProcessAddBtn(); |
527 | void ProcessCountBtn(); | |
528 | bool ValidateWhereClause(); | |
108106cf | 529 | |
f6fcbb63 | 530 | DECLARE_EVENT_TABLE() |
108106cf | 531 | }; // CqueryDlg |
1fc5dd6f JS |
532 | |
533 | #define QUERY_DIALOG 300 | |
534 | ||
535 | // Parameter dialog control ids | |
536 | #define QUERY_DIALOG_COL_MSG 301 | |
537 | #define QUERY_DIALOG_COL_CHOICE 302 | |
538 | #define QUERY_DIALOG_NOT_MSG 303 | |
539 | #define QUERY_DIALOG_NOT_CHECKBOX 304 | |
540 | #define QUERY_DIALOG_OP_MSG 305 | |
541 | #define QUERY_DIALOG_OP_CHOICE 306 | |
542 | #define QUERY_DIALOG_COL2_MSG 307 | |
543 | #define QUERY_DIALOG_COL2_CHOICE 308 | |
544 | #define QUERY_DIALOG_WHERE_MSG 309 | |
545 | #define QUERY_DIALOG_WHERE_TEXT 310 | |
546 | #define QUERY_DIALOG_ADD 311 | |
547 | #define QUERY_DIALOG_AND 312 | |
548 | #define QUERY_DIALOG_OR 313 | |
549 | #define QUERY_DIALOG_LPAREN 314 | |
550 | #define QUERY_DIALOG_RPAREN 315 | |
551 | #define QUERY_DIALOG_DONE 316 | |
552 | #define QUERY_DIALOG_CLEAR 317 | |
553 | #define QUERY_DIALOG_COUNT 318 | |
554 | #define QUERY_DIALOG_VALUE1_MSG 319 | |
555 | #define QUERY_DIALOG_VALUE1_TEXT 320 | |
556 | #define QUERY_DIALOG_VALUE2_MSG 321 | |
557 | #define QUERY_DIALOG_VALUE2_TEXT 322 | |
558 | #define QUERY_DIALOG_HINT_GROUP 323 | |
559 | #define QUERY_DIALOG_HINT_MSG 324 | |
560 | ||
74de91cc JS |
561 | wxChar * const langNO = wxT("No"); |
562 | wxChar * const langYES = wxT("Yes"); | |
563 | wxChar * const langDBINF_DB_NAME = wxT("Database Name = "); | |
564 | wxChar * const langDBINF_DB_VER = wxT("Database Version = "); | |
565 | wxChar * const langDBINF_DRIVER_NAME = wxT("Driver Name = "); | |
566 | wxChar * const langDBINF_DRIVER_ODBC_VER = wxT("Driver ODBC Version = "); | |
567 | wxChar * const langDBINF_DRIVER_MGR_ODBC_VER = wxT("Driver Manager ODBC Version = "); | |
568 | wxChar * const langDBINF_DRIVER_VER = wxT("Driver Version = "); | |
569 | wxChar * const langDBINF_SERVER_NAME = wxT("Server Name = "); | |
570 | wxChar * const langDBINF_FILENAME = wxT("Filename = "); | |
571 | wxChar * const langDBINF_OUTER_JOINS = wxT("Outer Joins = "); | |
572 | wxChar * const langDBINF_STORED_PROC = wxT("Stored Procedures = "); | |
573 | wxChar * const langDBINF_MAX_HDBC = wxT("Max # of Db connections = "); | |
574 | wxChar * const langDBINF_MAX_HSTMT = wxT("Max # of cursors (per db connection) = "); | |
925e9792 | 575 | wxChar * const langDBINF_UNLIMITED = wxT("Unlimited or Unknown"); |
74de91cc JS |
576 | wxChar * const langDBINF_API_LVL = wxT("ODBC API conformance level = "); |
577 | wxChar * const langDBINF_CLI_LVL = wxT("Client (SAG) conformance level = "); | |
578 | wxChar * const langDBINF_SQL_LVL = wxT("SQL conformance level = "); | |
579 | wxChar * const langDBINF_COMMIT_BEHAVIOR = wxT("Commit Behavior = "); | |
580 | wxChar * const langDBINF_ROLLBACK_BEHAVIOR = wxT("Rollback Behavior = "); | |
581 | wxChar * const langDBINF_SUPP_NOT_NULL = wxT("Support NOT NULL clause = "); | |
582 | wxChar * const langDBINF_SUPP_IEF = wxT("Support IEF = "); | |
583 | wxChar * const langDBINF_TXN_ISOLATION = wxT("Transaction Isolation Level (default) = "); | |
584 | wxChar * const langDBINF_TXN_ISOLATION_CURR = wxT("Transaction Isolation Level (current) = "); | |
585 | wxChar * const langDBINF_TXN_ISOLATION_OPTS = wxT("Transaction Isolation Options Available = "); | |
586 | wxChar * const langDBINF_FETCH_DIRS = wxT("Fetch Directions = "); | |
587 | wxChar * const langDBINF_LOCK_TYPES = wxT("Lock Types (SQLSetPos) = "); | |
588 | wxChar * const langDBINF_POS_OPERS = wxT("Position Operations (SQLSetPos) = "); | |
589 | wxChar * const langDBINF_POS_STMTS = wxT("Position Statements = "); | |
590 | wxChar * const langDBINF_SCROLL_CONCURR = wxT("Concurrency Options (scrollable cursors) = "); | |
591 | wxChar * const langDBINF_SCROLL_OPTS = wxT("Scroll Options (scrollable cursors) = "); | |
592 | wxChar * const langDBINF_STATIC_SENS = wxT("Static Sensitivity = "); | |
593 | wxChar * const langDBINF_TXN_CAPABLE = wxT("Transaction Support = "); | |
594 | wxChar * const langDBINF_LOGIN_TIMEOUT = wxT("Login Timeout = "); | |
595 | wxChar * const langDBINF_NONE = wxT("None"); | |
596 | wxChar * const langDBINF_LEVEL1 = wxT("Level 1"); | |
597 | wxChar * const langDBINF_LEVEL2 = wxT("Level 2"); | |
598 | wxChar * const langDBINF_NOT_COMPLIANT = wxT("Not Compliant"); | |
599 | wxChar * const langDBINF_COMPLIANT = wxT("Compliant"); | |
600 | wxChar * const langDBINF_MIN_GRAMMAR = wxT("Minimum Grammer"); | |
601 | wxChar * const langDBINF_CORE_GRAMMAR = wxT("Core Grammer"); | |
602 | wxChar * const langDBINF_EXT_GRAMMAR = wxT("Extended Grammer"); | |
603 | wxChar * const langDBINF_DELETE_CURSORS = wxT("Delete cursors"); | |
604 | wxChar * const langDBINF_CLOSE_CURSORS = wxT("Close cursors"); | |
605 | wxChar * const langDBINF_PRESERVE_CURSORS = wxT("Preserve cursors"); | |
606 | wxChar * const langDBINF_READ_UNCOMMITTED = wxT("Read Uncommitted"); | |
607 | wxChar * const langDBINF_READ_COMMITTED = wxT("Read Committed"); | |
608 | wxChar * const langDBINF_REPEATABLE_READ = wxT("Repeatable Read"); | |
609 | wxChar * const langDBINF_SERIALIZABLE = wxT("Serializable"); | |
610 | wxChar * const langDBINF_VERSIONING = wxT("Versioning"); | |
611 | wxChar * const langDBINF_NEXT = wxT("Next"); | |
612 | wxChar * const langDBINF_PREV = wxT("Prev"); | |
613 | wxChar * const langDBINF_FIRST = wxT("First"); | |
614 | wxChar * const langDBINF_LAST = wxT("Last"); | |
615 | wxChar * const langDBINF_ABSOLUTE = wxT("Absolute"); | |
616 | wxChar * const langDBINF_RELATIVE = wxT("Relative"); | |
617 | wxChar * const langDBINF_RESUME = wxT("Resume"); | |
618 | wxChar * const langDBINF_BOOKMARK = wxT("Bookmark"); | |
619 | wxChar * const langDBINF_NO_CHANGE = wxT("No Change"); | |
620 | wxChar * const langDBINF_EXCLUSIVE = wxT("Exclusive"); | |
621 | wxChar * const langDBINF_UNLOCK = wxT("Unlock"); | |
622 | wxChar * const langDBINF_POSITION = wxT("Position"); | |
623 | wxChar * const langDBINF_REFRESH = wxT("Refresh"); | |
624 | wxChar * const langDBINF_UPD = wxT("Upd"); | |
625 | wxChar * const langDBINF_DEL = wxT("Del"); | |
626 | wxChar * const langDBINF_ADD = wxT("Add"); | |
627 | wxChar * const langDBINF_POS_DEL = wxT("Pos Delete"); | |
628 | wxChar * const langDBINF_POS_UPD = wxT("Pos Update"); | |
629 | wxChar * const langDBINF_SELECT_FOR_UPD = wxT("Select For Update"); | |
630 | wxChar * const langDBINF_READ_ONLY = wxT("Read Only"); | |
631 | wxChar * const langDBINF_LOCK = wxT("Lock"); | |
632 | wxChar * const langDBINF_OPT_ROWVER = wxT("Opt. Rowver"); | |
633 | wxChar * const langDBINF_OPT_VALUES = wxT("Opt. Values"); | |
634 | wxChar * const langDBINF_FWD_ONLY = wxT("Fwd Only"); | |
635 | wxChar * const langDBINF_STATIC = wxT("Static"); | |
636 | wxChar * const langDBINF_KEYSET_DRIVEN = wxT("Keyset Driven"); | |
637 | wxChar * const langDBINF_DYNAMIC = wxT("Dynamic"); | |
638 | wxChar * const langDBINF_MIXED = wxT("Mixed"); | |
639 | wxChar * const langDBINF_ADDITIONS = wxT("Additions"); | |
640 | wxChar * const langDBINF_DELETIONS = wxT("Deletions"); | |
641 | wxChar * const langDBINF_UPDATES = wxT("Updates"); | |
642 | wxChar * const langDBINF_DML_ONLY = wxT("DML Only"); | |
643 | wxChar * const langDBINF_DDL_COMMIT = wxT("DDL Commit"); | |
644 | wxChar * const langDBINF_DDL_IGNORE = wxT("DDL Ignore"); | |
645 | wxChar * const langDBINF_DDL_AND_DML = wxT("DDL and DML"); | |
646 | wxChar * const langDBINF_ORACLE_BANNER = wxT(">>> ORACLE STATISTICS AND TUNING INFORMATION <<<"); | |
647 | wxChar * const langDBINF_DB_BLOCK_GETS = wxT("DB block gets"); | |
648 | wxChar * const langDBINF_CONSISTENT_GETS = wxT("Consistent gets"); | |
649 | wxChar * const langDBINF_PHYSICAL_READS = wxT("Physical reads"); | |
650 | wxChar * const langDBINF_CACHE_HIT_RATIO = wxT("Cache hit ratio"); | |
651 | wxChar * const langDBINF_TABLESPACE_IO = wxT("TABLESPACE I/O LEVELS"); | |
652 | wxChar * const langDBINF_PHYSICAL_WRITES = wxT("Physical writes"); |