📄 backupdata_unit.pas
字号:
unit BackUpData_Unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Base_Unit, Gauges, StdCtrls, Buttons, Menus, StdActns, ActnList,
ComCtrls;
type
TfrmBackupData = class(TfrmBase)
btnBackup: TBitBtn;
btnRestore: TBitBtn;
SaveDialog: TSaveDialog;
OpenDialog: TOpenDialog;
Animate1: TAnimate;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnBackupClick(Sender: TObject);
procedure btnRestoreClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmBackupData: TfrmBackupData;
DataBaseFile: string;
implementation
uses DM_Unit, Common_Unit;
{$R *.dfm}
procedure TfrmBackupData.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
frmBackUpData := nil;
end;
procedure TfrmBackupData.btnBackupClick(Sender: TObject);
begin
inherited;
//读取配置文件中的数据连接路径
DataBaseFile := DBConFileName(FileName);
//判断是否存在相同的备份
if SaveDialog.Execute then
begin
if FileExists(SaveDialog.FileName+'.mdb') then
if Application.MessageBox('文件名重复,是否覆盖!','提示',68)=IDNo then
Exit;
Animate1.Active := True;
//复制出来进行备份
if CopyFile(PChar(DataBaseFile),PChar(SaveDialog.FileName+'.mdb'),True) then
begin
Animate1.Active := False;
Application.MessageBox('备份成功!','提示',64);
end;
end;
end;
procedure TfrmBackupData.btnRestoreClick(Sender: TObject);
begin
inherited;
DataBaseFile := DBConFileName(FileName);
if OpenDialog.Execute then
begin
Animate1.Active := True;
//复制文件到另一个目录
if CopyFile(PChar(OpenDialog.FileName),PChar(DataBaseFile), False) then
begin
Animate1.Active := False;
Application.MessageBox('还原成功!','提示',64);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -