Changeset 3 for trunk/UCore.pas
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 MyData.lps 4 4 data.xml 5 Config.xml
-
- Property svn:ignore
-
trunk/UCore.pas
r2 r3 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, Controls, UDatabase;8 Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, UDatabase, Forms; 9 9 10 10 type … … 13 13 14 14 TCore = class(TDataModule) 15 AExit: TAction; 16 ActionList1: TActionList; 15 17 ImageList1: TImageList; 18 XMLConfig1: TXMLConfig; 19 procedure AExitExecute(Sender: TObject); 16 20 procedure DataModuleCreate(Sender: TObject); 17 21 procedure DataModuleDestroy(Sender: TObject); 18 22 private 19 { private declarations }23 Initialized: Boolean; 20 24 public 21 25 Database: TDatabase; 26 procedure LoadConfig; 27 procedure SaveConfig; 28 procedure Init; 29 procedure Done; 22 30 end; 23 31 … … 37 45 begin 38 46 Database := TDatabaseXML.Create; 39 Database.ConnectionString := 'file:///home/chronos/Projekty/test/MyData/data.xml'; 40 Database.Load; 47 end; 48 49 procedure TCore.AExitExecute(Sender: TObject); 50 begin 51 FormMain.Close; 41 52 end; 42 53 43 54 procedure TCore.DataModuleDestroy(Sender: TObject); 44 55 begin 56 Database.Free; 57 end; 58 59 procedure TCore.LoadConfig; 60 begin 61 Database.ConnectionString := XMLConfig1.GetValue('ConnectionString', 'file://' + ExtractFileDir(Application.ExeName) + '/data.xml'); 62 end; 63 64 procedure TCore.SaveConfig; 65 begin 66 XMLConfig1.SetValue('ConnectionString', Database.ConnectionString); 67 end; 68 69 procedure TCore.Init; 70 begin 71 if not Initialized then begin 72 Initialized := True; 73 LoadConfig; 74 Database.Load; 75 FormMain.ReloadList; 76 end; 77 end; 78 79 procedure TCore.Done; 80 begin 45 81 Database.Save; 46 Database.Free;82 SaveConfig; 47 83 end; 48 84
Note:
See TracChangeset
for help on using the changeset viewer.