Changeset 21 for trunk/USystem.pas
- Timestamp:
- Jun 16, 2011, 10:32:01 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/USystem.pas
r20 r21 7 7 uses 8 8 Classes, SysUtils, SpecializedList, SpecializedDictionary, USqlDatabase, 9 Strings, UDataTypes, Dialogs ;9 Strings, UDataTypes, Dialogs, ComCtrls, StdCtrls; 10 10 11 11 const … … 53 53 end; 54 54 55 { TReport } 56 55 57 TReport = class(TListObject) 56 58 Base: TChronisBase; … … 58 60 constructor Create; 59 61 destructor Destroy; override; 62 procedure FillListColumns(AColumns: TListColumns); 60 63 procedure Load(Obj: TChronisObject; Filter: string = ''); 61 64 end; … … 102 105 function AddGroup(Name: string; ParentGroupId: Integer = 0): Integer; 103 106 function AddObject(Name, TableName, Schema: string; GroupId: Integer): Integer; 104 function AddProperty(ObjectId: Integer; Name, ColumnName: string; CustomType: Integer): Integer; 107 function AddProperty(ObjectId: Integer; Name, ColumnName: string; 108 CustomType: Integer; Editable: Boolean): Integer; 105 109 function AddPropertyNumber(ObjectId: Integer; Name, 106 ColumnName: string; Default: Integer = 0; Min: Integer = Low(Integer);110 ColumnName: string; Editable: Boolean; Default: Integer = 0; Min: Integer = Low(Integer); 107 111 Max: Integer = High(Integer)): Integer; 108 112 function AddPropertyFloat(ObjectId: Integer; Name, 109 ColumnName: string; Default: Double = 0; Min: Double = 0;113 ColumnName: string; Editable: Boolean; Default: Double = 0; Min: Double = 0; 110 114 Max: Double = 0): Integer; 111 115 function AddPropertyDateTime(ObjectId: Integer; Name, 112 ColumnName: string; Default: TDateTime = 0; Min: TDateTime = 0;116 ColumnName: string; Editable: Boolean; Default: TDateTime = 0; Min: TDateTime = 0; 113 117 Max: TDateTime = 0): Integer; 114 118 function AddPropertyString(ObjectId: Integer; Name, ColumnName: string; 115 Default: string = ''; MaxLength: Integer = 255): Integer;119 Editable: Boolean; Default: string = ''; MaxLength: Integer = 255): Integer; 116 120 function AddPropertyRelationOne(ObjectId: Integer; Name, ColumnName: string; 117 ReferedObject: Integer): Integer;121 Editable: Boolean; ReferedObject: Integer): Integer; 118 122 function AddPropertyRelationMany(ObjectId: Integer; Name, ColumnName: string; 119 ReferedObjectProperty: Integer): Integer;123 Editable: Boolean; ReferedObjectProperty: Integer): Integer; 120 124 function AddObjectGroup(Name: string): Integer; 121 125 function AddEnumeration(Name: string): Integer; … … 188 192 '` WHERE `Object`=' + IntToStr(Obj.Id)); 189 193 Columns.Clear; 190 NewColumn := TReportColumn.Create;191 Columns.Add(NewColumn);192 NewColumn.Caption := 'Id';193 NewColumn.ColumnName := 'Id';194 NewColumn.CustomType := TDataTypeNumber.Create;195 194 196 195 for I := 0 to Properties.Count - 1 do begin … … 212 211 System.Delete(ColumnsQuery, 1, 2); 213 212 if Filter <> '' then Filter := ' WHERE ' + Filter; 214 Base.Database.Query(Values, 'SELECT ' + ColumnsQuery + ' FROM `' + Obj.Schema + '`.`' +213 Base.Database.Query(Values, 'SELECT ' + ColumnsQuery + ', `' + Obj.PrimaryKey + '` AS `SYS_PRIMARY_KEY` FROM `' + Obj.Schema + '`.`' + 215 214 Obj.Table + '`' + Filter); 216 215 for I := 0 to Values.Count - 1 do begin 217 216 NewItem := TReportLine.Create; 218 217 //NewItem.Items.Add(Values[I].Values[Obj.PrimaryKey]); 219 NewItem.Id := StrToInt(Values[I].Values[ Obj.PrimaryKey]);218 NewItem.Id := StrToInt(Values[I].Values['SYS_PRIMARY_KEY']); 220 219 for C := 0 to Columns.Count - 1 do 221 220 if not TReportColumn(Columns[C]).VirtualItem then begin … … 289 288 290 289 function TChronisBase.AddProperty(ObjectId: Integer; Name, ColumnName: string; 291 CustomType: Integer ): Integer;290 CustomType: Integer; Editable: Boolean): Integer; 292 291 var 293 292 DbRows: TDbRows; … … 301 300 Data.Add('ColumnName', ColumnName); 302 301 Data.Add('CustomType', IntToStr(CustomType)); 303 Data.Add('Editable', '1');302 Data.Add('Editable', IntToStr(Integer(Editable))); 304 303 Database.Insert(PropertyTable, Data); 305 304 Result := Database.LastInsertId; … … 311 310 312 311 function TChronisBase.AddPropertyNumber(ObjectId: Integer; Name, 313 ColumnName: string; Default: Integer = 0; Min: Integer = Low(Integer);312 ColumnName: string; Editable: Boolean; Default: Integer = 0; Min: Integer = Low(Integer); 314 313 Max: Integer = High(Integer)): Integer; 315 314 var … … 335 334 //CustomTypeId := Database.LastInsertId; 336 335 337 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId );336 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable); 338 337 finally 339 338 Data.Free; … … 343 342 344 343 function TChronisBase.AddPropertyFloat(ObjectId: Integer; Name, 345 ColumnName: string; Default: Double; Min: Double; Max: Double): Integer;344 ColumnName: string; Editable: Boolean; Default: Double; Min: Double; Max: Double): Integer; 346 345 var 347 346 DbRows: TDbRows; … … 366 365 //CustomTypeId := Database.LastInsertId; 367 366 368 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId );367 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable); 369 368 finally 370 369 Data.Free; … … 374 373 375 374 function TChronisBase.AddPropertyDateTime(ObjectId: Integer; Name, 376 ColumnName: string; Default: TDateTime; Min: TDateTime; Max: TDateTime375 ColumnName: string; Editable: Boolean; Default: TDateTime; Min: TDateTime; Max: TDateTime 377 376 ): Integer; 378 377 var … … 398 397 //CustomTypeId := Database.LastInsertId; 399 398 400 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId );399 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable); 401 400 finally 402 401 Data.Free; … … 406 405 407 406 function TChronisBase.AddPropertyString(ObjectId: Integer; Name, 408 ColumnName: string; Default: string = ''; MaxLength: Integer = 255): Integer;407 ColumnName: string; Editable: Boolean; Default: string = ''; MaxLength: Integer = 255): Integer; 409 408 var 410 409 DbRows: TDbRows; … … 428 427 //CustomTypeId := Database.LastInsertId; 429 428 430 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId );429 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable); 431 430 finally 432 431 Data.Free; … … 436 435 437 436 function TChronisBase.AddPropertyRelationOne(ObjectId: Integer; Name, 438 ColumnName: string; ReferedObject: Integer): Integer;437 ColumnName: string; Editable: Boolean; ReferedObject: Integer): Integer; 439 438 var 440 439 DbRows: TDbRows; … … 457 456 //CustomTypeId := Database.LastInsertId; 458 457 459 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId );458 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable); 460 459 finally 461 460 Data.Free; … … 465 464 466 465 function TChronisBase.AddPropertyRelationMany(ObjectId: Integer; Name, 467 ColumnName: string; ReferedObjectProperty: Integer): Integer;466 ColumnName: string; Editable: Boolean; ReferedObjectProperty: Integer): Integer; 468 467 var 469 468 DbRows: TDbRows; … … 486 485 //CustomTypeId := Database.LastInsertId; 487 486 488 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId );487 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable); 489 488 finally 490 489 Data.Free; … … 591 590 Columns.Free; 592 591 inherited Destroy; 592 end; 593 594 procedure TReport.FillListColumns(AColumns: TListColumns); 595 var 596 I: Integer; 597 NewColumn: TListColumn; 598 begin 599 AColumns.Clear; 600 for I := 0 to Columns.Count - 1 do 601 if not TReportColumn(Columns[I]).VirtualItem then begin 602 NewColumn := AColumns.Add; 603 NewColumn.Caption := TReportColumn(Columns[I]).Caption; 604 end; 593 605 end; 594 606
Note:
See TracChangeset
for help on using the changeset viewer.