📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, StdActns, ActnList;
type
Tf_sjbf = class(TForm)
Label1: TLabel;
ActionList1: TActionList;
FileOpen1: TFileOpen;
FileSaveAs1: TFileSaveAs;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
function getSof():string;
function getTaf():string;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
{ Private declarations }
public
{ Public declarations }
end;
var
f_sjbf: Tf_sjbf;
mypath:string;
taf,sof:string;
implementation
uses ubak, Unit5;
{$R *.dfm}
function tf_sjbf.getSof():string;
begin
result:= sof;
end;
function tf_sjbf.getTaf():string;
begin
result:= taf;
end;
procedure Tf_sjbf.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure Tf_sjbf.Button1Click(Sender: TObject);
begin
FileOpen1.Dialog.Title :='选择备份文件路径';
FileOpen1.Dialog.Filter :='备份文件(*.mdb)|*.mdb';
if FileOpen1.Dialog.Execute then edit1.Text :=FileOpen1.Dialog.FileName;
end;
procedure Tf_sjbf.FormCreate(Sender: TObject);
begin
MyPath:=ExtractFilePath(ParamStr(0));
end;
procedure Tf_sjbf.Button2Click(Sender: TObject);
var
temptbak:tbak;
begin
if edit1.Text ='' then exit;
if application.MessageBox('确认要备份吗?','提示',mb_okcancel)=idok then begin
sof:=mypath+'data\rsda.mdb';
taf:=edit1.Text;
if ExtractFileExt(taf)<>'.mdb' then
taf:=taf+'.mdb';
try
temptbak:=tbak.Create(self);
showmessage('数据备份成功,保管好您的备份');
except
showmessage('数据备份失败,如果继续发生该问题,请联系我们');
end;
self.Close;
end;
end;
procedure Tf_sjbf.Button3Click(Sender: TObject);
var
temptbak:tbak;
begin
if edit1.Text ='' then exit;
sof:=edit1.Text;
if not FileExists(sof) then begin
showmessage('没有正确选择备份文件');
exit;
end;
if application.MessageBox('确认要还原吗,建议先备份当前数据?','提示',mb_okcancel)=idok then begin
taf:=mypath+'data\rsda.mdb';
try
temptbak:=tbak.Create(self);
showmessage('还原成功,请先退出系统,再打开才能完全恢复数据');
application.Terminate;
except
showmessage('还原失败,如果继续发生该问题,请联系我们');
end;
self.Close;
end;
end;
procedure Tf_sjbf.Button4Click(Sender: TObject);
begin
self.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -