]>
git.saurik.com Git - wxWidgets.git/blob - samples/db/listdb.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWidgets database demo app
4 // Author: George Tasker
8 // Copyright: (c) 1996 Remstar International, Inc.
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 Contains dialog class for creating a data table lookup listbox
20 #include "wx/dbtable.h"
22 const int LOOKUP_COL_LEN
= 250;
25 class Clookup
: public wxDbTable
29 wxChar lookupCol
[LOOKUP_COL_LEN
+1];
31 Clookup(wxString tblName
, wxString colName
, wxDb
*pDb
, const wxString
&defDir
=wxT(""));
37 class Clookup2
: public wxDbTable
41 wxChar lookupCol1
[LOOKUP_COL_LEN
+1];
42 wxChar lookupCol2
[LOOKUP_COL_LEN
+1];
44 Clookup2(wxString tblName
, wxString colName1
, wxString colName2
, wxDb
*pDb
, const wxString
&defDir
=wxT(""));
50 class ClookUpDlg
: public wxDialog
60 wxListBox
*pLookUpSelectList
;
61 wxButton
*pLookUpOkBtn
;
62 wxButton
*pLookUpCancelBtn
;
66 // This is a generic lookup constructor that will work with any table and any column
67 ClookUpDlg(wxWindow
*parent
,
68 const wxString
&windowTitle
,
69 const wxString
&tableName
,
70 const wxString
&colName
,
71 const wxString
&where
,
72 const wxString
&orderBy
,
74 const wxString
&defDir
);
77 // This is a generic lookup constructor that will work with any table and any column.
78 // It extends the capabilites of the lookup dialog in the following ways:
80 // 1) 2 columns rather than one
81 // 2) The ability to select DISTINCT column values
83 // Only set distinctValues equal to true if necessary. In many cases, the constraints
84 // of the index(es) will enforce this uniqueness. Selecting DISTINCT does require
85 // overhead by the database to ensure that all values returned are distinct. Therefore,
86 // use this ONLY when you need it.
88 // For complicated queries, you can pass in the sql select statement. This would be
89 // necessary if joins are involved since by default both columns must come from the
92 // If you do query by sql statement, you must pass in the maximum length of column1,
93 // since it cannot be derived when you query using your own sql statement.
95 // The optional database connection can be used if you'd like the lookup class
96 // to use a database pointer other than the READONLY_DB of the app. This is necessary
97 // if records are being saved, but not committed to the db, yet should be included
98 // in the lookup window.
100 ClookUpDlg(wxWindow
*parent
,
101 const wxString
&windowTitle
,
102 const wxString
&tableName
,
103 const wxString
&dispCol1
, // Must have at least 1 display column
104 const wxString
&dispCol2
, // Optional
105 const wxString
&where
,
106 const wxString
&orderBy
,
107 wxDb
*pDb
, // Database connection pointer
108 const wxString
&defDir
,
109 bool distinctValues
, // e.g. SELECT DISTINCT ...
110 const wxString
&selectStmt
= wxEmptyString
, // If you wish to query by SQLstmt (complicated lookups)
111 int maxLenCol1
= 0, // Mandatory if querying by SQLstmt
112 bool allowOk
= true); // is the OK button enabled
114 void OnButton(wxCommandEvent
&event
);
115 void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
116 void OnClose(wxCloseEvent
& event
);
117 void OnActivate(bool) {}; // necessary for hot keys
118 void OnDClick(wxCommandEvent
&event
);
120 DECLARE_EVENT_TABLE()
121 }; // class ClookUpDlg
123 #define LOOKUP_DIALOG 500
125 #define LOOKUP_DIALOG_SELECT 501
126 #define LOOKUP_DIALOG_OK 502
127 #define LOOKUP_DIALOG_CANCEL 503
129 #endif // LISTDB_DOT_H
131 // ************************************ listdb.h *********************************