リビジョン | 5 (tree) |
---|---|
日時 | 2022-01-08 11:05:30 |
作者 | derekwildstar |
Exemplo básico de utilização do TBRDMasterNavigator concluído
@@ -2,7 +2,8 @@ | ||
2 | 2 | |
3 | 3 | uses |
4 | 4 | Vcl.Forms, |
5 | - UFormPrincipal in '..\src\UFormPrincipal.pas' {Form1}; | |
5 | + UFormPrincipal in '..\src\UFormPrincipal.pas' {FormPrincipal}, | |
6 | + UDamoPrincipal in '..\src\UDamoPrincipal.pas' {DamoPrincipal: TDataModule}; | |
6 | 7 | |
7 | 8 | {$R *.res} |
8 | 9 |
@@ -9,6 +10,6 @@ | ||
9 | 10 | begin |
10 | 11 | Application.Initialize; |
11 | 12 | Application.MainFormOnTaskbar := True; |
12 | - Application.CreateForm(TForm1, Form1); | |
13 | + Application.CreateForm(TFormPrincipal, FormPrincipal); | |
13 | 14 | Application.Run; |
14 | 15 | end. |
@@ -68,6 +68,7 @@ | ||
68 | 68 | <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo> |
69 | 69 | <VerInfo_Locale>1033</VerInfo_Locale> |
70 | 70 | <Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File> |
71 | + <Icon_MainIcon>..\res\bdd.ico</Icon_MainIcon> | |
71 | 72 | </PropertyGroup> |
72 | 73 | <PropertyGroup Condition="'$(Base_Win64)'!=''"> |
73 | 74 | <DCC_UsePackage>DBXSqliteDriver;bindcompdbx;RESTComponents;DBXInterBaseDriver;vcl;IndyIPServer;vclactnband;IndyIPCommon;vclFireDAC;IndySystem;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;vclimg;TeeDB;FireDAC;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;inetdb;CEF4Delphi;FMXTee;soaprtl;DbxCommonDriver;FmxTeeUI;ibxpress;FireDACIBDriver;fmx;fmxdae;xmlrtl;soapmidas;ibxbindings;fmxobj;vclwinx;vclib;rtl;Tee;DbxClientDriver;GR32_R;CustomIPTransport;vcldsnap;dbexpress;IndyCore;vclx;bindcomp;appanalytics;dsnap;officeXPrt;FireDACCommon;IndyIPClient;bindcompvcl;RESTBackendComponents;TeeUI;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;PNGComponentsR;FireDACConnR;ADOConnR;UserControlR;vclie;bindengine;DBXMySQLDriver;CloudService;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;IndyProtocols;DBXConnR;FireDACCommonODBC;FireDACCommonDriver;inet;fmxase;$(DCC_UsePackage)</DCC_UsePackage> |
@@ -104,9 +105,14 @@ | ||
104 | 105 | <MainSource>MainSource</MainSource> |
105 | 106 | </DelphiCompile> |
106 | 107 | <DCCReference Include="..\src\UFormPrincipal.pas"> |
107 | - <Form>Form1</Form> | |
108 | + <Form>FormPrincipal</Form> | |
108 | 109 | <FormType>dfm</FormType> |
109 | 110 | </DCCReference> |
111 | + <DCCReference Include="..\src\UDamoPrincipal.pas"> | |
112 | + <Form>DamoPrincipal</Form> | |
113 | + <FormType>dfm</FormType> | |
114 | + <DesignClass>TDataModule</DesignClass> | |
115 | + </DCCReference> | |
110 | 116 | <BuildConfiguration Include="Release"> |
111 | 117 | <Key>Cfg_2</Key> |
112 | 118 | <CfgParent>Base</CfgParent> |
@@ -129,7 +135,7 @@ | ||
129 | 135 | </Source> |
130 | 136 | </Delphi.Personality> |
131 | 137 | <Deployment Version="3"> |
132 | - <DeployFile LocalName="Win32\Debug\BrutalDelphi.exe" Configuration="Debug" Class="ProjectOutput"> | |
138 | + <DeployFile LocalName="..\bin\BrutalDelphi.exe" Configuration="Debug" Class="ProjectOutput"> | |
133 | 139 | <Platform Name="Win32"> |
134 | 140 | <RemoteName>BrutalDelphi.exe</RemoteName> |
135 | 141 | <Overwrite>true</Overwrite> |
@@ -0,0 +1,58 @@ | ||
1 | +unit UDamoPrincipal; | |
2 | + | |
3 | +interface | |
4 | + | |
5 | +uses | |
6 | + System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, | |
7 | + FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, | |
8 | + FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait, | |
9 | + Data.DB, FireDAC.Comp.Client, FireDAC.Phys.SQLite, FireDAC.Phys.SQLiteDef, | |
10 | + FireDAC.Stan.ExprFuncs, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, | |
11 | + FireDAC.DApt, FireDAC.Comp.DataSet, BRD.MasterNavigator; | |
12 | + | |
13 | +type | |
14 | + TDamoPrincipal = class(TDataModule) | |
15 | + FDCO: TFDConnection; | |
16 | + FDTACustomers: TFDTable; | |
17 | + FDTACustomersCustomerID: TStringField; | |
18 | + FDTACustomersCompanyName: TStringField; | |
19 | + FDTACustomersContactName: TStringField; | |
20 | + FDTACustomersContactTitle: TStringField; | |
21 | + FDTACustomersAddress: TStringField; | |
22 | + FDTACustomersCity: TStringField; | |
23 | + FDTACustomersRegion: TStringField; | |
24 | + FDTACustomersPostalCode: TStringField; | |
25 | + FDTACustomersCountry: TStringField; | |
26 | + FDTACustomersPhone: TStringField; | |
27 | + FDTACustomersFax: TStringField; | |
28 | + DASOCustomers: TDataSource; | |
29 | + BRDMasterNavigator: TBRDMasterNavigator; | |
30 | + procedure DataModuleCreate(Sender: TObject); | |
31 | + procedure DataModuleDestroy(Sender: TObject); | |
32 | + private | |
33 | + { Private declarations } | |
34 | + public | |
35 | + { Public declarations } | |
36 | + end; | |
37 | + | |
38 | +implementation | |
39 | + | |
40 | +{%CLASSGROUP 'Vcl.Controls.TControl'} | |
41 | + | |
42 | +uses UFormPrincipal; | |
43 | + | |
44 | +{$R *.dfm} | |
45 | + | |
46 | +procedure TDamoPrincipal.DataModuleCreate(Sender: TObject); | |
47 | +begin | |
48 | + FDCO.Params.Database := ExtractFilePath(ParamStr(0)) + 'fddemo.sdb'; | |
49 | + FDCO.Open; | |
50 | + FDTACustomers.Open; | |
51 | +end; | |
52 | + | |
53 | +procedure TDamoPrincipal.DataModuleDestroy(Sender: TObject); | |
54 | +begin | |
55 | + FDCO.Close; | |
56 | +end; | |
57 | + | |
58 | +end. |
@@ -4,21 +4,38 @@ | ||
4 | 4 | |
5 | 5 | uses |
6 | 6 | Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, |
7 | - Vcl.Controls, Vcl.Forms, Vcl.Dialogs; | |
7 | + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Buttons, | |
8 | + BRD.MasterNavigator, UDamoPrincipal, Data.DB, Vcl.Grids, Vcl.DBGrids; | |
8 | 9 | |
9 | 10 | type |
10 | - TForm1 = class(TForm) | |
11 | + TFormPrincipal = class(TForm) | |
12 | + BBTNCancelar: TBitBtn; | |
13 | + BBTNGravar: TBitBtn; | |
14 | + BBTNExcluir: TBitBtn; | |
15 | + BBTNNovo: TBitBtn; | |
16 | + DBGRCustomers: TDBGrid; | |
17 | + BBTNEditar: TBitBtn; | |
11 | 18 | private |
12 | 19 | { Private declarations } |
20 | + FDamoPrincipal: TDamoPrincipal; | |
13 | 21 | public |
14 | 22 | { Public declarations } |
23 | + constructor Create(AOwner: TComponent); override; | |
15 | 24 | end; |
16 | 25 | |
17 | 26 | var |
18 | - Form1: TForm1; | |
27 | + FormPrincipal: TFormPrincipal; | |
19 | 28 | |
20 | 29 | implementation |
21 | 30 | |
22 | 31 | {$R *.dfm} |
23 | 32 | |
33 | +{ TFormPrincipal } | |
34 | + | |
35 | +constructor TFormPrincipal.Create(AOwner: TComponent); | |
36 | +begin | |
37 | + inherited; | |
38 | + FDamoPrincipal := TDamoPrincipal.Create(Self); | |
39 | +end; | |
40 | + | |
24 | 41 | end. |
@@ -32,9 +32,9 @@ | ||
32 | 32 | FEventoCancelar: TNotifyEvent; |
33 | 33 | FEventoGravar: TNotifyEvent; |
34 | 34 | FEventoExcluir: TNotifyEvent; |
35 | - FSN_Excluir: Boolean; | |
36 | - FSN_Editar: Boolean; | |
37 | - FSN_Incluir: Boolean; | |
35 | + FPodeExcluir: Boolean; | |
36 | + FPodeEditar: Boolean; | |
37 | + FPodeIncluir: Boolean; | |
38 | 38 | FFocusComp: TWinControl; |
39 | 39 | FMensagemErro: TGetStrProc; |
40 | 40 | FConfirmacao: TMsgPergunta; |
@@ -45,9 +45,9 @@ | ||
45 | 45 | procedure setBtnExcluir(const AValue: TCustomButton); |
46 | 46 | procedure setBtnGravar(const AValue: TCustomButton); |
47 | 47 | procedure setBtnNovo(const AValue: TCustomButton); |
48 | - procedure SetSN_Editar(const AValue: Boolean); | |
49 | - procedure SetSN_Excluir(const AValue: Boolean); | |
50 | - procedure SetSN_Incluir(const AValue: Boolean); | |
48 | + procedure SetPodeEditar(const AValue: Boolean); | |
49 | + procedure SetPodeExcluir(const AValue: Boolean); | |
50 | + procedure SetPodeIncluir(const AValue: Boolean); | |
51 | 51 | procedure UpdateGUI; |
52 | 52 | |
53 | 53 | procedure AcaoNovo(ASender: TObject); |
@@ -71,9 +71,9 @@ | ||
71 | 71 | property BtnCancelar: TCustomButton read FBtnCancelar write SetBtnCancelar; |
72 | 72 | property BtnGravar: TCustomButton read FBtnGravar write setBtnGravar; |
73 | 73 | property BtnExcluir: TCustomButton read FBtnExcluir write setBtnExcluir; |
74 | - property SN_Excluir: Boolean read FSN_Excluir write SetSN_Excluir default True; | |
75 | - property SN_Editar: Boolean read FSN_Editar write SetSN_Editar default True; | |
76 | - property SN_Incluir: Boolean read FSN_Incluir write SetSN_Incluir default True; | |
74 | + property PodeExcluir: Boolean read FPodeExcluir write SetPodeExcluir default True; | |
75 | + property PodeEditar: Boolean read FPodeEditar write SetPodeEditar default True; | |
76 | + property PodeIncluir: Boolean read FPodeIncluir write SetPodeIncluir default True; | |
77 | 77 | property DataSource: TDataSource read GetDataSource write SetDataSource; |
78 | 78 | property FocusComp: TWinControl read FFocusComp write FFocusComp; |
79 | 79 | property OnError: TGetStrProc read FMensagemErro write FMensagemErro; |
@@ -102,8 +102,8 @@ | ||
102 | 102 | |
103 | 103 | FLink.DataSet.Edit; |
104 | 104 | |
105 | - if Assigned(FocusComp) then | |
106 | - TrySetFocus(FocusComp); | |
105 | + if Assigned(FFocusComp) then | |
106 | + TrySetFocus(FFocusComp); | |
107 | 107 | end; |
108 | 108 | |
109 | 109 | procedure TBRDMasterNavigator.AcaoExcluir(ASender: TObject); |
@@ -155,8 +155,8 @@ | ||
155 | 155 | |
156 | 156 | FLink.DataSet.Append; |
157 | 157 | |
158 | - if Assigned(FocusComp) then | |
159 | - TrySetFocus(FocusComp); | |
158 | + if Assigned(FFocusComp) then | |
159 | + TrySetFocus(FFocusComp); | |
160 | 160 | end; |
161 | 161 | |
162 | 162 | constructor TBRDMasterNavigator.Create(AOwner: TComponent); |
@@ -166,9 +166,9 @@ | ||
166 | 166 | FLink := TChangeDataLink.Create; |
167 | 167 | FLink.StateChange := DoStateChange; |
168 | 168 | |
169 | - FSN_Excluir := True; | |
170 | - FSN_Editar := True; | |
171 | - FSN_Incluir := True; | |
169 | + FPodeExcluir := True; | |
170 | + FPodeEditar := True; | |
171 | + FPodeIncluir := True; | |
172 | 172 | FFocusComp := nil; |
173 | 173 | FBtnNovo := nil; |
174 | 174 | FBtnEditar := nil; |
@@ -224,12 +224,12 @@ | ||
224 | 224 | SetEnabled(FBtnCancelar,EditInsert); |
225 | 225 | |
226 | 226 | if not EditInsert then |
227 | - SetEnabled(FBtnEditar,(not FLink.DataSet.IsEmpty) and SN_Editar) | |
227 | + SetEnabled(FBtnEditar,(not FLink.DataSet.IsEmpty) and PodeEditar) | |
228 | 228 | else |
229 | 229 | SetEnabled(FBtnEditar,False); |
230 | 230 | |
231 | - SetEnabled(FBtnNovo,not EditInsert and SN_Incluir); | |
232 | - SetEnabled(FBtnExcluir,not EditInsert and SN_Excluir); | |
231 | + SetEnabled(FBtnNovo,not EditInsert and PodeIncluir); | |
232 | + SetEnabled(FBtnExcluir,not EditInsert and PodeExcluir); | |
233 | 233 | end |
234 | 234 | else |
235 | 235 | begin |
@@ -507,21 +507,21 @@ | ||
507 | 507 | FLink.DataSource := AValue; |
508 | 508 | end; |
509 | 509 | |
510 | -procedure TBRDMasterNavigator.SetSN_Editar(const AValue: Boolean); | |
510 | +procedure TBRDMasterNavigator.SetPodeEditar(const AValue: Boolean); | |
511 | 511 | begin |
512 | - FSN_Editar := AValue; | |
512 | + FPodeEditar := AValue; | |
513 | 513 | UpdateGUI; |
514 | 514 | end; |
515 | 515 | |
516 | -procedure TBRDMasterNavigator.SetSN_Excluir(const AValue: Boolean); | |
516 | +procedure TBRDMasterNavigator.SetPodeExcluir(const AValue: Boolean); | |
517 | 517 | begin |
518 | - FSN_Excluir := AValue; | |
518 | + FPodeExcluir := AValue; | |
519 | 519 | UpdateGUI; |
520 | 520 | end; |
521 | 521 | |
522 | -procedure TBRDMasterNavigator.SetSN_Incluir(const AValue: Boolean); | |
522 | +procedure TBRDMasterNavigator.SetPodeIncluir(const AValue: Boolean); | |
523 | 523 | begin |
524 | - FSN_Incluir := AValue; | |
524 | + FPodeIncluir := AValue; | |
525 | 525 | UpdateGUI; |
526 | 526 | end; |
527 | 527 |