-
Notifications
You must be signed in to change notification settings - Fork 1
/
U_SelectDatabase.pas
90 lines (68 loc) · 2.02 KB
/
U_SelectDatabase.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
unit U_SelectDatabase;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Buttons;
type
TFrSelectDatabase = class(TForm)
Panel1: TPanel;
PathDisplay: TEdit;
Label1: TLabel;
ButtonSelectFile: TSpeedButton;
ButtonConnectionDataBase: TSpeedButton;
OpenFile: TOpenDialog;
procedure FormCreate(Sender: TObject);
procedure ButtonConnectionDataBaseClick(Sender: TObject);
procedure ButtonSelectFileClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrSelectDatabase: TFrSelectDatabase;
Connected_Validation : boolean;
FileDirectory : String;
implementation
uses U_DataModule;
{$R *.dfm}
procedure TFrSelectDatabase.FormCreate(Sender: TObject);
begin
ShowMessage(
'Erro: 26'+#13+'Não Foi Possivel Iniciar a Aplicação.'+ #13 +
'Selecione Um Banco de Dados.'
);
self.Height := 162;
self.Width := 315;
Connected_Validation := False;
end;
procedure TFrSelectDatabase.ButtonSelectFileClick(Sender: TObject);
begin
if OpenFile.Execute() then
begin
FileDirectory := OpenFile.FileName;
if FileDirectory <> '' then
begin
PathDisplay.Text := FileDirectory;
ButtonConnectionDataBase.Enabled := True;
end;
end;
end;
procedure TFrSelectDatabase.ButtonConnectionDataBaseClick(Sender: TObject);
var
path : String;
begin
if FileDirectory = '' then abort();
path := ExtractFilePath(ParamStr(0)) + 'database.db';
if ((Trim(PathDisplay.Text) <> '') and (ExtractFileExt(PathDisplay.Text) = '.db')) then
begin
if copyfile(pchar(FileDirectory),pchar(path),false) then
begin
Connected_Validation := True;
close;
end
else showMessage('Não Foi Possivel Conectar o Banco de Dados, Tente Novamente.');
end
else showMessage('Não Foi Possivel Conectar o Banco de Dados, Tente Novamente.');
end;
end.