ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/design/ibdeletesqleditor.pas
(Generate patch)

Comparing ibx/trunk/design/ibdeletesqleditor.pas (file contents):
Revision 20 by tony, Mon Jul 7 13:00:15 2014 UTC vs.
Revision 21 by tony, Thu Feb 26 10:33:34 2015 UTC

# Line 32 | Line 32 | interface
32  
33   uses
34    Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
35 <  StdCtrls, IBSystemTables, IBDatabase, IBCustomDataSet;
35 >  StdCtrls, ComCtrls, IBSystemTables, IBDatabase, IBCustomDataSet;
36  
37   type
38  
# Line 41 | Line 41 | type
41    TIBDeleteSQLEditorForm = class(TForm)
42      Button1: TButton;
43      Button2: TButton;
44 +    ExecuteOnlyIndicator: TLabel;
45      GenerateBtn: TButton;
46      GenerateParams: TCheckBox;
46    TestBtn: TButton;
47    IBTransaction1: TIBTransaction;
47      Label1: TLabel;
48 <    Label3: TLabel;
48 >    Label16: TLabel;
49 >    Label17: TLabel;
50 >    Label18: TLabel;
51      Label4: TLabel;
52 +    PageControl: TPageControl;
53      PrimaryKeyList: TListBox;
54 +    ProcedureNames: TComboBox;
55 +    ProcInputList: TListBox;
56 +    ProcOutputList: TListBox;
57 +    TableNamesCombo: TComboBox;
58 +    DeletePage: TTabSheet;
59 +    ExecutePage: TTabSheet;
60 +    TestBtn: TButton;
61 +    IBTransaction1: TIBTransaction;
62 +    Label3: TLabel;
63      QuoteFields: TCheckBox;
64      SQLText: TMemo;
65 <    TableNamesCombo: TComboBox;
65 >    procedure DeletePageShow(Sender: TObject);
66 >    procedure ExecutePageShow(Sender: TObject);
67      procedure GenerateBtnClick(Sender: TObject);
68 +    procedure ProcedureNamesCloseUp(Sender: TObject);
69      procedure TestBtnClick(Sender: TObject);
70      procedure FormShow(Sender: TObject);
71      procedure PrimaryKeyListDblClick(Sender: TObject);
# Line 74 | Line 87 | function EditSQL(DataSet: TIBCustomDataS
87  
88   implementation
89  
90 + uses IBSQL;
91 +
92   {$R *.lfm}
93  
94   function EditSQL(DataSet: TIBCustomDataSet; SelectSQL: TStrings): boolean;
# Line 109 | Line 124 | end;
124   { TIBDeleteSQLEditorForm }
125  
126   procedure TIBDeleteSQLEditorForm.FormShow(Sender: TObject);
127 < var TableName: string;
127 > var IsProcedureName: boolean;
128 >    SQLType: TIBSQLTypes;
129   begin
130    GenerateBtn.Enabled := (IBTransaction1.DefaultDatabase <> nil) and IBTransaction1.DefaultDatabase.Connected;
131    TestBtn.Enabled := (IBTransaction1.DefaultDatabase <> nil) and IBTransaction1.DefaultDatabase.Connected;
132 +  if Trim(SQLText.Text) <> '' then
133 +  begin
134 +    try
135 +      SQLType := FIBSystemTables.GetStatementType(SQLText.Text,IsProcedureName);
136 +    except  end;
137 +    if SQLType = SQLExecProcedure then
138 +      PageControl.ActivePage := ExecutePage
139 +    else
140 +      PageControl.ActivePage := DeletePage;
141 +  end
142 +  else
143 +    PageControl.ActivePage := DeletePage;
144 + end;
145 +
146 + procedure TIBDeleteSQLEditorForm.PrimaryKeyListDblClick(Sender: TObject);
147 + begin
148 +  SQLText.SelText := PrimaryKeyList.Items[PrimaryKeyList.ItemIndex];
149 +  SQLText.SetFocus
150 + end;
151 +
152 + procedure TIBDeleteSQLEditorForm.GenerateBtnClick(Sender: TObject);
153 + begin
154 +  if PageControl.ActivePage = ExecutePage then
155 +    FIBSystemTables.GenerateExecuteSQL(ProcedureNames.Text,QuoteFields.Checked,true,
156 +          ProcInputList.Items,ProcOutputList.Items,SQLText.Lines)
157 +  else
158 +    FIBSystemTables.GenerateDeleteSQL(TableNamesCombo.Text,QuoteFields.Checked,SQLText.Lines)
159 + end;
160 +
161 + procedure TIBDeleteSQLEditorForm.ProcedureNamesCloseUp(Sender: TObject);
162 + var ExecuteOnly: boolean;
163 + begin
164 +  FIBSystemTables.GetProcParams(ProcedureNames.Text,ExecuteOnly,ProcInputList.Items,ProcOutputList.Items);
165 +  ExecuteOnlyIndicator.Visible := ExecuteOnly;
166 + end;
167 +
168 + procedure TIBDeleteSQLEditorForm.DeletePageShow(Sender: TObject);
169 + var TableName: string;
170 + begin
171    TableNamesCombo.Items.Clear;
172    try
173    FIBSystemTables.GetTableNames(TableNamesCombo.Items);
# Line 129 | Line 184 | begin
184    except {ignore} end;
185   end;
186  
187 < procedure TIBDeleteSQLEditorForm.PrimaryKeyListDblClick(Sender: TObject);
187 > procedure TIBDeleteSQLEditorForm.ExecutePageShow(Sender: TObject);
188 > var ProcName: string;
189 >    IsProcedureName: boolean;
190   begin
191 <  SQLText.SelText := PrimaryKeyList.Items[PrimaryKeyList.ItemIndex];
192 <  SQLText.SetFocus
193 < end;
194 <
195 < procedure TIBDeleteSQLEditorForm.GenerateBtnClick(Sender: TObject);
196 < begin
197 <  FIBSystemTables.GenerateDeleteSQL(TableNamesCombo.Text,QuoteFields.Checked,SQLText.Lines)
191 >  FIBSystemTables.GetProcedureNames(ProcedureNames.Items,false);
192 >  if ProcedureNames.Items.Count > 0 then
193 >  begin
194 >    if (FIBSystemTables.GetStatementType(SQLText.Text,IsProcedureName) = SQLExecProcedure) or IsProcedureName then
195 >    begin
196 >      FIBSystemTables.GetTableAndColumns(SQLText.Text,ProcName,nil);
197 >      ProcedureNames.ItemIndex := ProcedureNames.Items.IndexOf(ProcName)
198 >    end
199 >    else
200 >      ProcedureNames.ItemIndex := 0;
201 >  end;
202 >  ProcedureNamesCloseUp(nil);
203   end;
204  
205   procedure TIBDeleteSQLEditorForm.TestBtnClick(Sender: TObject);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines