-
Notifications
You must be signed in to change notification settings - Fork 0
/
untGerenciaDados.pas
93 lines (55 loc) · 1.6 KB
/
untGerenciaDados.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
85
86
87
88
89
90
91
92
93
unit untGerenciaDados;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Aurelius.Bind.Dataset, ConnectionModule,
Generics.Collections, UEntity, Aurelius.Engine.DatabaseManager, Aurelius.Engine.ObjectManager,
Data.DB;
type
TGerenciador = class(TForm)
AureliusDataset1: TAureliusDataset;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
modoAdicionar:boolean;
end;
var
Gerenciador: TGerenciador;
DbManager: TDatabaseManager;
ObjManager: TObjectManager;
Produto: TProduto;
ListaProdutos : TList<TProduto>;
dataSTR: string;
implementation
{$R *.dfm}
procedure TGerenciador.FormCreate(Sender: TObject);
begin
DBManager:= TDatabaseManager.Create(TSQLiteSQLiteConnection.CreateConnection);
if FileExists(nomedb) then
begin
DbManager.UpdateDatabase;
DBmanager.Free;
ObjManager:= TObjectManager.Create(TSQLiteSQLiteConnection.CreateConnection);
ListaProdutos := objManager.Find<TProduto>.List;
end
else
begin
DbManager.BuildDatabase;
DBmanager.Free;
ObjManager:= TObjectManager.Create(TSQLiteSQLiteConnection.CreateConnection);
ListaProdutos:= TList<TProduto>.Create;
end;
AureliusDataset1.SetSourceList(ListaProdutos);
AureliusDataset1.Manager:= ObjManager;
end;
procedure TGerenciador.FormDestroy(Sender: TObject);
begin
ObjManager.Free;
AureliusDataset1.Free;
ListaProdutos.Free;
end;
end.