📄 restoredb.pas
字号:
Unit RestoreDB;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, FileCtrl, AAFont, AACtrls, LbButton;
Type
tRestoreDBForm = Class(TForm)
StaticText2: TStaticText;
StaticText4: TStaticText;
FileListBox1: TFileListBox;
LbButton3: TLbButton;
LbButton4: TLbButton;
LbButton1: TLbButton;
LbButton2: TLbButton;
AALabel1: TAALabel;
Procedure FormClose(Sender: TObject; Var Action: TCloseAction);
Procedure FormCreate(Sender: TObject);
Procedure Button6Click(Sender: TObject);
Procedure Button5Click(Sender: TObject);
Procedure Button4Click(Sender: TObject);
Procedure Button7Click(Sender: TObject);
Private
{ Private declarations }
Public
{ Public declarations }
End;
Var
RestoreDBForm : tRestoreDBForm;
Rpaths : String;
currdir1 : String;
Const
DBNAME : String = 'X.MDB';
Implementation
Uses DM, MainUnit, CompactMDB;
{$R *.dfm}
Procedure tRestoreDBForm.FormClose(Sender: TObject; Var Action: TCloseAction);
Begin
Action := cafree;
RestoreDBForm := Nil;
End;
Procedure tRestoreDBForm.FormCreate(Sender: TObject);
Begin
LbButton2.Visible := true;
LbButton1.Enabled := false;
currdir1 := ExtractFilePath(Application.ExeName);
ChDir(currdir1);
StaticText4.Caption :=
'可选择恢复存放文件夹后再开始,默认为当前目录下的BACKUP文件夹中。';
If DirectoryExists(currdir1 + '\backup') Then
FileListBox1.Directory := currdir1 + '\backup';
End;
Procedure tRestoreDBForm.Button6Click(Sender: TObject);
Var
BOL : Boolean;
Begin
// BOL := SelectDirectory('选择备份存放路径', DM.CURRDIR, Rpaths);
BOL := SelectDirectory(Rpaths, [sdAllowCreate, sdPerformCreate], 0);
If BOL Then StaticText4.Caption := '源文件夹:' + Rpaths;
FileListBox1.Directory := Rpaths;
RestoreDBForm.Show;
End;
Procedure tRestoreDBForm.Button5Click(Sender: TObject);
Begin
If FileListBox1.FileName = '' Then Begin
Application.MessageBox('未选择你要恢复的备份文件!请先在下面列表中选择!',
'提示信息', mb_OK + MB_ICONERROR);
Exit;
End;
LbButton2.Visible := false;
StaticText2.Caption := '正在准备恢复数据库';
Application.ProcessMessages;
If Not FileExists(FileListBox1.FileName) Then Begin
Application.MessageBox('数据库恢复失败!没有备份的数据库可用于恢复!',
'提示信息', mb_OK + MB_ICONERROR);
Button7Click(self);
Exit;
End;
ChDir(currdir1);
If FileExists(DBNAME) Then DeleteFile(DBNAME);
DM.DataModule2.ADOConnection1.Close;
StaticText2.Caption := '正在恢复数据库....';
CopyFile(pchar(FileListBox1.FileName), pchar(DBNAME), false);
DM.DataModule2.ADOConnection1.open;
StaticText2.Caption := '成功恢复数据库!';
LbButton1.Enabled := true;
LbButton4.Visible := false;
End;
Procedure tRestoreDBForm.Button4Click(Sender: TObject);
Begin
ChDir(currdir1);
Close;
End;
Procedure tRestoreDBForm.Button7Click(Sender: TObject);
Begin
ChDir(currdir1);
Close;
End;
End.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -