Changeset 12 for trunk/USystem.pas
- Timestamp:
- Jun 9, 2011, 1:04:45 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/USystem.pas
r11 r12 35 35 TReportColumn = class 36 36 Caption: string; 37 TypeId: Integer;38 37 TypeDef: TChronisType; 39 38 ColumnName: string; … … 76 75 end; 77 76 77 { TChronisTypeList } 78 79 TChronisTypeList = class(TListObject) 80 function FindById(Id: Integer): TChronisType; 81 function FindByTypeIndex(Id: Integer): TChronisType; 82 end; 83 78 84 { TChronisBase } 79 85 80 86 TChronisBase = class 81 Types: T ListObject; // TList<TChronisType>87 Types: TChronisTypeList; 82 88 Database: TSQLDatabase; 83 89 function AddType(Name, DataType: string; TypeIndex: TDbValueType): Integer; … … 85 91 function AddProperty(ObjectId: Integer; Name, ColumnName: string; DataType: Integer): Integer; 86 92 function AddObjectGroup(Name: string): Integer; 93 procedure LoadTypes; 87 94 constructor Create; 88 95 destructor Destroy; override; … … 92 99 93 100 implementation 101 102 { TChronisTypeList } 103 104 function TChronisTypeList.FindById(Id: Integer): TChronisType; 105 var 106 I: Integer; 107 begin 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; 112 end; 113 114 function TChronisTypeList.FindByTypeIndex(Id: Integer): TChronisType; 115 var 116 I: Integer; 117 begin 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; 122 end; 94 123 95 124 { TReportLine } … … 128 157 NewColumn.Caption := 'Id'; 129 158 NewColumn.ColumnName := 'Id'; 130 NewColumn.Type Id := Integer(vtInteger);159 NewColumn.TypeDef := Base.Types.FindByTypeIndex(Integer(vtInteger)); 131 160 for I := 0 to Properties.Count - 1 do 132 161 if Properties[I].Values['Type'] <> IntToStr(20) then begin … … 135 164 NewColumn.Caption := Properties[I].Values['Name']; 136 165 NewColumn.ColumnName := Properties[I].Values['ColumnName'];; 137 NewColumn.Type Id := StrToInt(Properties[I].Values['Type']);166 NewColumn.TypeDef := Base.Types.FindById(StrToInt(Properties[I].Values['Type'])); 138 167 end; 139 168 … … 241 270 end; 242 271 272 procedure TChronisBase.LoadTypes; 273 var 274 DbRows: TDbRows; 275 I: Integer; 276 begin 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; 293 end; 294 243 295 constructor TChronisBase.Create; 244 296 begin 245 297 Database := TSqlDatabase.Create; 246 Types := T ListObject.Create;298 Types := TChronisTypeList.Create; 247 299 end; 248 300
Note:
See TracChangeset
for help on using the changeset viewer.