📄 unitpass.pas
字号:
unit UnitPass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Mask, DBCtrls,ShellAPI;
type
TPassFrm = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Memo1: TMemo;
Button3: TButton;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Button4: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
PassFrm: TPassFrm;
strpath:String;
implementation
uses UnitDataModule,UnitMain;
{$R *.dfm}
procedure TPassFrm.Button2Click(Sender: TObject);
begin
self.Close;
end;
procedure TPassFrm.Button1Click(Sender: TObject);
var str:String;
begin
try
DataModule1.ADOConnection1.Connected:=False;
strpath:=extractfilepath(application.exename);
SaveDialog1.Filter:='*.mdb';
if SaveDialog1.Execute then
begin
if SaveDialog1.FileName='' then
exit;
str:=SaveDialog1.FileName;
CopyFile(Pchar(strpath+'data\db1.mdb'),Pchar(str),false);
SetCurrentDir(ExtractFilePath(Application.exename));
end;
DataModule1.ADOConnection1.Connected:=True;
Memo1.Text:='数据备份成功!'+'数据被成功备份到'+str+'\db1.mdb';
except
Memo1.Text:='数据备份错误!';
DataModule1.ADOConnection1.Connected:=True;
end;
end;
procedure TPassFrm.Button3Click(Sender: TObject);
var str:string;
begin
try
DataModule1.ADOConnection1.Connected:=False;
strpath:=extractfilepath(application.exename);
//SaveDialog1.Filter:='*.*';
if OpenDialog1.Execute then
begin
if OpenDialog1.FileName='' then
exit;
str:=OpenDialog1.FileName;
CopyFile(Pchar(str),Pchar(strpath+'data\db1.mdb'),false);
SetCurrentDir(ExtractFilePath(Application.exename));
end;
DataModule1.ADOConnection1.Connected:=True;
Memo1.Text:='数据恢复成功!';
except
Memo1.Text:='数据恢复错误!';
DataModule1.ADOConnection1.Connected:=True;
end;
end;
procedure TPassFrm.Button4Click(Sender: TObject);
var strpath:string;
begin
try
DataModule1.ADOConnection1.Connected:=False;
strpath:=extractfilepath(application.exename);
CopyFile(Pchar(strpath+'excel\db1.mdb'),Pchar(strpath+'data\db1.mdb'),false);
SetCurrentDir(ExtractFilePath(Application.exename));
DataModule1.ADOConnection1.Connected:=True;
Memo1.Text:='数据初始化成功!'
except
Memo1.Text:='数据初始化错误!';
DataModule1.ADOConnection1.Connected:=True;
end;
end;
procedure TPassFrm.FormShow(Sender: TObject);
begin
Memo1.Text:='建议您经常备份你的数据';
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -