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

📄 unitdbbuckup.pas

📁 超市管理系统
💻 PAS
字号:
unit UnitDbBuckup;

interface

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

type
  TFrameDbBuckup = class(TFrame)
    Image1: TImage;
    GroupBox1: TGroupBox;
    Image2: TImage;
    Image3: TImage;
    SaveDialog1: TSaveDialog;
    Gauge1: TGauge;
    OpenDialog1: TOpenDialog;
    procedure Image2Click(Sender: TObject);
    procedure Image3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses UnitLogin;

{$R *.dfm}

procedure TFrameDbBuckup.Image2Click(Sender: TObject);
var
  i: integer;
begin
  try
    if not savedialog1.Execute then exit;
    if FileExists(savedialog1.FileName+'.mdb') then
    begin
      if Messagebox(handle,'存在数据库重名,是否覆盖?','存盘选项',mb_iconquestion+mb_yesno)=IDNo then Exit;
    end
    else
    begin
      for i:=Gauge1.MinValue to Gauge1.MaxValue do
        Gauge1.Progress := i;
      CopyFile(PChar(DataFile),PChar(SaveDialog1.FileName+'.mdb'),True);
      Messagebox(handle,'数据库备份成功!','备份数据',mb_iconinformation+mb_ok);
    end;
  except
    Messagebox(handle,'警告:数据库备份失败!','存盘错误',mb_iconwarning+mb_ok);
  end;
end;

procedure TFrameDbBuckup.Image3Click(Sender: TObject);
var
  i: integer;
begin
  try
    if not opendialog1.Execute then exit;
    if Messagebox(handle,'警告:现有数据有可能丢失,确定还原?','确定还原',mb_iconquestion+mb_yesno)=IDNo then Exit;
    for i:=Gauge1.MinValue to Gauge1.MaxValue do
      Gauge1.Progress := i;
//    CopyFile(PChar(OpenDialog1.FileName+'.mdb'),PChar(Form1.DataFile),True);
      Messagebox(handle,'数据库还原成功!','还原数据',mb_iconinformation+mb_ok);
  except
    Messagebox(handle,'警告:数据库还原失败!','读取错误',mb_iconwarning+mb_ok);
  end;
end;

end.

⌨️ 快捷键说明

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