Changeset 34 for trunk/USystem.pas


Ignore:
Timestamp:
Nov 24, 2011, 2:06:10 PM (13 years ago)
Author:
chronos
Message:
  • Modified: Report loading is now done by TChronisClient.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/USystem.pas

    r33 r34  
    187187procedure TReport.Load(Obj: TChronisObject; Filter: string = '');
    188188var
    189   Properties: TDbRows;
    190   Values: TDbRows;
     189  Properties: TListProxy;
     190  Values: TListProxy;
    191191  I: Integer;
    192192  C: Integer;
     
    195195  ColumnsQuery: string;
    196196  DataType: TDataType;
     197  ProxyObj: TObjectProxy;
    197198begin
    198199  Clear;
     
    200201    // Load column names
    201202    try
    202       Properties := TDbRows.Create;
    203       Base.Database.Query(Properties, 'SELECT * FROM `' + PropertyTable +
    204         '` WHERE `Object`=' + IntToStr(Obj.Id));
     203      Properties := TListProxy.Create;
     204      Properties.Client := Base.Client;
     205      Properties.ObjectName := PropertyTable;
     206      Properties.SchemaName := Base.Database.Database;
     207      Properties.SetCondition('Object', IntToStr(Obj.Id));
     208      Properties.Load;
    205209      Columns.Clear;
    206210
    207       for I := 0 to Properties.Count - 1 do begin
    208         DataType := GetDataType(StrToInt(Properties[I].Values['CustomType']));
     211      for I := 0 to Properties.Objects.Count - 1 do begin
     212        ProxyObj := TObjectProxy(Properties.Objects[I]);
     213        DataType := GetDataType(StrToInt(ProxyObj.Properties.Values['CustomType']));
    209214        NewColumn := TReportColumn.Create;
    210215        Columns.Add(NewColumn);
    211         NewColumn.Caption := Properties[I].Values['Name'];
    212         NewColumn.ColumnName := Properties[I].Values['ColumnName'];
     216        NewColumn.Caption := ProxyObj.Properties.Values['Name'];
     217        NewColumn.ColumnName := ProxyObj.Properties.Values['ColumnName'];
    213218        NewColumn.CustomType := DataType;
    214219        if (DataType is TDataTypeRelationMany) then NewColumn.VirtualItem := True;
     
    216221
    217222      // Load items
    218       Values := TDbRows.Create;
    219       ColumnsQuery := '';
     223      Values := TListProxy.Create;
     224      Values.Client := Base.Client;
    220225      for I := 0 to Columns.Count - 1 do
    221226        if not TReportColumn(Columns[I]).VirtualItem then
    222         ColumnsQuery := ColumnsQuery + ', `' + TReportColumn(Columns[I]).ColumnName + '`';
    223       System.Delete(ColumnsQuery, 1, 2);
    224       if Filter <> '' then Filter := ' WHERE ' + Filter;
    225       Base.Database.Query(Values, 'SELECT ' + ColumnsQuery + ', `' + Obj.PrimaryKey + '` AS `SYS_PRIMARY_KEY`  FROM `' + Obj.Schema + '`.`' +
    226         Obj.Table + '`' + Filter);
    227       for I := 0 to Values.Count - 1 do begin
     227          Values.ColumnsFilter.Add(TReportColumn(Columns[I]).ColumnName);
     228      Values.ColumnsFilter.Add(Obj.PrimaryKey);
     229      Values.ColummsFilterUse := True;
     230      Values.ObjectName := Obj.Table;
     231      Values.SchemaName := Obj.Schema;
     232      Values.Load;
     233
     234      //Base.Database.Query(Values, 'SELECT ' + ColumnsQuery + ', `' + Obj.PrimaryKey + '` AS `SYS_PRIMARY_KEY`  FROM `' + Obj.Schema + '`.`' +
     235      //  Obj.Table + '`' + Filter);
     236      for I := 0 to Values.Objects.Count - 1 do begin
     237        ProxyObj := TObjectProxy(Values.Objects[I]);
    228238        NewItem := TReportLine.Create;
    229239        //NewItem.Items.Add(Values[I].Values[Obj.PrimaryKey]);
    230         NewItem.Id := StrToInt(Values[I].Values['SYS_PRIMARY_KEY']);
     240        NewItem.Id := StrToInt(ProxyObj.Properties.Values[Obj.PrimaryKey]);
    231241        for C := 0 to Columns.Count - 1 do
    232242        if not TReportColumn(Columns[C]).VirtualItem then begin
    233           NewItem.Items.Add(Values[I].Values[TReportColumn(Columns[C]).ColumnName]);
     243          NewItem.Items.Add(ProxyObj.Properties.Values[TReportColumn(Columns[C]).ColumnName]);
    234244        end else NewItem.Items.Add('');
    235245        Add(NewItem);
Note: See TracChangeset for help on using the changeset viewer.