ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/design/ibmodifysqleditor.pas
Revision: 105
Committed: Thu Jan 18 14:37:32 2018 UTC (6 years, 10 months ago) by tony
Content type: text/x-pascal
File size: 3317 byte(s)
Log Message:
Property Editor Fixes

File Contents

# Content
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 ibmodifysqleditor;
28
29 {$mode objfpc}{$H+}
30
31 interface
32
33 uses
34 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
35 StdCtrls, ComCtrls, ibselectsqleditor, IBSQLEditFrame, IBLookupComboEditBox,
36 IBDynamicGrid, IBDatabase, IBCustomDataset;
37
38 type
39
40 { TIBModifySQLEditorForm }
41
42 TIBModifySQLEditorForm = class(TIBSelectSQLEditorForm)
43 IncludePrimaryKeys: TCheckBox;
44 Label5: TLabel;
45 ReadOnlyGrid: TIBDynamicGrid;
46 procedure GenerateBtnClick(Sender: TObject);
47 procedure IncludePrimaryKeysChange(Sender: TObject);
48 private
49
50 protected
51 procedure Loaded; override;
52
53 public
54
55 end;
56
57 function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
58
59 var
60 IBModifySQLEditorForm: TIBModifySQLEditorForm;
61
62 implementation
63
64 {$R *.lfm}
65
66 function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
67 begin
68 Result := false;
69 if assigned(DataSet) and assigned(DataSet.Database) then
70 try
71 DataSet.Database.Connected := true;
72 except on E: Exception do
73 ShowMessage(E.Message)
74 end;
75
76 with TIBModifySQLEditorForm.Create(Application) do
77 try
78 if assigned(DataSet) then
79 begin
80 IBSQLEditFrame1.Database := DataSet.Database;
81 GenerateParams.Checked := DataSet.GenerateParamNames;
82 end;
83 with IBSQLEditFrame1 do
84 begin
85 IncludePrimaryKeys := false;
86 IncludeReadOnlyFields := false;
87 ExecuteOnlyProcs := true;
88 SQLText.Lines.Assign(SelectSQL);
89 end;
90 IncludePrimaryKeys.Checked := false;
91 Result := ShowModal = mrOK;
92 if Result then
93 begin
94 SelectSQL.Assign(IBSQLEditFrame1.SQLText.Lines);
95 if assigned(DataSet) then
96 DataSet.GenerateParamNames := GenerateParams.Checked
97 end;
98 finally
99 Free
100 end;
101 end;
102
103 { TIBModifySQLEditorForm }
104
105 procedure TIBModifySQLEditorForm.IncludePrimaryKeysChange(Sender: TObject);
106 begin
107 IBSQLEditFrame1.IncludePrimaryKeys := IncludePrimaryKeys.Checked;
108 end;
109
110 procedure TIBModifySQLEditorForm.Loaded;
111 begin
112 inherited Loaded;
113 if IBSQLEditFrame1 <> nil then
114 begin
115 if ReadOnlyGrid <> nil then
116 ReadOnlyGrid.DataSource := IBSQLEditFrame1.ReadOnlyFieldsSource;
117 end;
118 end;
119
120 procedure TIBModifySQLEditorForm.GenerateBtnClick(Sender: TObject);
121 begin
122 if PageControl.ActivePage = ExecutePage then
123 IBSQLEditFrame1.GenerateExecuteSQL(QuoteFields.Checked)
124 else
125 IBSQLEditFrame1.GenerateModifySQL(QuoteFields.Checked,not IncludePrimaryKeys.Checked);
126 end;
127
128
129 end.
130