Changeset 12 for trunk/USystem.pas


Ignore:
Timestamp:
Jun 9, 2011, 1:04:45 PM (13 years ago)
Author:
george
Message:
  • Fixed: Display edit controls according property type.
  • Added: Interface language translation.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/USystem.pas

    r11 r12  
    3535  TReportColumn = class
    3636    Caption: string;
    37     TypeId: Integer;
    3837    TypeDef: TChronisType;
    3938    ColumnName: string;
     
    7675  end;
    7776
     77  { TChronisTypeList }
     78
     79  TChronisTypeList = class(TListObject)
     80    function FindById(Id: Integer): TChronisType;
     81    function FindByTypeIndex(Id: Integer): TChronisType;
     82  end;
     83
    7884  { TChronisBase }
    7985
    8086  TChronisBase = class
    81     Types: TListObject;  // TList<TChronisType>
     87    Types: TChronisTypeList;
    8288    Database: TSQLDatabase;
    8389    function AddType(Name, DataType: string; TypeIndex: TDbValueType): Integer;
     
    8591    function AddProperty(ObjectId: Integer; Name, ColumnName: string; DataType: Integer): Integer;
    8692    function AddObjectGroup(Name: string): Integer;
     93    procedure LoadTypes;
    8794    constructor Create;
    8895    destructor Destroy; override;
     
    9299
    93100implementation
     101
     102{ TChronisTypeList }
     103
     104function TChronisTypeList.FindById(Id: Integer): TChronisType;
     105var
     106  I: Integer;
     107begin
     108  I := 0;
     109  while (I < Count) and (TChronisType(Items[I]).Id <> Id) do Inc(I);
     110  if I < Count then Result := TChronisType(Items[I])
     111    else Result := nil;
     112end;
     113
     114function TChronisTypeList.FindByTypeIndex(Id: Integer): TChronisType;
     115var
     116  I: Integer;
     117begin
     118  I := 0;
     119  while (I < Count) and (TChronisType(Items[I]).TypeIndex <> Id) do Inc(I);
     120  if I < Count then Result := TChronisType(Items[I])
     121    else Result := nil;
     122end;
    94123
    95124{ TReportLine }
     
    128157      NewColumn.Caption := 'Id';
    129158      NewColumn.ColumnName := 'Id';
    130       NewColumn.TypeId := Integer(vtInteger);
     159      NewColumn.TypeDef := Base.Types.FindByTypeIndex(Integer(vtInteger));
    131160      for I := 0 to Properties.Count - 1 do
    132161      if Properties[I].Values['Type'] <> IntToStr(20) then begin
     
    135164        NewColumn.Caption := Properties[I].Values['Name'];
    136165        NewColumn.ColumnName := Properties[I].Values['ColumnName'];;
    137         NewColumn.TypeId := StrToInt(Properties[I].Values['Type']);
     166        NewColumn.TypeDef := Base.Types.FindById(StrToInt(Properties[I].Values['Type']));
    138167      end;
    139168
     
    241270end;
    242271
     272procedure TChronisBase.LoadTypes;
     273var
     274  DbRows: TDbRows;
     275  I: Integer;
     276begin
     277  try
     278    DbRows := TDbRows.Create;
     279    Types.Clear;
     280    Database.Select(DbRows, PropertyTypeTable);
     281    for I := 0 to DbRows.Count - 1 do begin
     282      with TChronisType(Types.AddNew(TChronisType.Create)) do
     283      with DbRows[I] do begin
     284        Id := StrToInt(Values['Id']);
     285        TypeIndex := StrToInt(Values['TypeIndex']);
     286        DbType := Values['DbType'];
     287        //Parent := StrToInt(Values['Parent']);
     288      end;
     289    end;
     290  finally
     291    DbRows.Free;
     292  end;
     293end;
     294
    243295constructor TChronisBase.Create;
    244296begin
    245297  Database := TSqlDatabase.Create;
    246   Types := TListObject.Create;
     298  Types := TChronisTypeList.Create;
    247299end;
    248300
Note: See TracChangeset for help on using the changeset viewer.