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