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, 3 months ago) by tony
Content type: text/x-pascal
File size: 3317 byte(s)
Log Message:
Property Editor Fixes

File Contents

# User Rev Content
1 tony 33 (*
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 tony 80 Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
35     StdCtrls, ComCtrls, ibselectsqleditor, IBSQLEditFrame, IBLookupComboEditBox,
36     IBDynamicGrid, IBDatabase, IBCustomDataset;
37 tony 33
38     type
39    
40     { TIBModifySQLEditorForm }
41    
42 tony 80 TIBModifySQLEditorForm = class(TIBSelectSQLEditorForm)
43 tony 33 IncludePrimaryKeys: TCheckBox;
44 tony 105 Label5: TLabel;
45     ReadOnlyGrid: TIBDynamicGrid;
46 tony 33 procedure GenerateBtnClick(Sender: TObject);
47 tony 80 procedure IncludePrimaryKeysChange(Sender: TObject);
48 tony 33 private
49 tony 80
50 tony 105 protected
51     procedure Loaded; override;
52    
53 tony 33 public
54    
55 tony 80 end;
56    
57     function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
58    
59 tony 33 var
60     IBModifySQLEditorForm: TIBModifySQLEditorForm;
61    
62     implementation
63    
64     {$R *.lfm}
65    
66 tony 80 function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
67 tony 33 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 tony 80 IBSQLEditFrame1.Database := DataSet.Database;
81     GenerateParams.Checked := DataSet.GenerateParamNames;
82 tony 33 end;
83 tony 80 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 tony 33 Result := ShowModal = mrOK;
92     if Result then
93     begin
94 tony 80 SelectSQL.Assign(IBSQLEditFrame1.SQLText.Lines);
95 tony 33 if assigned(DataSet) then
96     DataSet.GenerateParamNames := GenerateParams.Checked
97     end;
98     finally
99     Free
100     end;
101     end;
102    
103     { TIBModifySQLEditorForm }
104    
105 tony 80 procedure TIBModifySQLEditorForm.IncludePrimaryKeysChange(Sender: TObject);
106 tony 33 begin
107 tony 80 IBSQLEditFrame1.IncludePrimaryKeys := IncludePrimaryKeys.Checked;
108 tony 33 end;
109    
110 tony 105 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 tony 33 procedure TIBModifySQLEditorForm.GenerateBtnClick(Sender: TObject);
121     begin
122     if PageControl.ActivePage = ExecutePage then
123 tony 80 IBSQLEditFrame1.GenerateExecuteSQL(QuoteFields.Checked)
124 tony 33 else
125 tony 105 IBSQLEditFrame1.GenerateModifySQL(QuoteFields.Checked,not IncludePrimaryKeys.Checked);
126 tony 33 end;
127    
128    
129 tony 80 end.
130 tony 33