home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 January / Chip_2000-01_cd.bin / zkuste / Delphi / kolekce / d345 / cdbu.exe / CoolDBUtilities / Example / UnitMain.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1999-09-28  |  3.8 KB  |  141 lines

  1. unit UnitMain;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   ComCtrls, CoolDBUtils, StdCtrls, Db, DbTables, ExtCtrls, Buttons;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     CoolDBBackup1: TCoolDBBackup;
  12.     CoolDBStructureRestorer1: TCoolDBStructureRestorer;
  13.     CoolDBUpdater21: TCoolDBUpdater2;
  14.     ProgressBar1: TProgressBar;
  15.     LabelProgress: TLabel;
  16.     CoolDBStructureExporter1: TCoolDBStructureExporter;
  17.     Bevel4: TBevel;
  18.     BitBtn1: TBitBtn;
  19.     RadioGroup1: TRadioGroup;
  20.     LabelInfo: TLabel;
  21.     CoolDBPack1: TCoolDBPack;
  22.     BitBtn2: TBitBtn;
  23.     procedure FormCreate(Sender: TObject);
  24.     procedure CoolDBBackup1ActionInProgress(Sender: TObject;
  25.       TablesNum: Integer; CurName: String; CurNum: Integer);
  26.     procedure CoolDBBackup1ExecuteEnd(Sender: TObject);
  27.     procedure BitBtn1Click(Sender: TObject);
  28.     procedure RadioGroup1Click(Sender: TObject);
  29.   private
  30.     Folder_DB,
  31.     Folder_Backup,
  32.     Folder_DBNew,
  33.     Folder_DBModified,
  34.     File_Structure: TFileName;
  35.   public
  36.     { Public declarations }
  37.   end;
  38.  
  39. var
  40.   Form1: TForm1;
  41.  
  42. implementation
  43.  
  44. {$R *.DFM}
  45.  
  46. procedure TForm1.FormCreate(Sender: TObject);
  47. begin
  48.   Folder_DB := ExtractFilePath(ParamStr(0)) + 'Database';
  49.   Folder_Backup := ExtractFilePath(ParamStr(0)) + 'Backup';
  50.   Folder_DBNew := ExtractFilePath(ParamStr(0)) + 'Database_New';
  51.   Folder_DBModified := ExtractFilePath(ParamStr(0)) + 'Database_Modified';
  52.   File_Structure := ExtractFilePath(ParamStr(0)) + 'Demo.dbs';
  53.  
  54.   LabelProgress.Caption := '';
  55.   RadioGroup1Click(Self);
  56. end;
  57.  
  58. procedure TForm1.CoolDBBackup1ActionInProgress(Sender: TObject;
  59.   TablesNum: Integer; CurName: String; CurNum: Integer);
  60. begin
  61.   LabelProgress.Caption := CurName;
  62.   ProgressBar1.Max := TablesNum;
  63.   ProgressBar1.Position := CurNum;
  64. end;
  65.  
  66. procedure TForm1.CoolDBBackup1ExecuteEnd(Sender: TObject);
  67. begin
  68.   LabelProgress.Caption := '';
  69.   ProgressBar1.Max := 0;
  70.   ProgressBar1.Position := 0;
  71. end;
  72.  
  73.  
  74. procedure TForm1.BitBtn1Click(Sender: TObject);
  75. begin
  76.   case RadioGroup1.ItemIndex of
  77.     0:
  78.     begin
  79.       with CoolDBBackup1 do
  80.       begin
  81.         DatabaseName := Folder_DB;
  82.         DatabaseBackupName := Folder_Backup;
  83.         Execute;
  84.       end;
  85.     end;
  86.     1:
  87.     begin
  88.       with CoolDBPack1 do
  89.       begin
  90.         DatabaseName := Folder_DB;
  91.         Execute;
  92.       end;
  93.     end;
  94.     2:
  95.     begin
  96.       with CoolDBStructureExporter1 do
  97.       begin
  98.         DatabaseName := Folder_DBModified;
  99.         FileName := File_Structure;
  100.         Execute;
  101.       end;
  102.     end;
  103.     3:
  104.     begin
  105.       with CoolDBStructureRestorer1 do
  106.       begin
  107.         DatabaseName := Folder_DBNew;
  108.         FileName := File_Structure;
  109.         Execute;
  110.       end;
  111.     end;
  112.     4:
  113.     begin
  114.       with CoolDBUpdater21 do
  115.       begin
  116.         DatabaseName := Folder_DB;
  117.         DatabaseImporterName := Folder_DBNew;
  118.         Execute;
  119.       end;
  120.     end;
  121.   end;
  122. end;
  123.  
  124. procedure TForm1.RadioGroup1Click(Sender: TObject);
  125. begin
  126.   case RadioGroup1.ItemIndex of
  127.     0:
  128.     LabelInfo.Caption := 'You can back up  existing DB you have in "Database" folder...  Copy of the database will be placed to "Backup" folder.';
  129.     1:
  130.     LabelInfo.Caption := 'You can pack your database physically removing already deleted rows';
  131.     2:
  132.     LabelInfo.Caption := 'Here you save structure of database from "Database_Modified" folder on disk "Demo.dbs"  file...';
  133.     3:
  134.     LabelInfo.Caption := 'Now restore database whose structure was previosly saved in "Demo.dbs" file... Database will be placed to "Database_New" folder.';
  135.     4:
  136.     LabelInfo.Caption := 'Now update DB in "Database" folder so that its structure will match to sttructure of DB from "Database_New" folder...';
  137.   end;
  138. end;
  139.  
  140. end.
  141.