【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,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.
上一篇:
backup.pas
下一篇:
按摩连锁财务管理系统|按摩连锁财务管理系统第一版