⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ustore.pas

📁 学生成绩管理系统开发软件
💻 PAS
字号:
unit Ustore;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, Buttons, StdCtrls, ExtCtrls;

type
  TFrmstore = class(TForm)
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    edit1: TEdit;
    Label1: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    ProgressBar1: TProgressBar;
    SpeedButton3: TSpeedButton;
    OpenDialog1: TOpenDialog;
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
  private
    { Private declarations }
  procedure restorefile(s,d:string);
  public
    { Public declarations }
  end;

var
  Frmstore: TFrmstore;

implementation

{$R *.dfm}

{ TForm2 }

procedure TFrmstore.restorefile(s, d: string);
var
FromF,ToF: file of byte;
buffer:array[0..2048] of char;
NumRead:integer;
FileLen:Longint;
begin
AssignFile(FromF,s);
reset(FromF);
AssignFile(toF,d);
rewrite(ToF);
FileLen := FileSize(FromF);
with progressbar1 do
begin
 position := 0;
 min := 0;
 max := FileLen;
 while FileLen>0 do
 begin
   BlockRead(FromF,buffer[0],sizeof(buffer),NumRead);
   FileLen  := FileLen-NumRead;
   Position := position+NumRead;
   BlockWrite(ToF,buffer[0],NumRead);
 end;
 closeFile(FromF);
 closeFile(ToF);
 showmessage('数据库恢复成功!');
 end;


end;

procedure TFrmstore.SpeedButton2Click(Sender: TObject);
var
  s,d,topath:string;
begin
if messagebox(Application.Handle,'确认要恢复数据库吗?按是将会覆盖现有的数据库',
' 提示 ',mb_ICONWarning+mb_yesno)=mrno then
exit;
 if radiobutton1.Checked then
 begin
    d   := extractFilePath(Application.ExeName)+'data.mdb';
 topath := extractFilePath(Application.ExeName)+'\dataout';
      s := topath+'\data.bak';
   if edit1.Text <>'' then
   begin
       s  := edit1.Text;
   topath := extractfilepath(s);
   end;
   if not directoryExists(topath) then
   CreateDir(topath);
   restorefile(s,d);
 end;

end;

procedure TFrmstore.SpeedButton3Click(Sender: TObject);
begin
close;
end;

procedure TFrmstore.SpeedButton1Click(Sender: TObject);
var fileName:string;
begin
opendialog1.InitialDir := ExtractFilePath(application.ExeName)+'dataout\';
if opendialog1.Execute then
 begin
 FileName := opendialog1.FileName;
 edit1.Text := Filename;
 end;
 end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -