Changeset 34 for trunk/USystem.pas
- Timestamp:
- Nov 24, 2011, 2:06:10 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/USystem.pas
r33 r34 187 187 procedure TReport.Load(Obj: TChronisObject; Filter: string = ''); 188 188 var 189 Properties: T DbRows;190 Values: T DbRows;189 Properties: TListProxy; 190 Values: TListProxy; 191 191 I: Integer; 192 192 C: Integer; … … 195 195 ColumnsQuery: string; 196 196 DataType: TDataType; 197 ProxyObj: TObjectProxy; 197 198 begin 198 199 Clear; … … 200 201 // Load column names 201 202 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; 205 209 Columns.Clear; 206 210 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'])); 209 214 NewColumn := TReportColumn.Create; 210 215 Columns.Add(NewColumn); 211 NewColumn.Caption := Pro perties[I].Values['Name'];212 NewColumn.ColumnName := Pro perties[I].Values['ColumnName'];216 NewColumn.Caption := ProxyObj.Properties.Values['Name']; 217 NewColumn.ColumnName := ProxyObj.Properties.Values['ColumnName']; 213 218 NewColumn.CustomType := DataType; 214 219 if (DataType is TDataTypeRelationMany) then NewColumn.VirtualItem := True; … … 216 221 217 222 // Load items 218 Values := T DbRows.Create;219 ColumnsQuery := '';223 Values := TListProxy.Create; 224 Values.Client := Base.Client; 220 225 for I := 0 to Columns.Count - 1 do 221 226 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]); 228 238 NewItem := TReportLine.Create; 229 239 //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]); 231 241 for C := 0 to Columns.Count - 1 do 232 242 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]); 234 244 end else NewItem.Items.Add(''); 235 245 Add(NewItem);
Note:
See TracChangeset
for help on using the changeset viewer.