Skip to content

Commit

Permalink
version 2.1.1
Browse files Browse the repository at this point in the history
» add database selection
» fix bugs
» new features
  • Loading branch information
miguelhp373 committed Mar 5, 2022
1 parent 6df444e commit b2f1b39
Show file tree
Hide file tree
Showing 22 changed files with 524 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
__history
__recovery
Win32
Win64
Win64
exe/mydatabase/database.db
3 changes: 2 additions & 1 deletion NumismaticPro.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ uses
U_Menu in 'U_Menu.pas' {FrMenu},
U_DataModule in 'U_DataModule.pas' {DataModule1: TDataModule},
U_FrInfo in 'U_FrInfo.pas' {FrInfo},
U_Config in 'U_Config.pas' {FrConfig};
U_Config in 'U_Config.pas' {FrConfig},
U_SelectDatabase in 'U_SelectDatabase.pas' {FrSelectDatabase};

{$R *.res}

Expand Down
4 changes: 4 additions & 0 deletions NumismaticPro.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
<Form>FrConfig</Form>
<FormType>dfm</FormType>
</DCCReference>
<DCCReference Include="U_SelectDatabase.pas">
<Form>FrSelectDatabase</Form>
<FormType>dfm</FormType>
</DCCReference>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
Expand Down
18 changes: 16 additions & 2 deletions NumismaticPro.dproj.local
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,24 @@
<Transaction>2022/02/12 19:41:05.000.964,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.dfm=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_DataModule.dfm</Transaction>
<Transaction>2022/02/12 19:41:05.000.964,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_DataModule.pas</Transaction>
<Transaction>2022/02/12 19:58:39.000.400,=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas</Transaction>
<Transaction>2022/02/12 19:59:05.000.404,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.dfm=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_FrInfo.dfm</Transaction>
<Transaction>2022/02/12 19:59:05.000.404,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_FrInfo.pas</Transaction>
<Transaction>2022/02/12 19:59:05.000.404,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.dfm=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_FrInfo.dfm</Transaction>
<Transaction>2022/02/28 21:24:54.000.012,=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas</Transaction>
<Transaction>2022/02/28 21:25:16.000.149,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_Config.dfm=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.dfm</Transaction>
<Transaction>2022/02/28 21:25:16.000.149,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_Config.pas=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas</Transaction>
</Transactions>
<Transaction>2022/03/05 14:49:03.482,=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas</Transaction>
<Transaction>2022/03/05 14:52:36.423,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_SelectDatabase.pas=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.pas</Transaction>
<Transaction>2022/03/05 14:52:36.423,C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\U_SelectDatabase.dfm=C:\Users\migue\OneDrive\Documentos\Projetos\Delphi\NumismaticProDesktop\Unit1.dfm</Transaction>
</Transactions> <ProjectSortOrder AutoSort="0" SortType="0">
<File Path="U_Config.pas"/>
<File Path="U_Config.dfm"/>
<File Path="U_DataModule.pas"/>
<File Path="U_DataModule.dfm"/>
<File Path="U_FrInfo.pas"/>
<File Path="U_FrInfo.dfm"/>
<File Path="U_Menu.pas"/>
<File Path="U_Menu.dfm"/>
<File Path="U_SelectDatabase.pas"/>
<File Path="U_SelectDatabase.dfm"/>
</ProjectSortOrder>
</BorlandProject>
Binary file modified NumismaticPro.res
Binary file not shown.
Binary file modified Setup/Setup.exe
Binary file not shown.
Binary file modified Setup/Setup.rar
Binary file not shown.
Binary file added Setup/compressed/Setup_NPD_vs2.0.1.rar
Binary file not shown.
Binary file added Setup/compressed/Setup_NPD_vs2.1.1.rar
Binary file not shown.
Binary file added Setup/exe/Setup_NPD_vs2.0.1.1.exe
Binary file not shown.
Binary file added Setup/exe/Setup_NPD_vs2.1.1.exe
Binary file not shown.
63 changes: 51 additions & 12 deletions U_Config.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ object FrConfig: TFrConfig
Left = 0
Top = 0
Caption = 'Configura'#231#245'es'
ClientHeight = 457
ClientHeight = 192
ClientWidth = 357
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Expand Down Expand Up @@ -132,36 +132,75 @@ object FrConfig: TFrConfig
FFFCFFFFFFFC}
OldCreateOrder = False
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 357
Height = 457
Height = 192
Align = alClient
BevelOuter = bvNone
TabOrder = 0
ExplicitLeft = 256
ExplicitTop = 176
ExplicitWidth = 185
ExplicitHeight = 41
object PageControl1: TPageControl
AlignWithMargins = True
Left = 3
Top = 3
Width = 351
Height = 451
Height = 186
ActivePage = Page01
Align = alClient
TabOrder = 0
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 357
ExplicitHeight = 457
object Page01: TTabSheet
Caption = ' Banco de Dados '
Caption = 'Banco de Dados'
object SaveBackupButton: TSpeedButton
Left = 16
Top = 74
Width = 307
Height = 33
Cursor = crHandPoint
Caption = 'Criar Backup Do Banco de Dados'
OnClick = SaveBackupButtonClick
end
object Label1: TLabel
Left = 16
Top = 16
Width = 61
Height = 21
Alignment = taRightJustify
AutoSize = False
Caption = 'Meu Backup:'
Layout = tlCenter
end
object pathBackup: TEdit
AlignWithMargins = True
Left = 16
Top = 43
Width = 307
Height = 22
AutoSize = False
BevelInner = bvLowered
BorderStyle = bsNone
Color = clScrollBar
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
ReadOnly = True
TabOrder = 0
end
end
end
end
object SaveDialog1: TSaveDialog
DefaultExt = '.db'
Filter = 'Todos os Arquivos|*.db'
InitialDir = '/downloads'
Title = 'Selecione a Pasta Para Salvar o Backup do Banco de Dados'
Left = 23
Top = 139
end
end
108 changes: 107 additions & 1 deletion U_Config.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,130 @@ interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.ComCtrls;
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.ComCtrls,
Vcl.StdCtrls, Vcl.Buttons, Data.DB, Datasnap.DBClient, Datasnap.Provider;

type
TFrConfig = class(TForm)
Panel1: TPanel;
PageControl1: TPageControl;
Page01: TTabSheet;
SaveBackupButton: TSpeedButton;
pathBackup: TEdit;
SaveDialog1: TSaveDialog;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure SaveBackupButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure SearchFilePathInDatabase(tip: String);
end;

var
FrConfig: TFrConfig;
PathDatabaseDefault : String;

implementation

{$R *.dfm}

uses U_DataModule;

procedure TFrConfig.FormCreate(Sender: TObject);
begin
PathDatabaseDefault := ExtractFilePath(ParamStr(0));
SearchFilePathInDatabase('Search');
end;

procedure TFrConfig.SaveBackupButtonClick(Sender: TObject);
var
loadFilePath : String;
saveFilePath : String;
begin
loadFilePath := PathDatabaseDefault + 'database.db';

if SaveDialog1.Execute() then
begin
saveFilePath := SaveDialog1.FileName;
copyfile(pchar(loadFilePath),pchar(saveFilePath),false);

pathBackup.Text := saveFilePath;
end;

showmessage(SaveDialog1.FileName);

SearchFilePathInDatabase('File');
end;

procedure TFrConfig.SearchFilePathInDatabase(tip: String);
begin

DataModule1.SqlActions.Close;

if tip = 'Search' then
begin

With DataModule1.SqlActions do
begin
SQL.Clear;
SQL.Add('SELECT DatabaseBackupPath FROM ConfigTable');
Open();

if FieldByName('DatabaseBackupPath').AsString <> '' then pathBackup.Text := FieldByName('DatabaseBackupPath').AsString;
abort;
end;

end;

if tip = 'File' then
begin
With DataModule1.SqlActions do
begin
SQL.Clear;
SQL.Add('SELECT DatabaseBackupPath FROM ConfigTable');
Open();

if FieldByName('DatabaseBackupPath').AsString = '' then
begin

With DataModule1.SqlActions do
begin
SQL.Clear;
SQL.Add('INSERT INTO ConfigTable');
SQL.Add('(DatabaseBackupPath, BackupDate)VALUES(:path, :dateBackup)');
ParamByName('path' ).AsString := pathBackup.Text;
ParamByName('dateBackup').AsString := DatetimeToStr(now());

ExecSQL();

ShowMessage('Backup Salvo Com Sucesso!');
abort;
end;

end
else
begin
With DataModule1.SqlActions do
begin
SQL.Clear;
SQL.Add('UPDATE ConfigTable SET');
SQL.Add('DatabaseBackupPath = :path, BackupDate = :dateBackup');
ParamByName('path' ).AsString := pathBackup.Text;
ParamByName('dateBackup').AsString := DatetimeToStr(now());

ExecSQL();

ShowMessage('Backup Salvo Com Sucesso!');
abort;
end;
end;

end;
end;


end;

end.
31 changes: 25 additions & 6 deletions U_DataModule.pas
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,51 @@ TDataModule1 = class(TDataModule)
{ Private declarations }
public
{ Public declarations }
procedure ConnectionExecute(pathFile : String);
end;

var
DataModule1: TDataModule1;
DataModule1 : TDataModule1;

implementation

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

uses U_SelectDatabase, U_Menu;

procedure TDataModule1.ConnectionExecute(pathFile : String);
begin
SqliteConnection.Params.Values['DataBase'] := pathFile + 'database.db';
SqliteConnection.Connected := True;
end;

procedure TDataModule1.DataModuleCreate(Sender: TObject);
var
error : boolean;
path : String;
begin
path := ExtractFilePath(ParamStr(0));

try
SqliteConnection.Params.Values['DataBase'] := path + 'database.db';

SqliteConnection.Connected := True;
ConnectionExecute(path);
except
on e:exception do
begin
ShowMessage('Erro: 26'+#13+'Não Foi Possivel Iniciar a Aplicação.'+ #13 +'Banco de Dados Não Encontrado!'+#13+'Reinstale a Aplicação.');
Application.Terminate()
Connected_Validation := False;

Application.CreateForm(TFrSelectDatabase,FrSelectDatabase);
FrSelectDatabase.ShowModal;

if Connected_Validation = True then
begin
ConnectionExecute(path);
FrSelectDatabase.Free;
Application.CreateForm(TFrMenu,FrMenu);
FrMenu.ShowModal;
end;

end;
end;

Expand Down
3 changes: 1 addition & 2 deletions U_Menu.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ object FrMenu: TFrMenu
Menu = MainMenu1
OldCreateOrder = False
Position = poScreenCenter
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
Expand Down Expand Up @@ -646,8 +647,6 @@ object FrMenu: TFrMenu
Top = 224
object Configuraes1: TMenuItem
Caption = 'Configura'#231#245'es'
Enabled = False
Visible = False
OnClick = Configuraes1Click
end
object Info1: TMenuItem
Expand Down
Loading

0 comments on commit b2f1b39

Please sign in to comment.