ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/design/ibmodifysqleditor.pas
Revision: 80
Committed: Mon Jan 1 11:31:07 2018 UTC (6 years, 11 months ago) by tony
Content type: text/x-pascal
File size: 2965 byte(s)
Log Message:
Fixes merged into public release

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     procedure GenerateBtnClick(Sender: TObject);
45 tony 80 procedure IncludePrimaryKeysChange(Sender: TObject);
46 tony 33 private
47 tony 80
48 tony 33 public
49    
50 tony 80 end;
51    
52     function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
53    
54 tony 33 var
55     IBModifySQLEditorForm: TIBModifySQLEditorForm;
56    
57     implementation
58    
59     {$R *.lfm}
60    
61 tony 80 function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
62 tony 33 begin
63     Result := false;
64     if assigned(DataSet) and assigned(DataSet.Database) then
65     try
66     DataSet.Database.Connected := true;
67     except on E: Exception do
68     ShowMessage(E.Message)
69     end;
70    
71     with TIBModifySQLEditorForm.Create(Application) do
72     try
73     if assigned(DataSet) then
74     begin
75 tony 80 IBSQLEditFrame1.Database := DataSet.Database;
76     GenerateParams.Checked := DataSet.GenerateParamNames;
77 tony 33 end;
78 tony 80 with IBSQLEditFrame1 do
79     begin
80     IncludePrimaryKeys := false;
81     IncludeReadOnlyFields := false;
82     ExecuteOnlyProcs := true;
83     SQLText.Lines.Assign(SelectSQL);
84     end;
85     IncludePrimaryKeys.Checked := false;
86 tony 33 Result := ShowModal = mrOK;
87     if Result then
88     begin
89 tony 80 SelectSQL.Assign(IBSQLEditFrame1.SQLText.Lines);
90 tony 33 if assigned(DataSet) then
91     DataSet.GenerateParamNames := GenerateParams.Checked
92     end;
93     finally
94     Free
95     end;
96     end;
97    
98     { TIBModifySQLEditorForm }
99    
100 tony 80 procedure TIBModifySQLEditorForm.IncludePrimaryKeysChange(Sender: TObject);
101 tony 33 begin
102 tony 80 IBSQLEditFrame1.IncludePrimaryKeys := IncludePrimaryKeys.Checked;
103 tony 33 end;
104    
105     procedure TIBModifySQLEditorForm.GenerateBtnClick(Sender: TObject);
106     begin
107     if PageControl.ActivePage = ExecutePage then
108 tony 80 IBSQLEditFrame1.GenerateExecuteSQL(QuoteFields.Checked)
109 tony 33 else
110 tony 80 IBSQLEditFrame1.GenerateModifySQL(QuoteFields.Checked);
111 tony 33 end;
112    
113    
114 tony 80 end.
115 tony 33