ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/employee/unit2.pas
(Generate patch)
# Line 1 | Line 1
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,
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 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines