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 |
|
27 |
unit ibrefreshsqleditor; |
28 |
|
29 |
{$mode objfpc}{$H+} |
30 |
|
31 |
interface |
32 |
|
33 |
uses |
34 |
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, |
35 |
ibselectsqleditor, IBDatabase, IBCustomDataset; |
36 |
|
37 |
type |
38 |
|
39 |
{ TIBRefreshSQLEditorForm } |
40 |
|
41 |
TIBRefreshSQLEditorForm = class(TIBSelectSQLEditorForm) |
42 |
procedure GenerateBtnClick(Sender: TObject); |
43 |
private |
44 |
|
45 |
public |
46 |
|
47 |
end; |
48 |
|
49 |
var |
50 |
IBRefreshSQLEditorForm: TIBRefreshSQLEditorForm; |
51 |
|
52 |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
53 |
|
54 |
implementation |
55 |
|
56 |
{$R *.lfm} |
57 |
|
58 |
function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean; |
59 |
begin |
60 |
Result := false; |
61 |
if assigned(DataSet) and assigned(DataSet.Database) then |
62 |
try |
63 |
DataSet.Database.Connected := true; |
64 |
except on E: Exception do |
65 |
ShowMessage(E.Message) |
66 |
end; |
67 |
|
68 |
with TIBRefreshSQLEditorForm.Create(Application) do |
69 |
try |
70 |
if assigned(DataSet) then |
71 |
begin |
72 |
IBSQLEditFrame1.Database := DataSet.Database; |
73 |
GenerateParams.Checked := DataSet.GenerateParamNames; |
74 |
end; |
75 |
IBSQLEditFrame1.SQLText.Lines.Assign(SelectSQL); |
76 |
Result := ShowModal = mrOK; |
77 |
if Result then |
78 |
begin |
79 |
SelectSQL.Assign(IBSQLEditFrame1.SQLText.Lines); |
80 |
if assigned(DataSet) then |
81 |
DataSet.GenerateParamNames := GenerateParams.Checked |
82 |
end; |
83 |
finally |
84 |
Free |
85 |
end; |
86 |
end; |
87 |
|
88 |
{ TIBRefreshSQLEditorForm } |
89 |
|
90 |
procedure TIBRefreshSQLEditorForm.GenerateBtnClick(Sender: TObject); |
91 |
begin |
92 |
IBSQLEditFrame1.GenerateRefreshSQL(QuoteFields.Checked); |
93 |
end; |
94 |
|
95 |
|
96 |
end. |
97 |
|