1 |
tony |
37 |
unit Unit2;
|
2 |
|
|
|
3 |
|
|
{$mode objfpc}{$H+}
|
4 |
|
|
|
5 |
|
|
interface
|
6 |
|
|
|
7 |
|
|
uses
|
8 |
|
|
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, db,
|
9 |
|
|
IBTreeView, IBQuery;
|
10 |
|
|
|
11 |
|
|
type
|
12 |
|
|
|
13 |
|
|
{ TSelectDeptDlg }
|
14 |
|
|
|
15 |
|
|
TSelectDeptDlg = class(TForm)
|
16 |
|
|
Button1: TButton;
|
17 |
|
|
Button2: TButton;
|
18 |
|
|
DataSource1: TDataSource;
|
19 |
|
|
Depts: TIBQuery;
|
20 |
|
|
DeptsTreeView: TIBTreeView;
|
21 |
|
|
Label1: TLabel;
|
22 |
|
|
procedure DeptsTreeViewDblClick(Sender: TObject);
|
23 |
|
|
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
24 |
|
|
procedure FormShow(Sender: TObject);
|
25 |
|
|
private
|
26 |
|
|
{ private declarations }
|
27 |
|
|
FDeptKeyPath: string;
|
28 |
|
|
FDept_no: string;
|
29 |
|
|
public
|
30 |
|
|
{ public declarations }
|
31 |
|
|
function ShowModal(DeptKeyPath: string; var Dept_no: string): TModalResult;
|
32 |
|
|
end;
|
33 |
|
|
|
34 |
|
|
var
|
35 |
|
|
SelectDeptDlg: TSelectDeptDlg;
|
36 |
|
|
|
37 |
|
|
implementation
|
38 |
|
|
|
39 |
|
|
{$R *.lfm}
|
40 |
|
|
|
41 |
|
|
{ TSelectDeptDlg }
|
42 |
|
|
|
43 |
|
|
procedure TSelectDeptDlg.FormShow(Sender: TObject);
|
44 |
|
|
begin
|
45 |
|
|
Depts.Active := true;
|
46 |
|
|
if FDeptKeyPath <> '' then
|
47 |
|
|
DeptsTreeView.FindNode(StrIntListToVar(FDeptKeyPath),true); {Find and Select Current Dept}
|
48 |
|
|
end;
|
49 |
|
|
|
50 |
|
|
function TSelectDeptDlg.ShowModal(DeptKeyPath: string; var Dept_no: string
|
51 |
|
|
): TModalResult;
|
52 |
|
|
begin
|
53 |
|
|
FDeptKeyPath := DeptKeyPath;
|
54 |
|
|
Result := inherited ShowModal;
|
55 |
|
|
Dept_no := FDept_no;
|
56 |
|
|
end;
|
57 |
|
|
|
58 |
|
|
procedure TSelectDeptDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
59 |
|
|
begin
|
60 |
|
|
FDept_no := '';
|
61 |
|
|
if assigned(DeptsTreeView.Selected) then
|
62 |
|
|
FDept_no := TIBTreeNode(DeptsTreeView.Selected).KeyValue;
|
63 |
|
|
Depts.Active := false
|
64 |
|
|
end;
|
65 |
|
|
|
66 |
|
|
procedure TSelectDeptDlg.DeptsTreeViewDblClick(Sender: TObject);
|
67 |
|
|
begin
|
68 |
|
|
ModalResult := mrOK;
|
69 |
|
|
end;
|
70 |
|
|
|
71 |
|
|
end.
|
72 |
|
|
|