Changeset 16 for trunk/USystem.pas
- Timestamp:
- Jun 13, 2011, 12:43:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/USystem.pas
r15 r16 48 48 CustomType: TDataType; 49 49 ColumnName: string; 50 VirtualItem: Boolean; 50 51 end; 51 52 … … 104 105 function AddPropertyString(ObjectId: Integer; Name, ColumnName: string; 105 106 Default: string = ''; MaxLength: Integer = 255): Integer; 107 function AddPropertyRelationOne(ObjectId: Integer; Name, ColumnName: string; 108 ReferedObject: Integer): Integer; 109 function AddPropertyRelationMany(ObjectId: Integer; Name, ColumnName: string; 110 ReferedObjectProperty: Integer): Integer; 106 111 function AddObjectGroup(Name: string): Integer; 107 112 function AddEnumeration(Name: string): Integer; … … 164 169 NewColumn: TReportColumn; 165 170 ColumnsQuery: string; 171 DataType: TDataType; 166 172 begin 167 173 Clear; … … 179 185 NewColumn.CustomType := TDataTypeNumber.Create; 180 186 181 for I := 0 to Properties.Count - 1 do 182 if Properties[I].Values['CustomType'] <> IntToStr(Integer(vtRelationMany)) then begin187 for I := 0 to Properties.Count - 1 do begin 188 DataType := GetDataType(StrToInt(Properties[I].Values['CustomType'])); 183 189 NewColumn := TReportColumn.Create; 184 190 Columns.Add(NewColumn); 185 191 NewColumn.Caption := Properties[I].Values['Name']; 186 192 NewColumn.ColumnName := Properties[I].Values['ColumnName']; 187 NewColumn.CustomType := GetDataType(StrToInt(Properties[I].Values['CustomType'])); 193 NewColumn.CustomType := DataType; 194 if (DataType is TDataTypeRelationMany) then NewColumn.VirtualItem := True; 188 195 end; 189 196 … … 192 199 ColumnsQuery := ''; 193 200 for I := 0 to Columns.Count - 1 do 201 if not TReportColumn(Columns[I]).VirtualItem then 194 202 ColumnsQuery := ColumnsQuery + ', `' + TReportColumn(Columns[I]).ColumnName + '`'; 195 203 System.Delete(ColumnsQuery, 1, 2); … … 202 210 NewItem.Id := StrToInt(Values[I].Values[Obj.PrimaryKey]); 203 211 for C := 0 to Properties.Count - 1 do 204 if Properties[C].Values['CustomType'] <> IntToStr(Integer(vtRelationMany))then begin205 NewItem.Items.Add(Values[I].Values[ Properties[C].Values['ColumnName']]);206 end ;212 if not TReportColumn(Columns[C]).VirtualItem then begin 213 NewItem.Items.Add(Values[I].Values[TReportColumn(Columns[C]).ColumnName]); 214 end else NewItem.Items.Add(''); 207 215 Add(NewItem); 208 216 end; … … 328 336 Data.Add('Default', Default); 329 337 Database.Insert(TypeString, Data); 338 //CustomTypeId := Database.LastInsertId; 339 340 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId); 341 finally 342 Data.Free; 343 DbRows.Free; 344 end; 345 end; 346 347 function TChronisBase.AddPropertyRelationOne(ObjectId: Integer; Name, 348 ColumnName: string; ReferedObject: Integer): Integer; 349 var 350 DbRows: TDbRows; 351 Data: TDictionaryStringString; 352 CustomTypeId: Integer; 353 begin 354 try 355 DbRows := TDbRows.Create; 356 Data := TDictionaryStringString.Create; 357 358 Data.Clear; 359 Data.Add('Type', IntToStr(Integer(vtRelationOne))); 360 Database.Insert(CustomTypeTableName, Data); 361 CustomTypeId := Database.LastInsertId; 362 363 Data.Clear; 364 Data.Add('CustomType', IntToStr(CustomTypeId)); 365 Data.Add('Object', IntToStr(ReferedObject)); 366 Database.Insert(TypeRelationOne, Data); 367 //CustomTypeId := Database.LastInsertId; 368 369 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId); 370 finally 371 Data.Free; 372 DbRows.Free; 373 end; 374 end; 375 376 function TChronisBase.AddPropertyRelationMany(ObjectId: Integer; Name, 377 ColumnName: string; ReferedObjectProperty: Integer): Integer; 378 var 379 DbRows: TDbRows; 380 Data: TDictionaryStringString; 381 CustomTypeId: Integer; 382 begin 383 try 384 DbRows := TDbRows.Create; 385 Data := TDictionaryStringString.Create; 386 387 Data.Clear; 388 Data.Add('Type', IntToStr(Integer(vtRelationMany))); 389 Database.Insert(CustomTypeTableName, Data); 390 CustomTypeId := Database.LastInsertId; 391 392 Data.Clear; 393 Data.Add('CustomType', IntToStr(CustomTypeId)); 394 Data.Add('ObjectProperty', IntToStr(ReferedObjectProperty)); 395 Database.Insert(TypeRelationMany, Data); 330 396 //CustomTypeId := Database.LastInsertId; 331 397
Note:
See TracChangeset
for help on using the changeset viewer.