-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFormTeste.pas
84 lines (71 loc) · 2.45 KB
/
FormTeste.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
unit FormTeste;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async,
FireDAC.Phys, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, Vcl.StdCtrls, Data.FMTBcd, Data.SqlExpr;
type
TForm1 = class(TForm)
btnAction: TButton;
FDConnection: TFDConnection;
FDQuery: TFDQuery;
SQLConnection: TSQLConnection;
SQLQuery: TSQLQuery;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
lblOpenedFDConnection: TLabel;
lblOpenedSQLConnection: TLabel;
lblOpenedFDQuery: TLabel;
lblOpenedSQLQuery: TLabel;
lblActiveFDConnection: TLabel;
lblActiveSQLConnection: TLabel;
lblActiveFDQuery: TLabel;
lblActiveSQLQuery: TLabel;
procedure QueryAfterOpen(DataSet: TDataSet);
procedure ConnectionAfterConnect(Sender: TObject);
procedure QueryAfterClose(DataSet: TDataSet);
procedure ConnectionAfterDisconnect(Sender: TObject);
procedure btnActionClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
LABEL_OPENED = 'lblOpened';
LABEL_ACTIVE = 'lblActive';
SIM_NAO: array[Boolean] of string = ('NÃO', 'SIM');
implementation
{$R *.dfm}
procedure TForm1.btnActionClick(Sender: TObject);
begin
FDConnection.Open;
SQLConnection.Open;
FDQuery.Open;
SQLQuery.Open;
end;
procedure TForm1.ConnectionAfterConnect(Sender: TObject);
begin
TLabel(FindComponent(LABEL_OPENED + TComponent(Sender).Name)).Caption := SIM_NAO[True];
TLabel(FindComponent(LABEL_ACTIVE + TComponent(Sender).Name)).Caption := SIM_NAO[True];
end;
procedure TForm1.ConnectionAfterDisconnect(Sender: TObject);
begin
TLabel(FindComponent(LABEL_ACTIVE + TComponent(Sender).Name)).Caption := SIM_NAO[False];
end;
procedure TForm1.QueryAfterClose(DataSet: TDataSet);
begin
TLabel(FindComponent(LABEL_ACTIVE + DataSet.Name)).Caption := SIM_NAO[False];
end;
procedure TForm1.QueryAfterOpen(DataSet: TDataSet);
begin
TLabel(FindComponent(LABEL_OPENED + DataSet.Name)).Caption := SIM_NAO[True];
TLabel(FindComponent('lblActive'+DataSet.Name)).Caption := SIM_NAO[True];
end;
end.