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) 2015 Tony Whyman, MWA Software |
19 |
+ |
* (http://www.mwasoftware.co.uk). |
20 |
+ |
* |
21 |
+ |
* All Rights Reserved. |
22 |
+ |
* |
23 |
+ |
* Contributor(s): ______________________________________. |
24 |
+ |
* |
25 |
+ |
*) |
26 |
+ |
|
27 |
|
unit Unit1; |
28 |
|
|
29 |
|
{$mode objfpc}{$H+} |
52 |
|
DBEdit2: TDBEdit; |
53 |
|
DBEdit3: TDBEdit; |
54 |
|
DBEdit4: TDBEdit; |
55 |
< |
DepartmentsCHILDCOUNT: TIntegerField; |
55 |
> |
DepartmentsCHILDCOUNT: TIBLargeIntField; |
56 |
> |
DepartmentsIMAGEINDEX: TIBIntegerField; |
57 |
|
IBDynamicGrid1: TIBDynamicGrid; |
58 |
|
IBLookupComboEditBox1: TIBLookupComboEditBox; |
59 |
|
ImageList1: TImageList; |
110 |
|
procedure DepartmentsAfterDelete(DataSet: TDataSet); |
111 |
|
procedure DepartmentsAfterInsert(DataSet: TDataSet); |
112 |
|
procedure DepartmentsAfterTransactionEnd(Sender: TObject); |
86 |
– |
procedure DepartmentsBeforeScroll(DataSet: TDataSet); |
87 |
– |
procedure DepartmentsBUDGETChange(Sender: TField); |
113 |
|
procedure DepartmentsBUDGETGetText(Sender: TField; var aText: string; |
114 |
|
DisplayText: Boolean); |
115 |
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
116 |
|
procedure FormShow(Sender: TObject); |
92 |
– |
procedure IBTreeView1Addition(Sender: TObject; Node: TTreeNode); |
117 |
|
procedure IBTreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); |
118 |
|
procedure IBTreeView1DragOver(Sender, Source: TObject; X, Y: Integer; |
119 |
|
State: TDragState; var Accept: Boolean); |
123 |
|
FDirty: boolean; |
124 |
|
FClosing: boolean; |
125 |
|
procedure Reopen(Data: PtrInt); |
102 |
– |
procedure SetNodeImage(Node: TTreeNode); |
126 |
|
public |
127 |
|
{ public declarations } |
128 |
|
end; |
154 |
|
procedure TForm1.AddChildExecute(Sender: TObject); |
155 |
|
begin |
156 |
|
IBTreeView1.Selected.Expand(true); |
157 |
< |
IBTreeView1.Items.AddChild(IBTreeView1.Selected,''); |
157 |
> |
IBTreeView1.Selected := IBTreeView1.Items.AddChild(IBTreeView1.Selected,''); |
158 |
|
IBTreeView1.Selected.Expand(true); |
159 |
+ |
IBTreeView1.Selected.EditText; |
160 |
|
end; |
161 |
|
|
162 |
|
procedure TForm1.AddFirstChildExecute(Sender: TObject); |
163 |
|
begin |
164 |
|
IBTreeView1.Selected.Expand(true); |
165 |
< |
IBTreeView1.Items.AddChildFirst(IBTreeView1.Selected,''); |
165 |
> |
IBTreeView1.Selected := IBTreeView1.Items.AddChildFirst(IBTreeView1.Selected,''); |
166 |
|
IBTreeView1.Selected.Expand(true); |
167 |
+ |
IBTreeView1.Selected.EditText; |
168 |
|
end; |
169 |
|
|
170 |
|
procedure TForm1.AddSiblingExecute(Sender: TObject); |
171 |
|
begin |
172 |
< |
IBTreeView1.Items.Add(IBTreeView1.Selected,''); |
172 |
> |
IBTreeView1.Selected := IBTreeView1.Items.Add(IBTreeView1.Selected,''); |
173 |
> |
IBTreeView1.Selected.EditText; |
174 |
|
end; |
175 |
|
|
176 |
|
procedure TForm1.CancelBtnClick(Sender: TObject); |
207 |
|
Application.QueueAsyncCall(@Reopen,0); |
208 |
|
end; |
209 |
|
|
184 |
– |
procedure TForm1.DepartmentsBeforeScroll(DataSet: TDataSet); |
185 |
– |
begin |
186 |
– |
with DataSet do |
187 |
– |
try |
188 |
– |
if State in [dsInsert,dsEdit] then Post |
189 |
– |
except on E: Exception do |
190 |
– |
begin |
191 |
– |
Cancel; |
192 |
– |
MessageDlg(E.Message,mtError,[mbOK],0) |
193 |
– |
end |
194 |
– |
end; |
195 |
– |
end; |
196 |
– |
|
197 |
– |
procedure TForm1.DepartmentsBUDGETChange(Sender: TField); |
198 |
– |
begin |
199 |
– |
SetNodeImage(IBTreeView1.Selected) |
200 |
– |
end; |
201 |
– |
|
210 |
|
procedure TForm1.DepartmentsBUDGETGetText(Sender: TField; var aText: string; |
211 |
|
DisplayText: Boolean); |
212 |
|
begin |
234 |
|
Reopen(0); |
235 |
|
end; |
236 |
|
|
229 |
– |
procedure TForm1.IBTreeView1Addition(Sender: TObject; Node: TTreeNode); |
230 |
– |
begin |
231 |
– |
SetNodeImage(Node) |
232 |
– |
end; |
233 |
– |
|
237 |
|
procedure TForm1.IBTreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); |
238 |
|
var Node: TTreeNode; |
239 |
|
tv: TTreeView; |
280 |
|
Staff.Active := true; |
281 |
|
end; |
282 |
|
|
280 |
– |
procedure TForm1.SetNodeImage(Node: TTreeNode); |
281 |
– |
begin |
282 |
– |
if Departments.FieldByName('Budget').AsFloat < 500000 then |
283 |
– |
Node.ImageIndex := 0 |
284 |
– |
else |
285 |
– |
if Departments.FieldByName('Budget').AsFloat = 500000 then |
286 |
– |
Node.ImageIndex := 2 |
287 |
– |
else |
288 |
– |
Node.ImageIndex := 1 |
289 |
– |
end; |
290 |
– |
|
283 |
|
end. |
284 |
|
|