ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/examples/ibtable/Unit1.pas
Revision: 143
Committed: Fri Feb 23 12:11:21 2018 UTC (6 years, 1 month ago) by tony
Content type: text/x-pascal
File size: 3225 byte(s)
Log Message:
Fixes Merged

File Contents

# Content
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+}
30
31 interface
32
33 uses
34 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
35 DBGrids, db, IBDatabase, IBTable, IBCustomDataSet, IBDynamicGrid, IB;
36
37 type
38
39 { TForm1 }
40
41 TForm1 = class(TForm)
42 Datasource1: TDataSource;
43 DataSource2: TDataSource;
44 IBDatabase1: TIBDatabase;
45 IBDynamicGrid1: TIBDynamicGrid;
46 IBDynamicGrid2: TIBDynamicGrid;
47 Employees: TIBTable;
48 EmployeesDEPT_NO: TIBStringField;
49 EmployeesEMP_NO: TSmallintField;
50 EmployeesFIRST_NAME: TIBStringField;
51 EmployeesFULL_NAME: TIBStringField;
52 EmployeesHIRE_DATE: TDateTimeField;
53 EmployeesJOB_CODE: TIBStringField;
54 EmployeesJOB_COUNTRY: TIBStringField;
55 EmployeesJOB_GRADE: TSmallintField;
56 EmployeesLAST_NAME: TIBStringField;
57 EmployeesPHONE_EXT: TIBStringField;
58 EmployeesSALARY: TIBBCDField;
59 Depts: TIBTable;
60 DeptsBUDGET: TIBBCDField;
61 DeptsDEPARTMENT: TIBStringField;
62 DeptsDEPT_NO: TIBStringField;
63 DeptsHEAD_DEPT: TIBStringField;
64 DeptsLOCATION: TIBStringField;
65 DeptsMNGR_NO: TSmallintField;
66 DeptsPHONE_NO: TIBStringField;
67 IBTransaction1: TIBTransaction;
68 Panel1: TPanel;
69 Panel2: TPanel;
70 Splitter1: TSplitter;
71 procedure EmployeesSALARYGetText(Sender: TField; var aText: string;
72 DisplayText: Boolean);
73 procedure FormShow(Sender: TObject);
74 procedure IBDatabase1AfterConnect(Sender: TObject);
75 procedure DeptsAfterOpen(DataSet: TDataSet);
76 private
77 { private declarations }
78 public
79 { public declarations }
80 end;
81
82 var
83 Form1: TForm1;
84
85 implementation
86
87 {$R *.lfm}
88
89 { TForm1 }
90
91 procedure TForm1.FormShow(Sender: TObject);
92 begin
93 repeat
94 try
95 IBDatabase1.Connected := true;
96 except
97 on E:EIBClientError do
98 begin
99 Close;
100 Exit
101 end;
102 On E:Exception do
103 MessageDlg(E.Message,mtError,[mbOK],0);
104 end;
105 until IBDatabase1.Connected;
106 end;
107
108 procedure TForm1.EmployeesSALARYGetText(Sender: TField; var aText: string;
109 DisplayText: Boolean);
110 begin
111 if DisplayText and not Sender.IsNull then
112 aText := FormatFloat('$#,##0.00',Sender.AsFloat)
113 else
114 aText := Sender.AsString;
115 end;
116
117 procedure TForm1.IBDatabase1AfterConnect(Sender: TObject);
118 begin
119 Depts.Active := true;
120 end;
121
122 procedure TForm1.DeptsAfterOpen(DataSet: TDataSet);
123 begin
124 Employees.Active := true;
125 end;
126
127 end.
128