Changeset 3 for trunk/UCore.pas


Ignore:
Timestamp:
Jan 18, 2015, 5:25:37 PM (10 years ago)
Author:
chronos
Message:
  • Added: Support for editing String and DateTime value types in record edit form.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        33MyData.lps
        44data.xml
         5Config.xml
  • trunk/UCore.pas

    r2 r3  
    66
    77uses
    8   Classes, SysUtils, FileUtil, Controls, UDatabase;
     8  Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, UDatabase, Forms;
    99
    1010type
     
    1313
    1414  TCore = class(TDataModule)
     15    AExit: TAction;
     16    ActionList1: TActionList;
    1517    ImageList1: TImageList;
     18    XMLConfig1: TXMLConfig;
     19    procedure AExitExecute(Sender: TObject);
    1620    procedure DataModuleCreate(Sender: TObject);
    1721    procedure DataModuleDestroy(Sender: TObject);
    1822  private
    19     { private declarations }
     23    Initialized: Boolean;
    2024  public
    2125    Database: TDatabase;
     26    procedure LoadConfig;
     27    procedure SaveConfig;
     28    procedure Init;
     29    procedure Done;
    2230  end;
    2331
     
    3745begin
    3846  Database := TDatabaseXML.Create;
    39   Database.ConnectionString := 'file:///home/chronos/Projekty/test/MyData/data.xml';
    40   Database.Load;
     47end;
     48
     49procedure TCore.AExitExecute(Sender: TObject);
     50begin
     51  FormMain.Close;
    4152end;
    4253
    4354procedure TCore.DataModuleDestroy(Sender: TObject);
    4455begin
     56  Database.Free;
     57end;
     58
     59procedure TCore.LoadConfig;
     60begin
     61  Database.ConnectionString := XMLConfig1.GetValue('ConnectionString', 'file://' + ExtractFileDir(Application.ExeName) + '/data.xml');
     62end;
     63
     64procedure TCore.SaveConfig;
     65begin
     66  XMLConfig1.SetValue('ConnectionString', Database.ConnectionString);
     67end;
     68
     69procedure TCore.Init;
     70begin
     71  if not Initialized then begin
     72    Initialized := True;
     73    LoadConfig;
     74    Database.Load;
     75    FormMain.ReloadList;
     76  end;
     77end;
     78
     79procedure TCore.Done;
     80begin
    4581  Database.Save;
    46   Database.Free;
     82  SaveConfig;
    4783end;
    4884
Note: See TracChangeset for help on using the changeset viewer.