Ignore:
Timestamp:
Nov 25, 2011, 9:17:21 AM (13 years ago)
Author:
chronos
Message:
  • Modified: More direct SQL queries replaced by TChronisClient execution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.pas

    r32 r35  
    112112  UItemView, UItemEdit, UItemAdd, ULoginForm, USettingForm, UApplicationInfo,
    113113  UCore, UImportStructureForm, UAboutForm, ULoginProfileForm, UChronisClientDirect,
    114   UItemList;
     114  UItemList, UChronisClient;
    115115
    116116{$R *.lfm}
     
    334334procedure TMainForm.LoadTree;
    335335var
    336   DbRows: TDbRows;
    337   ObjectDbRows: TDbRows;
     336  Groups: TListProxy;
     337  Obj: TObjectProxy;
     338  Objects: TListProxy;
     339  Obj2: TObjectProxy;
    338340  I: Integer;
    339341  O: Integer;
     
    348350    TopItem.SelectedIndex := 0;
    349351    try
    350       DbRows := TDbRows.Create;
    351       Core.System.Database.Query(DbRows, 'SELECT * FROM `' + ObjectGroupTable + '`');
    352       for I := 0 to DbRows.Count - 1 do begin
    353         NewNode := AddChild(TopItem, DbRows[I].Values['Name']);
     352      Groups := TListProxy.Create;
     353      Groups.Client := Core.System.Client;
     354      Groups.ObjectName := ObjectGroupTable;
     355      Groups.SchemaName := Core.System.Database.Database;
     356      Groups.Load;
     357      for I := 0 to Groups.Objects.Count - 1 do begin
     358        Obj := TObjectProxy(Groups.Objects[I]);
     359        NewNode := AddChild(TopItem, Obj.Properties.Values['Name']);
    354360        NewNode.ImageIndex := 0;
    355361        NewNode.SelectedIndex := 0;
    356         NewNode.Data := Pointer(StrToInt(DbRows[I].Values['Id']));
     362        NewNode.Data := Pointer(StrToInt(Obj.Properties.Values['Id']));
    357363        try
    358           ObjectDbRows := TDbRows.Create;
    359           Core.System.Database.Query(ObjectDbRows, 'SELECT * FROM `' + ObjectTable + '` WHERE `Group`=' + DbRows[I].Values['Id']);
    360           for O := 0 to ObjectDbRows.Count - 1 do begin
    361             NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']);
    362             NewObjectNode.Data := Pointer(StrToInt(ObjectDbRows[O].Values['Id']));
     364          Objects := TListProxy.Create;
     365          Objects.Client := Core.System.Client;
     366          Objects.ObjectName := ObjectTable;
     367          Objects.SchemaName := Core.System.Database.Database;
     368          Objects.SetCondition('Group', Obj.Properties.Values['Id']);
     369          Objects.Load;
     370          for O := 0 to Objects.Objects.Count - 1 do begin
     371            Obj2 := TObjectProxy(Objects.Objects[O]);
     372            NewObjectNode := AddChild(NewNode, Obj2.Properties.Values['Name']);
     373            NewObjectNode.Data := Pointer(StrToInt(Obj2.Properties.Values['Id']));
    363374            NewObjectNode.ImageIndex := 1;
    364375            NewObjectNode.SelectedIndex := 1;
    365376          end;
    366377        finally
    367           ObjectDbRows.Free;
     378          Objects.Free;
    368379        end;
    369380      end;
    370381      TopItem.Expand(True);
    371382    finally
    372       DbRows.Free;
     383      Groups.Free;
    373384    end;
    374385    TreeState.LoadTree(TreeView1);
Note: See TracChangeset for help on using the changeset viewer.