unit Backup; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, JvComponent, JvUIB, ActnList, JvExControls, JvButton, JvTransparentButton,main, JvWaitingGradient, JvAppStorage, JvAppXMLStorage, JvFormPlacement, StdCtrls, Mask, JvExMask, JvToolEdit, JvThread, JvThreadDialog, IBServices; type TBackup_Form = class(TForm) JvUIBBackup: TJvUIBBackup; ActionList1: TActionList; Action_Run: TAction; JvTransparentButton1: TJvTransparentButton; JvAppXMLFileStorage: TJvAppXMLFileStorage; JvDirectoryEdit: TJvDirectoryEdit; JvFormStorage: TJvFormStorage; Label1: TLabel; Last: TLabel; DB: TCheckBox; JvThreadAnimateDialog: TJvThreadAnimateDialog; JvThread: TJvThread; procedure FormShow(Sender: TObject); procedure Action_RunExecute(Sender: TObject); procedure JvUIBBackupVerbose(Sender: TObject; Message: String); procedure JvThreadExecute(Sender: TObject; Params: Pointer); procedure JvThreadBegin(Sender: TObject); procedure JvThreadFinish(Sender: TObject); private FNoErr:boolean; FErr:string; public { Public declarations } end; var Backup_Form: TBackup_Form; implementation {$R *.dfm} procedure TBackup_Form.FormShow(Sender: TObject); Var L:TDateTime; begin SetCurrentDir(ExtractFileDir(ParamStr(0))); JvUIBBackup.Database:=ExpandFileName(MainForm.JvUIBDataBase.DatabaseName); JvUIBBackup.UserName:=MainForm.JvUIBDataBase.UserName; JvUIBBackup.PassWord:=MainForm.JvUIBDataBase.PassWord; L:=JvAppXMLFileStorage.ReadDateTime('Last\DB',0); If L<>0 then Last.Caption:='Останню копію було створено '+DateTimeToStr(L) else Last.Caption:='Системі не відома дата створення останньої копії'; end; procedure TBackup_Form.Action_RunExecute(Sender: TObject); begin JvThread.Execute(nil); end; procedure TBackup_Form.JvUIBBackupVerbose(Sender: TObject; Message: String); begin //Application.ProcessMessages; end; procedure TBackup_Form.JvThreadExecute(Sender: TObject; Params: Pointer); Var L:TDateTime; S:TFormatSettings; begin FNoErr:=false; Try GetLocaleFormatSettings(GetThreadLocale,S); S.DateSeparator:='.'; S.TimeSeparator:='-'; JvUIBBackup.BackupFiles.Text:=JvDirectoryEdit.Text+'PLA_Base_'+DateTimeToStr(now,S)+'.fbk'; JvUIBBackup.Run; L:=now; JvAppXMLFileStorage.WriteDateTime('Last\DB',L); Last.Caption:='Останню копію було створено '+DateTimeToStr(L); FNoErr:=true; Except On E:Exception do FErr:=E.Message; End; end; procedure TBackup_Form.JvThreadBegin(Sender: TObject); begin Hide; end; procedure TBackup_Form.JvThreadFinish(Sender: TObject); begin JvThreadAnimateDialog.CloseThreadDialogForm; If FNoErr then InfoMessage('Копію бази успішно створено') else ErrorMessage(FErr); Show; end; end.