【delphi开源代码栏目提醒】:网学会员,鉴于大家对delphi开源代码十分关注,论文会员在此为大家搜集整理了“daterestore.pas”一文,供大家参考学习!
unit daterestore;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Backup, ComCtrls, ShellCtrls, ExtCtrls, Gauges, StdCtrls;
type
tpaintthread = class(TThread)
protected
procedure execute;override;
end;
type
EPasswordInvalid = class(Exception);
type
Trestore = class(TdateBack)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Panel2Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
private
pt:Tpaintthread;
{ Private declarations }
public
{ Public declarations }
end;
var
restore: Trestore;
implementation
uses unit2;
{$R *.dfm}
procedure Tpaintthread.execute;
var i:integer;
begin
for i:=0 to 100 do
begin
restore.Gauge1.Progress:=restore.Gauge1.Progress+1;
sleep(50);
application.ProcessMessages;
end;
restore.Panel1.Enabled:=true;
restore.Panel1.Color:=clmoneygreen;
restore.Panel2.Enabled:=true;
restore.Panel2.Color:=clmoneygreen;
end;
procedure Trestore.FormCreate(Sender: TObject);
begin
pt:=tpaintthread.Create(true);
restore.Height:=205;
pathse:=true;
getdir(0,dir);
label1.Caption:=dir+'\bak';
end;
procedure Trestore.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dateback.Height:=205;
gauge1.Progress:=0;
gauge1.Visible:=false;
restore.Panel1.Enabled:=true;
restore.Panel1.Color:=clmoneygreen;
restore.Panel2.Enabled:=true;
restore.Panel2.Color:=clmoneygreen;
end;
procedure Trestore.Panel2Click(Sender: TObject);
begin
if pathse then
begin
restore.Height:=349;
pathse:=false;
panel2.Caption:='确认目录';
end
else
begin
restore.Height:=205;
pathse:=true;
panel2.Caption:='选择目录';
end;
end;
procedure Trestore.Panel1Click(Sender: TObject);
var
sr: TSearchRec;
// FileAttrs: Integer;
begin
restore.Enabled:=false;
restore.Height:=205;
panel2.Caption:='选择目录';
gauge1.Visible:=true;
panel1.Enabled:=false;
panel1.Color:=clwindow;
panel2.Enabled:=false;
panel2.Color:=clwindow;
try
begin
datamodule2.carclassQ.Close;
datamodule2.CardanganQ.Close;
//fileattrs:=faDirectory;
dir:=dir+'\data';
if FindFirst(pchar(label1.Caption+'\Carbaofei.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Carbaofei.DBF'),pchar(dir+'\Carbaofei.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Carbaofei.DBF');
if FindFirst(pchar(label1.Caption+'\Carclass.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Carclass.DBF'),pchar(dir+'\carclass.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'carclass.DBF');
if FindFirst(pchar(label1.Caption+'\Cardangan.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Cardangan.DBF'),pchar(dir+'\Cardangan.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Cardangan.DBF');
if FindFirst(pchar(label1.Caption+'\Cardriver.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Cardriver.DBF'),pchar(dir+'\Cardriver.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Cardriver.DBF');
if FindFirst(pchar(label1.Caption+'\Carlingjian.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Carlingjian.DBF'),pchar(dir+'\Carlingjian.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Carlingjian.DBF');
if FindFirst(pchar(label1.Caption+'\Carshigu.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Carshigu.DBF'),pchar(dir+'\Carshigu.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Carshigu.DBF');
if FindFirst(pchar(label1.Caption+'\Carweixiu.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Carweixiu.DBF'),pchar(dir+'\Carweixiu.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Carweixiu.DBF');
if FindFirst(pchar(label1.Caption+'\Carweizhang.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Carweizhang.DBF'),pchar(dir+'\Carweizhang.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Carweizhang.DBF');
if FindFirst(pchar(label1.Caption+'\Caryidong.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Caryidong.DBF'),pchar(dir+'\Caryidong.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Caryidong.DBF');
if FindFirst(pchar(label1.Caption+'\Caryunying.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\Caryunying.DBF'),pchar(dir+'\Caryunying.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'Caryunying.DBF');
if FindFirst(pchar(label1.Caption+'\driverjf.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\driverjf.DBF'),pchar(dir+'\driverjf.DBF'),false)
else showmessage('对不起再恢复目录中没有找到'+'driverjf.DBF');
if FindFirst(pchar(label1.Caption+'\users.DBF'),$37, sr) = 0 then
copyfile(pchar(label1.Caption+'\users.DBF'),pchar(dir+'\users.DBF'),false)
else begin
showmessage('对不起再恢复目录中没有找到'+'users.DBF');
raise EPasswordInvalid.Create('file not found!!')
end;
pt.execute;
showmessage('恢复完毕!');
end
except
messagebox(restore.handle,'出错!恢复目录中某些文件没有找到!请重新恢复!','错误',MB_OK+MB_ICONWARNING);
end;
panel1.Enabled:=true;
panel1.Color:=clmoneygreen;
panel2.Enabled:=true;
panel2.Color:=clmoneygreen;
restore.Enabled:=true;
restore.Close;
end;
end.
上一篇:
datefmu.pas
下一篇:
土木建筑工程的可持续发展教育