diff --git a/.gitignore b/.gitignore index 9532800..19e2949 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,7 @@ __recovery/ # Boss dependency manager vendor folder https://github.com/HashLoad/boss modules/ + +Win32/ +Win64/ +Linux64/ diff --git a/CRUDPOODelphi.dpr b/CRUDPOODelphi.dpr new file mode 100644 index 0000000..883d067 --- /dev/null +++ b/CRUDPOODelphi.dpr @@ -0,0 +1,18 @@ +program CRUDPOODelphi; + +uses + Vcl.Forms, + CRUDPOO.View.Main in 'src\view\CRUDPOO.View.Main.pas' {Form1}, + CRUDPOO.Model.Pessoa in 'src\model\CRUDPOO.Model.Pessoa.pas', + CRUDPOO.Model.Endereco in 'src\model\CRUDPOO.Model.Endereco.pas', + CRUDPOO.Model.Connection in 'src\model\connection\CRUDPOO.Model.Connection.pas' {Connection: TDataModule}, + CRUDPOO.DAO.Pessoa in 'src\DAO\CRUDPOO.DAO.Pessoa.pas'; + +{$R *.res} + +begin + Application.Initialize; + Application.MainFormOnTaskbar := True; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. diff --git a/CRUDPOODelphi.dproj b/CRUDPOODelphi.dproj new file mode 100644 index 0000000..ace27f8 --- /dev/null +++ b/CRUDPOODelphi.dproj @@ -0,0 +1,928 @@ + + + {F814A4F4-2804-4B7F-B145-D48057E3D08D} + 19.2 + VCL + True + Debug + Win32 + 1 + Application + CRUDPOODelphi.dpr + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + .\$(Platform)\$(Config) + .\$(Platform)\$(Config) + false + false + false + false + false + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + $(BDS)\bin\delphi_PROJECTICON.ico + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + CRUDPOODelphi + + + DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;bindcompvclsmp;emsclientfiredac;DataSnapFireDAC;tethering;svnui;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;svn;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;FireDACIBDriver;fmx;fmxdae;vcledge;vclib;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;IndyIPCommon;vcl;DBXSybaseASEDriver;IndyIPServer;IndySystem;FireDACDb2Driver;bindcompvclwinx;dsnapcon;FireDACMSAccDriver;FireDACInfxDriver;fmxFireDAC;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;Tee;DataSnapServer;xmlrtl;DataSnapNativeClient;ibxbindings;fmxobj;FireDACDSDriver;soapmidas;rtl;emsserverresource;DbxClientDriver;vclwinx;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;DataSnapProviderClient;dsnapxml;dbrtl;FireDACMongoDBDriver;IndyProtocols;inetdbxpress;fmxase;$(DCC_UsePackage) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\default_app.manifest + + + DBXSqliteDriver;RESTComponents;DataSnapServerMidas;DBXDb2Driver;DBXInterBaseDriver;vclactnband;vclFireDAC;bindcompvclsmp;emsclientfiredac;DataSnapFireDAC;tethering;FireDACADSDriver;DBXMSSQLDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;DBXOracleDriver;inetdb;FmxTeeUI;emsedge;FireDACIBDriver;fmx;fmxdae;vcledge;vclib;FireDACDBXDriver;dbexpress;IndyCore;vclx;dsnap;DataSnapCommon;emsclient;FireDACCommon;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;vclie;bindengine;DBXMySQLDriver;CloudService;FireDACOracleDriver;FireDACMySQLDriver;DBXFirebirdDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;bindcompdbx;IndyIPCommon;vcl;DBXSybaseASEDriver;IndyIPServer;IndySystem;FireDACDb2Driver;bindcompvclwinx;dsnapcon;FireDACMSAccDriver;FireDACInfxDriver;fmxFireDAC;vclimg;TeeDB;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;ibmonitor;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;FMXTee;soaprtl;DbxCommonDriver;ibxpress;Tee;DataSnapServer;xmlrtl;DataSnapNativeClient;ibxbindings;fmxobj;FireDACDSDriver;soapmidas;rtl;emsserverresource;DbxClientDriver;vclwinx;DBXSybaseASADriver;CustomIPTransport;vcldsnap;bindcomp;appanalytics;DBXInformixDriver;IndyIPClient;bindcompvcl;TeeUI;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;DataSnapProviderClient;dsnapxml;dbrtl;FireDACMongoDBDriver;IndyProtocols;inetdbxpress;fmxase;$(DCC_UsePackage) + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + false + true + PerMonitorV2 + true + 1033 + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + PerMonitorV2 + + + + MainSource + + +
Form1
+ dfm +
+ + + +
Connection
+ dfm + TDataModule +
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Application + + + + CRUDPOODelphi.dpr + + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + CRUDPOODelphi.exe + true + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + classes + 1 + + + classes + 1 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen + 64 + + + ..\$(PROJECTNAME).launchscreen + 64 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/CRUDPOODelphi.res b/CRUDPOODelphi.res new file mode 100644 index 0000000..cbaeee8 Binary files /dev/null and b/CRUDPOODelphi.res differ diff --git a/database/dados.sdb3 b/database/dados.sdb3 new file mode 100644 index 0000000..c8dcf17 Binary files /dev/null and b/database/dados.sdb3 differ diff --git a/src/DAO/CRUDPOO.DAO.Pessoa.pas b/src/DAO/CRUDPOO.DAO.Pessoa.pas new file mode 100644 index 0000000..06521a3 --- /dev/null +++ b/src/DAO/CRUDPOO.DAO.Pessoa.pas @@ -0,0 +1,63 @@ +unit CRUDPOO.DAO.Pessoa; + +interface + +uses + CRUDPOO.Model.Pessoa, CRUDPOO.Model.Connection; + +type + TDAOPessoa = class + private + FConnection : TConnection; + public + constructor Create; + destructor Destroy; override; + procedure CreatePessoa(aValue : TPessoa); + end; + +implementation + +{ TDAOPessoa } + +constructor TDAOPessoa.Create; +begin + FConnection := TConnection.Create(nil); +end; + +procedure TDAOPessoa.CreatePessoa(aValue: TPessoa); +var + lSQL : String; + I: Integer; +begin + FConnection.StartTransation; + try + lSQL := 'insert into pessoa values (?, ?)'; + FConnection.PrepareStatement(lSQL); + FConnection.SetValue(0, aValue.Id); + FConnection.SetValue(1, aValue.Nome); + FConnection.ExecSQL; + + lSQL := ''; + for I := 0 to Pred(aValue.Endereco.Count) do + begin + lSQL := 'insert into endereco values (?, ?, ?)'; + FConnection.PrepareStatement(lSQL); + FConnection.SetValue(0,aValue.Endereco[I].Id); + FConnection.SetValue(1,aValue.Id); + FConnection.SetValue(2,aValue.Endereco[I].Logradouro); + FConnection.ExecSQL; + end; + + FConnection.Commit; + except + FConnection.Rollback; + end; +end; + +destructor TDAOPessoa.Destroy; +begin + FConnection.DisposeOf; + inherited; +end; + +end. diff --git a/src/model/CRUDPOO.Model.Endereco.pas b/src/model/CRUDPOO.Model.Endereco.pas new file mode 100644 index 0000000..356044e --- /dev/null +++ b/src/model/CRUDPOO.Model.Endereco.pas @@ -0,0 +1,19 @@ +unit CRUDPOO.Model.Endereco; + +interface + +type + TEndereco = class + private + FLogradouro: String; + Fid: Integer; + FIdPessoa: Integer; + public + property Id : Integer read Fid write FId; + property IdPessoa : Integer read FIdPessoa write FIdPessoa; + property Logradouro : String read FLogradouro write FLogradouro; + end; + +implementation + +end. diff --git a/src/model/CRUDPOO.Model.Pessoa.pas b/src/model/CRUDPOO.Model.Pessoa.pas new file mode 100644 index 0000000..bb99bea --- /dev/null +++ b/src/model/CRUDPOO.Model.Pessoa.pas @@ -0,0 +1,38 @@ +unit CRUDPOO.Model.Pessoa; + +interface + +uses + CRUDPOO.Model.Endereco, + System.Generics.Collections; + +type + TPessoa = class + private + Fid: Integer; + Fnome: String; + FEndereco: TList; + public + constructor Create; + destructor Destroy; override; + property Id : Integer read Fid write FId; + property Nome : String read Fnome write Fnome; + property Endereco : TList read FEndereco write FEndereco; + end; + +implementation + +{ TPessoa } + +constructor TPessoa.Create; +begin + FEndereco:= TList.Create; +end; + +destructor TPessoa.Destroy; +begin + FEndereco.DisposeOf; + inherited; +end; + +end. diff --git a/src/model/connection/CRUDPOO.Model.Connection.dfm b/src/model/connection/CRUDPOO.Model.Connection.dfm new file mode 100644 index 0000000..635bb01 --- /dev/null +++ b/src/model/connection/CRUDPOO.Model.Connection.dfm @@ -0,0 +1,22 @@ +object Connection: TConnection + OldCreateOrder = False + OnCreate = DataModuleCreate + Height = 150 + Width = 215 + object FDConnection: TFDConnection + Params.Strings = ( + + 'Database=C:\Users\Criacao\Desktop\CRUDPOODelphi\database\dados.s' + + 'db3' + 'LockingMode=Normal' + 'DriverID=SQLite') + LoginPrompt = False + Left = 72 + Top = 32 + end + object FDQuery: TFDQuery + Connection = FDConnection + Left = 160 + Top = 24 + end +end diff --git a/src/model/connection/CRUDPOO.Model.Connection.pas b/src/model/connection/CRUDPOO.Model.Connection.pas new file mode 100644 index 0000000..0d44ba2 --- /dev/null +++ b/src/model/connection/CRUDPOO.Model.Connection.pas @@ -0,0 +1,73 @@ +unit CRUDPOO.Model.Connection; + +interface + +uses + System.SysUtils, System.Classes, 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.Phys.SQLite, + FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, + FireDAC.Phys.SQLiteWrapper.Stat, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, + FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet, + FireDAC.Comp.Client; + +type + TConnection = class(TDataModule) + FDConnection: TFDConnection; + FDQuery: TFDQuery; + procedure DataModuleCreate(Sender: TObject); + private + { Private declarations } + public + procedure PrepareStatement(aSQL: String); + procedure SetValue(aIndex: Integer; aValue: Variant); + procedure ExecSQL; + procedure StartTransation; + procedure Commit; + procedure Rollback; + end; + +implementation + +{%CLASSGROUP 'Vcl.Controls.TControl'} + +{$R *.dfm} + +procedure TConnection.Commit; +begin + FDConnection.Commit; +end; + +procedure TConnection.DataModuleCreate(Sender: TObject); +begin + FDConnection.Connected := true; +end; + +procedure TConnection.ExecSQL; +begin + FDQuery.ExecSQL; +end; + +procedure TConnection.PrepareStatement(aSQL: String); +begin + FDQuery.SQL.Clear; + FDQuery.SQL.Add(aSQL); +end; + +procedure TConnection.Rollback; +begin + FDConnection.Rollback; +end; + +procedure TConnection.SetValue(aIndex: Integer; aValue: Variant); +begin + FDQuery.Params.Add; + FDQuery.Params[aIndex].Value := aValue; +end; + +procedure TConnection.StartTransation; +begin + FDConnection.StartTransaction; +end; + +end. diff --git a/src/view/CRUDPOO.View.Main.dfm b/src/view/CRUDPOO.View.Main.dfm new file mode 100644 index 0000000..9ab99c4 --- /dev/null +++ b/src/view/CRUDPOO.View.Main.dfm @@ -0,0 +1,34 @@ +object Form1: TForm1 + Left = 0 + Top = 0 + Caption = 'Form1' + ClientHeight = 201 + ClientWidth = 384 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + PixelsPerInch = 96 + TextHeight = 13 + object Button1: TButton + Left = 8 + Top = 8 + Width = 75 + Height = 25 + Caption = 'Button1' + TabOrder = 0 + OnClick = Button1Click + end + object Memo1: TMemo + Left = 89 + Top = 8 + Width = 280 + Height = 185 + Lines.Strings = ( + 'Memo1') + TabOrder = 1 + end +end diff --git a/src/view/CRUDPOO.View.Main.pas b/src/view/CRUDPOO.View.Main.pas new file mode 100644 index 0000000..b77575f --- /dev/null +++ b/src/view/CRUDPOO.View.Main.pas @@ -0,0 +1,103 @@ +unit CRUDPOO.View.Main; + +interface + +uses + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; + +type + TForm1 = class(TForm) + Button1: TButton; + Memo1: TMemo; + procedure Button1Click(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + Form1: TForm1; + +implementation + +uses + CRUDPOO.Model.Pessoa, CRUDPOO.Model.Endereco, CRUDPOO.DAO.Pessoa; + +{$R *.dfm} + +procedure TForm1.Button1Click(Sender: TObject); +var + lPessoa : TPessoa; + lEndereco : TEndereco; + lDAOPessoa : TDAOPessoa; + I: Integer; +begin + lPessoa := TPessoa.Create; + lDAOPessoa := TDAOPessoa.Create; + try + lPessoa.Id := 2; + lPessoa.Nome := 'Alessandro'; + + lEndereco := TEndereco.Create; + lEndereco.id := 1; + lEndereco.IdPessoa := lPessoa.Id; + lEndereco.Logradouro := 'Rua teste1'; + lPessoa.Endereco.Add(lEndereco); + + lEndereco := TEndereco.Create; + lEndereco.id := 2; + lEndereco.IdPessoa := lPessoa.Id; + lEndereco.Logradouro := 'Rua teste2'; + lPessoa.Endereco.Add(lEndereco); + + lDAOPessoa.CreatePessoa(lPessoa); + for I := 0 to Pred(lPessoa.Endereco.Count) do + begin + + end; + finally + lPessoa.DisposeOf; + lEndereco.DisposeOf; + lDAOPessoa.DisposeOf; + end; +end; + + +//begin +// lPessoa := TPessoa.Create; +// try +// lPessoa.Id := 1; +// lPessoa.Nome := 'João'; +// +// lEndereco := TEndereco.Create; +// lEndereco.id := 1; +// lEndereco.IdPessoa := lPessoa.Id; +// lEndereco.Logradouro := 'Rua teste1'; +// lPessoa.Endereco.Add(lEndereco); +// +// lEndereco := TEndereco.Create; +// lEndereco.id := 2; +// lEndereco.IdPessoa := lPessoa.Id; +// lEndereco.Logradouro := 'Rua teste2'; +// lPessoa.Endereco.Add(lEndereco); +// +// Memo1.Lines.Add('id: '+ lPessoa.Id.ToString); +// Memo1.Lines.Add('Nome: '+ lPessoa.Nome); +// +// Memo1.Lines.Add('-----'); +// for I := 0 to Pred(lPessoa.Endereco.Count) do +// begin +// Memo1.Lines.Add('id: '+ lPessoa.Endereco[I].Id.ToString); +// Memo1.Lines.Add('idPessoa: '+ lPessoa.Endereco[I].IdPessoa.ToString); +// Memo1.Lines.Add('Logradouro: '+ lPessoa.Endereco[I].Logradouro); +// Memo1.Lines.Add('-----'); +// end; +// finally +// lPessoa.DisposeOf; +// lEndereco.DisposeOf; +// end; +//end; + +end.