1 |
< |
(* |
2 |
< |
* IBX For Lazarus (Firebird Express) |
3 |
< |
* |
4 |
< |
* The contents of this file are subject to the Initial Developer's |
5 |
< |
* Public License Version 1.0 (the "License"); you may not use this |
6 |
< |
* file except in compliance with the License. You may obtain a copy |
7 |
< |
* of the License here: |
8 |
< |
* |
9 |
< |
* http://www.firebirdsql.org/index.php?op=doc&id=idpl |
10 |
< |
* |
11 |
< |
* Software distributed under the License is distributed on an "AS |
12 |
< |
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
13 |
< |
* implied. See the License for the specific language governing rights |
14 |
< |
* and limitations under the License. |
15 |
< |
* |
16 |
< |
* The Initial Developer of the Original Code is Tony Whyman. |
17 |
< |
* |
18 |
< |
* The Original Code is (C) 2011 Tony Whyman, MWA Software |
19 |
< |
* (http://www.mwasoftware.co.uk). |
20 |
< |
* |
21 |
< |
* All Rights Reserved. |
22 |
< |
* |
23 |
< |
* Contributor(s): ______________________________________. |
24 |
< |
* |
25 |
< |
*) |
26 |
< |
unit IBUpdateSQLEditor; |
27 |
< |
|
28 |
< |
{$mode objfpc}{$H+} |
29 |
< |
|
30 |
< |
interface |
31 |
< |
|
32 |
< |
uses |
33 |
< |
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, |
34 |
< |
ComCtrls, StdCtrls, ExtCtrls, IBSystemTables, IBUpdateSQL, IBDatabase; |
35 |
< |
|
36 |
< |
type |
37 |
< |
|
38 |
< |
{ TIBUpdateSQLEditorForm } |
39 |
< |
|
40 |
< |
TIBUpdateSQLEditorForm = class(TForm) |
41 |
< |
GenerateParams: TCheckBox; |
42 |
< |
TestBtn: TButton; |
43 |
< |
CancelButton: TButton; |
44 |
< |
FieldsPage: TTabSheet; |
45 |
< |
GenerateBtn: TButton; |
46 |
< |
GroupBox1: TGroupBox; |
47 |
< |
IBTransaction1: TIBTransaction; |
48 |
< |
IncludePrimaryKeys: TCheckBox; |
49 |
< |
PrimaryKeyList: TListBox; |
50 |
< |
Label1: TLabel; |
51 |
< |
Label2: TLabel; |
52 |
< |
Label3: TLabel; |
53 |
< |
Label4: TLabel; |
54 |
< |
OkButton: TButton; |
55 |
< |
PageControl: TPageControl; |
56 |
< |
QuoteFields: TCheckBox; |
57 |
< |
SQLMemo: TMemo; |
58 |
< |
SQLPage: TTabSheet; |
59 |
< |
StatementType: TRadioGroup; |
60 |
< |
FieldList: TListBox; |
61 |
< |
TableNamesCombo: TComboBox; |
62 |
< |
procedure TestBtnClick(Sender: TObject); |
63 |
< |
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
64 |
< |
procedure FormShow(Sender: TObject); |
65 |
< |
procedure GenerateBtnClick(Sender: TObject); |
66 |
< |
procedure SQLMemoChange(Sender: TObject); |
67 |
< |
procedure SQLPageShow(Sender: TObject); |
68 |
< |
procedure StatementTypeClick(Sender: TObject); |
69 |
< |
procedure TableNamesComboCloseUp(Sender: TObject); |
70 |
< |
private |
71 |
< |
{ private declarations } |
72 |
< |
FUpdateObject: TIBUpdateSQL; |
73 |
< |
FIBSystemTables: TIBSystemTables; |
74 |
< |
FDirty: boolean; |
75 |
< |
FCurrentStatement: integer; |
76 |
< |
FModifySQL: TStringList; |
77 |
< |
FInsertSQL: TStringList; |
78 |
< |
FDeleteSQL: TStringList; |
79 |
< |
FRefreshSQL: TStringList; |
80 |
< |
procedure UpdateSQLMemo; |
81 |
< |
public |
82 |
< |
{ public declarations } |
83 |
< |
constructor Create(TheOwner: TComponent); override; |
84 |
< |
destructor Destroy; override; |
85 |
< |
procedure SetUpdateObject(AObject: TIBUpdateSQL); |
86 |
< |
end; |
87 |
< |
|
88 |
< |
var |
89 |
< |
IBUpdateSQLEditorForm: TIBUpdateSQLEditorForm; |
90 |
< |
|
91 |
< |
function EditIBUpdateSQL(UpdateObject: TIBUpdateSQL): boolean; |
92 |
< |
|
93 |
< |
implementation |
94 |
< |
|
95 |
< |
uses IBQuery; |
96 |
< |
|
97 |
< |
{$R *.lfm} |
98 |
< |
|
99 |
< |
function EditIBUpdateSQL(UpdateObject: TIBUpdateSQL): boolean; |
100 |
< |
begin |
101 |
< |
Result := false; |
102 |
< |
if assigned(UpdateObject.DataSet) and assigned(UpdateObject.DataSet.Database) then |
103 |
< |
try |
104 |
< |
UpdateObject.DataSet.Database.Connected := true; |
105 |
< |
except on E: Exception do |
106 |
< |
ShowMessage(E.Message) |
107 |
< |
end; |
108 |
< |
|
109 |
< |
with TIBUpdateSQLEditorForm.Create(Application) do |
110 |
< |
try |
111 |
< |
SetUpdateObject(UpdateObject); |
112 |
< |
if assigned(UpdateObject.DataSet) then |
113 |
< |
GenerateParams.Checked := UpdateObject.DataSet.GenerateParamNames; |
114 |
< |
Result := ShowModal = mrOK; |
115 |
< |
if Result and assigned(UpdateObject.DataSet) then |
116 |
< |
UpdateObject.DataSet.GenerateParamNames := GenerateParams.Checked |
117 |
< |
finally |
118 |
< |
Free |
119 |
< |
end; |
120 |
< |
|
121 |
< |
end; |
122 |
< |
|
123 |
< |
{ TIBUpdateSQLEditorForm } |
124 |
< |
|
125 |
< |
procedure TIBUpdateSQLEditorForm.FormShow(Sender: TObject); |
126 |
< |
var TableName: string; |
127 |
< |
begin |
128 |
< |
GenerateBtn.Enabled := (IBTransaction1.DefaultDatabase <> nil) and IBTransaction1.DefaultDatabase.Connected; |
129 |
< |
TestBtn.Enabled := (IBTransaction1.DefaultDatabase <> nil) and IBTransaction1.DefaultDatabase.Connected; |
130 |
< |
PageControl.ActivePage := FieldsPage; |
131 |
< |
FModifySQL.Assign(FUpdateObject.ModifySQL); |
132 |
< |
FInsertSQL.Assign(FUpdateObject.InsertSQL); |
133 |
< |
FDeleteSQL.Assign(FUpdateObject.DeleteSQL); |
134 |
< |
FRefreshSQL.Assign(FUpdateObject.RefreshSQL); |
135 |
< |
FCurrentStatement := -1; |
136 |
< |
TableNamesCombo.Items.Clear; |
137 |
< |
FIBSystemTables.GetTableNames(TableNamesCombo.Items); |
138 |
< |
if TableNamesCombo.Items.Count > 0 then |
139 |
< |
begin |
140 |
< |
TableNamesCombo.ItemIndex := 0; |
141 |
< |
if assigned(FUpdateObject.DataSet) and (FUpdateObject.DataSet is TIBQuery) and |
142 |
< |
((FUpdateObject.DataSet as TIBQuery).SQL.Text <> '') then |
143 |
< |
try |
144 |
< |
FIBSystemTables.GetTableAndColumns((FUpdateObject.DataSet as TIBQuery).SQL.Text,TableName,nil); |
145 |
< |
TableNamesCombo.ItemIndex := TableNamesCombo.Items.IndexOf(TableName); |
146 |
< |
except //ignore |
147 |
< |
end; |
148 |
< |
FIBSystemTables.GetFieldNames(TableNamesCombo.Text,FieldList.Items,IncludePrimaryKeys.checked,false); |
149 |
< |
FIBSystemTables.GetPrimaryKeys(TableNamesCombo.Text,PrimaryKeyList.Items); |
150 |
< |
end; |
151 |
< |
end; |
152 |
< |
|
153 |
< |
procedure TIBUpdateSQLEditorForm.FormClose(Sender: TObject; |
154 |
< |
var CloseAction: TCloseAction); |
155 |
< |
begin |
156 |
< |
if ModalResult = mrOK then |
157 |
< |
begin |
158 |
< |
UpdateSQLMemo; |
159 |
< |
FUpdateObject.ModifySQL.Assign(FModifySQL); |
160 |
< |
FUpdateObject.InsertSQL.Assign(FInsertSQL); |
161 |
< |
FUpdateObject.DeleteSQL.Assign(FDeleteSQL); |
162 |
< |
FUpdateObject.RefreshSQL.Assign(FRefreshSQL); |
163 |
< |
end; |
164 |
< |
end; |
165 |
< |
|
166 |
< |
procedure TIBUpdateSQLEditorForm.TestBtnClick(Sender: TObject); |
167 |
< |
begin |
168 |
< |
if SQLMemo.Lines.Text <> '' then |
169 |
< |
FIBSystemTables.TestSQL(SQLMemo.Lines.Text,GenerateParams.Checked); |
170 |
< |
end; |
171 |
< |
|
172 |
< |
procedure TIBUpdateSQLEditorForm.GenerateBtnClick(Sender: TObject); |
173 |
< |
var FieldNames: TStringList; |
174 |
< |
I: integer; |
175 |
< |
begin |
176 |
< |
FieldNames := TStringList.Create; |
177 |
< |
try |
178 |
< |
FUpdateObject.RefreshSQL.Clear; |
179 |
< |
FIBSystemTables.GetFieldNames(TableNamesCombo.Text,FieldNames); |
180 |
< |
FIBSystemTables.GenerateRefreshSQL(TableNamesCombo.Text,QuoteFields.Checked,FieldNames,FRefreshSQL); |
181 |
< |
FIBSystemTables.GenerateDeleteSQL(TableNamesCombo.Text,QuoteFields.Checked,FDeleteSQL); |
182 |
< |
FieldNames.Clear; |
183 |
< |
FIBSystemTables.GetFieldNames(TableNamesCombo.Text,FieldNames,true,false); |
184 |
< |
FIBSystemTables.GenerateInsertSQL(TableNamesCombo.Text,QuoteFields.Checked, |
185 |
< |
FieldNames,FInsertSQL); |
186 |
< |
if FieldList.SelCount = 0 then |
187 |
< |
begin |
188 |
< |
FIBSystemTables.GenerateModifySQL(TableNamesCombo.Text,QuoteFields.Checked, |
189 |
< |
FieldList.Items,FModifySQL); |
190 |
< |
|
191 |
< |
end |
192 |
< |
else |
193 |
< |
begin |
194 |
< |
FieldNames.Clear; |
195 |
< |
for I := 0 to FieldList.Items.Count - 1 do |
196 |
< |
if FieldList.Selected[I] then |
197 |
< |
FieldNames.Add(FieldList.Items[I]); |
198 |
< |
FIBSystemTables.GenerateModifySQL(TableNamesCombo.Text,QuoteFields.Checked, |
199 |
< |
FieldNames,FModifySQL); |
200 |
< |
end; |
201 |
< |
FDirty := false; |
202 |
< |
PageControl.ActivePage := SQLPage; |
203 |
< |
finally |
204 |
< |
FieldNames.Free |
205 |
< |
end; |
206 |
< |
end; |
207 |
< |
|
208 |
< |
procedure TIBUpdateSQLEditorForm.SQLMemoChange(Sender: TObject); |
209 |
< |
begin |
210 |
< |
FDirty := true |
211 |
< |
end; |
212 |
< |
|
213 |
< |
procedure TIBUpdateSQLEditorForm.SQLPageShow(Sender: TObject); |
214 |
< |
begin |
215 |
< |
UpdateSQLMemo |
216 |
< |
end; |
217 |
< |
|
218 |
< |
procedure TIBUpdateSQLEditorForm.StatementTypeClick(Sender: TObject); |
219 |
< |
begin |
220 |
< |
UpdateSQLMemo |
221 |
< |
end; |
222 |
< |
|
223 |
< |
procedure TIBUpdateSQLEditorForm.TableNamesComboCloseUp(Sender: TObject); |
224 |
< |
begin |
225 |
< |
FIBSystemTables.GetFieldNames(TableNamesCombo.Text,FieldList.Items,IncludePrimaryKeys.checked,false); |
226 |
< |
FIBSystemTables.GetPrimaryKeys(TableNamesCombo.Text,PrimaryKeyList.Items); |
227 |
< |
end; |
228 |
< |
|
229 |
< |
procedure TIBUpdateSQLEditorForm.UpdateSQLMemo; |
230 |
< |
begin |
231 |
< |
if FDirty then |
232 |
< |
case FCurrentStatement of |
233 |
< |
0: //Modify |
234 |
< |
FModifySQL.Assign(SQLMemo.Lines); |
235 |
< |
1: //Insert |
236 |
< |
FInsertSQL.Assign(SQLMemo.Lines); |
237 |
< |
2: // Delete |
238 |
< |
FDeleteSQL.Assign(SQLMemo.Lines); |
239 |
< |
3: //Refresh |
240 |
< |
FRefreshSQL.Assign(SQLMemo.Lines); |
241 |
< |
end; |
242 |
< |
FDirty := false; |
243 |
< |
case StatementType.ItemIndex of |
244 |
< |
0: // Modify |
245 |
< |
SQLMemo.Lines.Assign(FModifySQL) ; |
246 |
< |
1: //Insert |
247 |
< |
SQLMemo.Lines.Assign(FInsertSQL) ; |
248 |
< |
2: // Delete |
249 |
< |
SQLMemo.Lines.Assign(FDeleteSQL) ; |
250 |
< |
3: //Refresh |
251 |
< |
SQLMemo.Lines.Assign(FRefreshSQL) ; |
252 |
< |
end; |
253 |
< |
FCurrentStatement := StatementType.ItemIndex; |
254 |
< |
end; |
255 |
< |
|
256 |
< |
constructor TIBUpdateSQLEditorForm.Create(TheOwner: TComponent); |
257 |
< |
begin |
258 |
< |
inherited Create(TheOwner); |
259 |
< |
FIBSystemTables := TIBSystemTables.Create; |
260 |
< |
FModifySQL := TStringList.Create; |
261 |
< |
FInsertSQL := TStringList.Create; |
262 |
< |
FDeleteSQL := TStringList.Create; |
263 |
< |
FRefreshSQL := TStringList.Create; |
264 |
< |
end; |
265 |
< |
|
266 |
< |
destructor TIBUpdateSQLEditorForm.Destroy; |
267 |
< |
begin |
268 |
< |
if assigned(FIBSystemTables) then FIBSystemTables.Free; |
269 |
< |
if assigned(FModifySQL) then FModifySQL.Free; |
270 |
< |
if assigned(FInsertSQL) then FInsertSQL.Free; |
271 |
< |
if assigned(FDeleteSQL) then FDeleteSQL.Free; |
272 |
< |
if assigned(FRefreshSQL) then FRefreshSQL.Free; |
273 |
< |
inherited Destroy; |
274 |
< |
end; |
275 |
< |
|
276 |
< |
procedure TIBUpdateSQLEditorForm.SetUpdateObject(AObject: TIBUpdateSQL); |
277 |
< |
begin |
278 |
< |
FUpdateObject := AObject; |
279 |
< |
if assigned(FUpdateObject.DataSet) then |
280 |
< |
begin |
281 |
< |
IBTransaction1.DefaultDatabase := FUpdateObject.DataSet.Database; |
282 |
< |
FIBSystemTables.SelectDatabase(FUpdateObject.DataSet.Database,IBTransaction1); |
283 |
< |
end; |
284 |
< |
end; |
285 |
< |
|
286 |
< |
|
287 |
< |
end. |
288 |
< |
|
1 |
> |
(* |
2 |
> |
* IBX For Lazarus (Firebird Express) |
3 |
> |
* |
4 |
> |
* The contents of this file are subject to the Initial Developer's |
5 |
> |
* Public License Version 1.0 (the "License"); you may not use this |
6 |
> |
* file except in compliance with the License. You may obtain a copy |
7 |
> |
* of the License here: |
8 |
> |
* |
9 |
> |
* http://www.firebirdsql.org/index.php?op=doc&id=idpl |
10 |
> |
* |
11 |
> |
* Software distributed under the License is distributed on an "AS |
12 |
> |
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
13 |
> |
* implied. See the License for the specific language governing rights |
14 |
> |
* and limitations under the License. |
15 |
> |
* |
16 |
> |
* The Initial Developer of the Original Code is Tony Whyman. |
17 |
> |
* |
18 |
> |
* The Original Code is (C) 2011-17 Tony Whyman, MWA Software |
19 |
> |
* (http://www.mwasoftware.co.uk). |
20 |
> |
* |
21 |
> |
* All Rights Reserved. |
22 |
> |
* |
23 |
> |
* Contributor(s): ______________________________________. |
24 |
> |
* |
25 |
> |
*) |
26 |
> |
|
27 |
> |
unit ibupdatesqleditor; |
28 |
> |
|
29 |
> |
{$mode objfpc}{$H+} |
30 |
> |
|
31 |
> |
interface |
32 |
> |
|
33 |
> |
uses |
34 |
> |
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, |
35 |
> |
StdCtrls, ExtCtrls, IBSQLEditFrame, IBCustomDataSet, |
36 |
> |
IBDatabase, IBLookupComboEditBox, IBDynamicGrid, Types, IBUpdateSQL; |
37 |
> |
|
38 |
> |
type |
39 |
> |
|
40 |
> |
{ TIBUpdateSQLEditorForm } |
41 |
> |
|
42 |
> |
TIBUpdateSQLEditorForm = class(TForm) |
43 |
> |
FieldNamesGrid: TIBDynamicGrid; |
44 |
> |
GenerateParams: TCheckBox; |
45 |
> |
IBSQLEditFrame1: TIBSQLEditFrame; |
46 |
> |
IncludeSysTables: TCheckBox; |
47 |
> |
PrimaryKeysGrid: TIBDynamicGrid; |
48 |
> |
SelectSelectAll: TCheckBox; |
49 |
> |
SelectTableNames: TIBLookupComboEditBox; |
50 |
> |
TestBtn: TButton; |
51 |
> |
CancelButton: TButton; |
52 |
> |
FieldsPage: TTabSheet; |
53 |
> |
GenerateButton: TButton; |
54 |
> |
GroupBox1: TGroupBox; |
55 |
> |
IncludePrimaryKeys: TCheckBox; |
56 |
> |
Label1: TLabel; |
57 |
> |
Label2: TLabel; |
58 |
> |
Label3: TLabel; |
59 |
> |
Label4: TLabel; |
60 |
> |
OkButton: TButton; |
61 |
> |
PageControl: TPageControl; |
62 |
> |
QuoteFields: TCheckBox; |
63 |
> |
SQLPage: TTabSheet; |
64 |
> |
StatementType: TRadioGroup; |
65 |
> |
procedure IncludeSysTablesChange(Sender: TObject); |
66 |
> |
procedure SelectSelectAllClick(Sender: TObject); |
67 |
> |
procedure TestBtnClick(Sender: TObject); |
68 |
> |
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
69 |
> |
procedure FormShow(Sender: TObject); |
70 |
> |
procedure GenerateButtonClick(Sender: TObject); |
71 |
> |
procedure SQLMemoChange(Sender: TObject); |
72 |
> |
procedure SQLPageShow(Sender: TObject); |
73 |
> |
procedure StatementTypeClick(Sender: TObject); |
74 |
> |
private |
75 |
> |
{ private declarations } |
76 |
> |
FUpdateObject: TIBUpdateSQL; |
77 |
> |
FDirty: boolean; |
78 |
> |
FCurrentStatement: integer; |
79 |
> |
FModifySQL: TStringList; |
80 |
> |
FInsertSQL: TStringList; |
81 |
> |
FDeleteSQL: TStringList; |
82 |
> |
FRefreshSQL: TStringList; |
83 |
> |
procedure UpdateSQLMemo; |
84 |
> |
procedure HandleUserTablesOpened(Sender: TObject); |
85 |
> |
protected |
86 |
> |
procedure Loaded; override; |
87 |
> |
public |
88 |
> |
{ public declarations } |
89 |
> |
constructor Create(TheOwner: TComponent); override; |
90 |
> |
destructor Destroy; override; |
91 |
> |
end; |
92 |
> |
|
93 |
> |
var |
94 |
> |
IBUpdateSQLEditorForm: TIBUpdateSQLEditorForm; |
95 |
> |
|
96 |
> |
function EditIBUpdateSQL(UpdateObject: TIBUpdateSQL): boolean; |
97 |
> |
|
98 |
> |
implementation |
99 |
> |
|
100 |
> |
{$R *.lfm} |
101 |
> |
|
102 |
> |
function EditIBUpdateSQL(UpdateObject: TIBUpdateSQL): boolean; |
103 |
> |
begin |
104 |
> |
Result := false; |
105 |
> |
if assigned(UpdateObject) and assigned(UpdateObject.DataSet) and assigned(UpdateObject.DataSet.Database) then |
106 |
> |
try |
107 |
> |
UpdateObject.DataSet.Database.Connected := true; |
108 |
> |
except on E: Exception do |
109 |
> |
ShowMessage(E.Message) |
110 |
> |
end; |
111 |
> |
|
112 |
> |
with TIBUpdateSQLEditorForm.Create(Application) do |
113 |
> |
try |
114 |
> |
if assigned(UpdateObject) and assigned(UpdateObject.DataSet) then |
115 |
> |
begin |
116 |
> |
IBSQLEditFrame1.Database := UpdateObject.DataSet.Database; |
117 |
> |
GenerateParams.Checked := UpdateObject.DataSet.GenerateParamNames; |
118 |
> |
end; |
119 |
> |
FUpdateObject := UpdateObject; |
120 |
> |
Result := ShowModal = mrOK; |
121 |
> |
if Result then |
122 |
> |
UpdateObject.DataSet.GenerateParamNames := GenerateParams.Checked |
123 |
> |
finally |
124 |
> |
Free |
125 |
> |
end; |
126 |
> |
|
127 |
> |
end; |
128 |
> |
|
129 |
> |
{ TIBUpdateSQLEditorForm } |
130 |
> |
|
131 |
> |
procedure TIBUpdateSQLEditorForm.FormShow(Sender: TObject); |
132 |
> |
var TableName: string; |
133 |
> |
begin |
134 |
> |
PageControl.ActivePage := FieldsPage; |
135 |
> |
FModifySQL.Assign(FUpdateObject.ModifySQL); |
136 |
> |
FInsertSQL.Assign(FUpdateObject.InsertSQL); |
137 |
> |
FDeleteSQL.Assign(FUpdateObject.DeleteSQL); |
138 |
> |
FRefreshSQL.Assign(FUpdateObject.RefreshSQL); |
139 |
> |
GenerateButton.Enabled := (IBSQLEditFrame1.Database <> nil) and IBSQLEditFrame1.Database.Connected; |
140 |
> |
TestBtn.Enabled := (IBSQLEditFrame1.Database <> nil) and IBSQLEditFrame1.Database.Connected; |
141 |
> |
FCurrentStatement := -1; |
142 |
> |
IBSQLEditFrame1.UserTables.Active := true; |
143 |
> |
IBSQLEditFrame1.SyncQueryBuilder(FRefreshSQL); |
144 |
> |
end; |
145 |
> |
|
146 |
> |
procedure TIBUpdateSQLEditorForm.FormClose(Sender: TObject; |
147 |
> |
var CloseAction: TCloseAction); |
148 |
> |
begin |
149 |
> |
if ModalResult = mrOK then |
150 |
> |
begin |
151 |
> |
UpdateSQLMemo; |
152 |
> |
FUpdateObject.ModifySQL.Assign(FModifySQL); |
153 |
> |
FUpdateObject.InsertSQL.Assign(FInsertSQL); |
154 |
> |
FUpdateObject.DeleteSQL.Assign(FDeleteSQL); |
155 |
> |
FUpdateObject.RefreshSQL.Assign(FRefreshSQL); |
156 |
> |
end; |
157 |
> |
end; |
158 |
> |
|
159 |
> |
procedure TIBUpdateSQLEditorForm.TestBtnClick(Sender: TObject); |
160 |
> |
begin |
161 |
> |
IBSQLEditFrame1.TestSQL(GenerateParams.Checked); |
162 |
> |
end; |
163 |
> |
|
164 |
> |
procedure TIBUpdateSQLEditorForm.IncludeSysTablesChange(Sender: TObject); |
165 |
> |
begin |
166 |
> |
IBSQLEditFrame1.IncludeSystemTables := IncludeSysTables.Checked; |
167 |
> |
end; |
168 |
> |
|
169 |
> |
procedure TIBUpdateSQLEditorForm.SelectSelectAllClick(Sender: TObject); |
170 |
> |
begin |
171 |
> |
IBSQLEditFrame1.SelectAllFields(SelectSelectAll.Checked); |
172 |
> |
end; |
173 |
> |
|
174 |
> |
procedure TIBUpdateSQLEditorForm.GenerateButtonClick(Sender: TObject); |
175 |
> |
begin |
176 |
> |
IBSQLEditFrame1.GenerateRefreshSQL(QuoteFields.Checked,FRefreshSQL); |
177 |
> |
IBSQLEditFrame1.GenerateDeleteSQL(QuoteFields.Checked,FDeleteSQL); |
178 |
> |
IBSQLEditFrame1.GenerateInsertSQL(QuoteFields.Checked,FInsertSQL); |
179 |
> |
IBSQLEditFrame1.GenerateModifySQL(QuoteFields.Checked,FModifySQL, not IncludePrimaryKeys.Checked); |
180 |
> |
FDirty := false; |
181 |
> |
PageControl.ActivePage := SQLPage; |
182 |
> |
end; |
183 |
> |
|
184 |
> |
procedure TIBUpdateSQLEditorForm.SQLMemoChange(Sender: TObject); |
185 |
> |
begin |
186 |
> |
FDirty := true |
187 |
> |
end; |
188 |
> |
|
189 |
> |
procedure TIBUpdateSQLEditorForm.SQLPageShow(Sender: TObject); |
190 |
> |
begin |
191 |
> |
UpdateSQLMemo |
192 |
> |
end; |
193 |
> |
|
194 |
> |
procedure TIBUpdateSQLEditorForm.StatementTypeClick(Sender: TObject); |
195 |
> |
begin |
196 |
> |
UpdateSQLMemo |
197 |
> |
end; |
198 |
> |
|
199 |
> |
procedure TIBUpdateSQLEditorForm.UpdateSQLMemo; |
200 |
> |
begin |
201 |
> |
if FDirty then |
202 |
> |
case FCurrentStatement of |
203 |
> |
0: //Modify |
204 |
> |
FModifySQL.Assign(IBSQLEditFrame1.SQLText.Lines); |
205 |
> |
1: //Insert |
206 |
> |
FInsertSQL.Assign(IBSQLEditFrame1.SQLText.Lines); |
207 |
> |
2: // Delete |
208 |
> |
FDeleteSQL.Assign(IBSQLEditFrame1.SQLText.Lines); |
209 |
> |
3: //Refresh |
210 |
> |
FRefreshSQL.Assign(IBSQLEditFrame1.SQLText.Lines); |
211 |
> |
end; |
212 |
> |
FDirty := false; |
213 |
> |
case StatementType.ItemIndex of |
214 |
> |
0: // Modify |
215 |
> |
IBSQLEditFrame1.SQLText.Lines.Assign(FModifySQL) ; |
216 |
> |
1: //Insert |
217 |
> |
IBSQLEditFrame1.SQLText.Lines.Assign(FInsertSQL) ; |
218 |
> |
2: // Delete |
219 |
> |
IBSQLEditFrame1.SQLText.Lines.Assign(FDeleteSQL) ; |
220 |
> |
3: //Refresh |
221 |
> |
IBSQLEditFrame1.SQLText.Lines.Assign(FRefreshSQL) ; |
222 |
> |
end; |
223 |
> |
FCurrentStatement := StatementType.ItemIndex; |
224 |
> |
end; |
225 |
> |
|
226 |
> |
procedure TIBUpdateSQLEditorForm.HandleUserTablesOpened(Sender: TObject); |
227 |
> |
begin |
228 |
> |
SelectSelectAll.Checked := true; |
229 |
> |
end; |
230 |
> |
|
231 |
> |
procedure TIBUpdateSQLEditorForm.Loaded; |
232 |
> |
begin |
233 |
> |
inherited Loaded; |
234 |
> |
if IBSQLEditFrame1 <> nil then |
235 |
> |
begin |
236 |
> |
IBSQLEditFrame1.OnUserTablesOpened := @HandleUserTablesOpened; |
237 |
> |
if SelectTableNames <> nil then |
238 |
> |
SelectTableNames.ListSource := IBSQLEditFrame1.UserTableSource; |
239 |
> |
if FieldNamesGrid <> nil then |
240 |
> |
FieldNamesGrid.DataSource := IBSQLEditFrame1.FieldsSource; |
241 |
> |
if PrimaryKeysGrid <> nil then |
242 |
> |
PrimaryKeysGrid.DataSource := IBSQLEditFrame1.PrimaryKeySource; |
243 |
> |
end; |
244 |
> |
end; |
245 |
> |
|
246 |
> |
constructor TIBUpdateSQLEditorForm.Create(TheOwner: TComponent); |
247 |
> |
begin |
248 |
> |
inherited Create(TheOwner); |
249 |
> |
FModifySQL := TStringList.Create; |
250 |
> |
FInsertSQL := TStringList.Create; |
251 |
> |
FDeleteSQL := TStringList.Create; |
252 |
> |
FRefreshSQL := TStringList.Create; |
253 |
> |
end; |
254 |
> |
|
255 |
> |
destructor TIBUpdateSQLEditorForm.Destroy; |
256 |
> |
begin |
257 |
> |
if assigned(FModifySQL) then FModifySQL.Free; |
258 |
> |
if assigned(FInsertSQL) then FInsertSQL.Free; |
259 |
> |
if assigned(FDeleteSQL) then FDeleteSQL.Free; |
260 |
> |
if assigned(FRefreshSQL) then FRefreshSQL.Free; |
261 |
> |
inherited Destroy; |
262 |
> |
end; |
263 |
> |
|
264 |
> |
end. |