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

📄 backup_unit.pas

📁 网上搜索来的进销存源码
💻 PAS
字号:
unit Backup_Unit;

interface

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

type
  TBackup_Form = class(TForm)
    Label1: TLabel;
    GroupBox1: TGroupBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label2: TLabel;
    Path_Edit: TEdit;
    SpeedButton1: TSpeedButton;
    Label3: TLabel;
    OpenDialog1: TOpenDialog;
    procedure SpeedButton1Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    function BackupFile: Boolean;
  public
    { Public declarations }
  end;

var
  Backup_Form: TBackup_Form;

implementation

{$R *.dfm}

function TBackup_Form.BackupFile: Boolean;
var
  ExePath: string;
begin
  ExePath := ExtractFilePath(Application.ExeName);
  if Path_Edit.Text = '' then
  begin
    Application.MessageBox('选择备份路径及文件名!', '提示', Mb_ok or Mb_IconWarning);
    Exit;
  end;
  if FileExists(Path_Edit.Text) then
  begin
    if Application.MessageBox('是否覆盖原来的文件?', '提示', Mb_YesNo or Mb_Iconquestion) = idyes then
    try
      DeleteFile(Path_Edit.Text);
    except
    end;
  end;
  try
    CopyFile(Pchar(ExePath + 'mdb\' + 'jxc.mdb'), Pchar(Path_Edit.Text), False);
    Result := True;
    Application.MessageBox('备份成功!', '提示', Mb_ok or Mb_Iconinformation);
  except
    Result := False;
    Application.MessageBox('备份失败!', '提示', Mb_ok or Mb_Iconerror);
  end;
end;

procedure TBackup_Form.SpeedButton1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    Path_Edit.Text := OpenDialog1.FileName;
  end;
end;

procedure TBackup_Form.BitBtn1Click(Sender: TObject);
begin
  BackupFile;
end;

procedure TBackup_Form.FormShow(Sender: TObject);
begin
  Path_Edit.Clear;
end;

end.

⌨️ 快捷键说明

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