1 |
< |
unit Unit2; |
2 |
< |
|
3 |
< |
{$mode objfpc}{$H+} |
4 |
< |
|
5 |
< |
interface |
6 |
< |
|
7 |
< |
uses |
8 |
< |
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, |
9 |
< |
DbCtrls, EditBtn, IBCustomDataSet, IBQuery, db; |
10 |
< |
|
11 |
< |
type |
12 |
< |
|
13 |
< |
{ TEditEmployeeDlg } |
14 |
< |
|
15 |
< |
TEditEmployeeDlg = class(TForm) |
16 |
< |
Button1: TButton; |
17 |
< |
Button2: TButton; |
18 |
< |
CountriesCOUNTRY: TIBStringField; |
19 |
< |
CountriesCURRENCY: TIBStringField; |
20 |
< |
Datasource1: TDatasource; |
21 |
< |
Datasource2: TDatasource; |
22 |
< |
Datasource4: TDatasource; |
23 |
< |
DateEdit1: TDateEdit; |
24 |
< |
DBEdit1: TDBEdit; |
25 |
< |
DBEdit2: TDBEdit; |
26 |
< |
DBEdit4: TDBEdit; |
27 |
< |
DBEdit5: TDBEdit; |
28 |
< |
DBLookupComboBox1: TDBLookupComboBox; |
29 |
< |
DBLookupComboBox3: TDBLookupComboBox; |
30 |
< |
IBDataSet1: TIBDataSet; |
31 |
< |
IBDataSet1DEPT_NO: TIBStringField; |
32 |
< |
IBDataSet1EMP_NO: TSmallintField; |
33 |
< |
IBDataSet1FIRST_NAME: TIBStringField; |
34 |
< |
IBDataSet1FULL_NAME: TIBStringField; |
35 |
< |
IBDataSet1HIRE_DATE: TDateTimeField; |
36 |
< |
IBDataSet1JOB_CODE: TIBStringField; |
37 |
< |
IBDataSet1JOB_COUNTRY: TIBStringField; |
38 |
< |
IBDataSet1JOB_GRADE: TSmallintField; |
39 |
< |
IBDataSet1LAST_NAME: TIBStringField; |
40 |
< |
IBDataSet1PHONE_EXT: TIBStringField; |
41 |
< |
IBDataSet1SALARY: TIBBCDField; |
42 |
< |
Depts: TIBQuery; |
43 |
< |
Countries: TIBQuery; |
44 |
< |
Label1: TLabel; |
45 |
< |
Label2: TLabel; |
46 |
< |
Label3: TLabel; |
47 |
< |
Label4: TLabel; |
48 |
< |
Label5: TLabel; |
49 |
< |
Label6: TLabel; |
50 |
< |
Label8: TLabel; |
51 |
< |
procedure DateEdit1Change(Sender: TObject); |
52 |
< |
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); |
53 |
< |
procedure FormShow(Sender: TObject); |
54 |
< |
procedure IBDataSet1AfterClose(DataSet: TDataSet); |
55 |
< |
procedure IBDataSet1AfterInsert(DataSet: TDataSet); |
56 |
< |
procedure IBDataSet1AfterScroll(DataSet: TDataSet); |
57 |
< |
procedure IBDataSet1BeforeOpen(DataSet: TDataSet); |
58 |
< |
procedure IBDataSet1BeforePost(DataSet: TDataSet); |
59 |
< |
private |
60 |
< |
{ private declarations } |
61 |
< |
FEmp_no: integer; |
62 |
< |
public |
63 |
< |
{ public declarations } |
64 |
< |
function ShowModal(Emp_no: integer): TModalResult; |
65 |
< |
end; |
66 |
< |
|
67 |
< |
var |
68 |
< |
EditEmployeeDlg: TEditEmployeeDlg; |
69 |
< |
|
70 |
< |
implementation |
71 |
< |
|
72 |
< |
{$R *.lfm} |
73 |
< |
|
74 |
< |
uses Unit1; |
75 |
< |
|
76 |
< |
{ TEditEmployeeDlg } |
77 |
< |
|
78 |
< |
procedure TEditEmployeeDlg.IBDataSet1AfterScroll(DataSet: TDataSet); |
79 |
< |
begin |
80 |
< |
DateEdit1.Date := DataSet.FieldByName('HIRE_DATE').AsDateTime |
81 |
< |
end; |
82 |
< |
|
83 |
< |
procedure TEditEmployeeDlg.IBDataSet1BeforeOpen(DataSet: TDataSet); |
84 |
< |
begin |
85 |
< |
Depts.Active:= true; |
86 |
< |
Countries.Active := true; |
87 |
< |
IBDataSet1.ParamByName('EMP_NO').AsInteger := FEmp_no |
88 |
< |
end; |
89 |
< |
|
90 |
< |
procedure TEditEmployeeDlg.DateEdit1Change(Sender: TObject); |
91 |
< |
begin |
92 |
< |
IBDataSet1.Edit; |
93 |
< |
IBDataSet1.FieldByName('HIRE_DATE').AsDateTime := DateEdit1.Date |
94 |
< |
end; |
95 |
< |
|
96 |
< |
procedure TEditEmployeeDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction); |
97 |
< |
begin |
98 |
< |
if IBDataSet1.State in [dsEdit,dsInsert] then |
99 |
< |
begin |
100 |
< |
if ModalResult = mrOK then |
101 |
< |
IBDataSet1.Post |
102 |
< |
else |
103 |
< |
IBDataSet1.Cancel |
104 |
< |
end; |
105 |
< |
IBDataSet1.Active := false |
106 |
< |
end; |
107 |
< |
|
108 |
< |
procedure TEditEmployeeDlg.FormShow(Sender: TObject); |
109 |
< |
begin |
110 |
< |
IBDataSet1.Active := true |
111 |
< |
end; |
112 |
< |
|
113 |
< |
procedure TEditEmployeeDlg.IBDataSet1AfterClose(DataSet: TDataSet); |
114 |
< |
begin |
115 |
< |
Depts.Active := false; |
116 |
< |
Countries.Active := false; |
117 |
< |
end; |
118 |
< |
|
119 |
< |
procedure TEditEmployeeDlg.IBDataSet1AfterInsert(DataSet: TDataSet); |
120 |
< |
begin |
121 |
< |
DataSet.FieldByName('HIRE_DATE').AsDateTime := Now; |
122 |
< |
DataSet.FieldByName('JOB_CODE').AsString := 'Eng'; |
123 |
< |
DataSet.FieldByName('JOB_GRADE').AsInteger := 2; |
124 |
< |
DataSet.FieldByName('Salary').AsFloat := 70000; |
125 |
< |
end; |
126 |
< |
|
127 |
< |
procedure TEditEmployeeDlg.IBDataSet1BeforePost(DataSet: TDataSet); |
128 |
< |
begin |
129 |
< |
DataSet.FieldByName('HIRE_DATE').AsDateTime := DateEdit1.Date |
130 |
< |
end; |
131 |
< |
|
132 |
< |
function TEditEmployeeDlg.ShowModal(Emp_no: integer): TModalResult; |
133 |
< |
begin |
134 |
< |
FEmp_no := Emp_no; |
135 |
< |
Result := inherited ShowModal |
136 |
< |
end; |
137 |
< |
|
138 |
< |
end. |
139 |
< |
|
1 |
> |
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 |
> |
|