procedure SelectWID_VST(VST: TVirtualStringTree);
var
ADODataSet, ADODataSet_sw, ADODataSet_oc: TADODataSet;
TreeObject: TTreeDataClass;
Wurzel, Wurzel_oc: PVirtualNode;
rs_sw, rs_oc: _Recordset;
function AddVSTObject(avst: TCustomVirtualStringTree; aNode: PVirtualNode; aObject: TObject): PVirtualNode;
var
Data: PTreeData;
begin
Result := avst.AddChild(aNode);
avst.ValidateNode(Result, False);
data := avst.GetNodeData(Result);
data^.FObject := aObject;
end;
begin
ADODataSet:= TADODataSet.Create(
nil);
ADODataSet.Connection:=DataModule_DBConnect.ADOConnection1;
ADODataSet_sw:= TADODataSet.Create(
nil);
ADODataSet_sw.Connection:=DataModule_DBConnect.ADOConnection1;
ADODataSet_oc:= TADODataSet.Create(
nil);
ADODataSet_oc.Connection:=DataModule_DBConnect.ADOConnection1;
VST.BeginUpdate;
VST.NodeDataSize:= SizeOf(TTreeData);
VST.DeleteChildren(VST.RootNode, true);
try
ADODataSet.CommandText:='
Select distinct(tbl_w_daten.fk_w_id), tbl_w_daten.username, (tbl_umgebung.env || '+'
''
- ''
'
+'
|| tbl_umgebung.beschreibung)as env from tbl_w_daten, tbl_umgebung, tbl_w_id where tbl_w_id.fk_env_id '
+'
= tbl_umgebung.pk_env_id and tbl_w_id.pk_w_id = tbl_w_daten.fk_w_id order by tbl_w_daten.fk_w_id';
ADODataSet.Open;
rs:=ADODataSet.Recordset;
while not rs.EOF
do
begin
TreeObject:= TTreeDataClass.Create;
TreeObject.WID:=FormatFloat('
000000', rs.Fields['
FK_W_ID'].Value);
TreeObject.ICON:=0;
Wurzel:= AddVSTObject(VST,
Nil, TreeObject);
ADODataSet_sw.CommandText:='
select tbl_w_daten.fk_w_id, tbl_application.pk_sw_product_id, tbl_application.pk_sw_product_id, tbl_application.sw_product, tbl_w_art.w_art from tbl_application, tbl_w_daten, tbl_w_art where tbl_w_daten.fk_w_id='
+VarToStr(rs.Fields['
FK_W_ID'].Value)+'
and tbl_w_daten.fk_sw_product_id = tbl_application.pk_sw_product_id'
+'
and tbl_w_daten.fk_w_art_id = tbl_w_art.pk_w_art_id';
ADODataSet_sw.open;
rs_sw:=ADODataSet_sw.Recordset;
while not rs_sw.EOF
do
begin
TreeObject:= TTreeDataClass.Create;
TreeObject.ICON:=1;
Try
If VarToStr(rs_sw.Fields['
sw_product'].Value) > '
'
Then
Begin
TreeObject.SW:=VarToStr(rs_sw.Fields['
sw_product'].Value);
TreeObject.USER:=VarToStr(rs.Fields['
USERNAME'].Value);
TreeObject.ART:=VarToStr(rs_sw.Fields['
W_ART'].Value);
TreeObject.ENV:=VarToStr(rs.Fields['
ENV'].Value);
ADODataSet_oc.CommandText:='
select cm_no from tbl_cm_no where fk_w_id='+VarToStr(rs.Fields['
FK_W_ID'].Value)
+'
and fk_sw_product_id='+VarToStr(rs_sw.Fields['
PK_SW_PRODUCT_ID'].Value);
ADODataSet_oc.Open;
rs_oc:=ADODataSet_oc.Recordset;
Wurzel_oc:=AddVSTObject(VST, VST.AddChild(Wurzel, TreeObject),
nil);
while not rs_oc.EOF
do
begin
TreeObject:=TTreeDataClass.Create;
TreeObject.ICON:=1;
try
if VarToStr(rs_oc.Fields['
CM_NO'].Value) > '
'
then
begin
TreeObject.OC:=VarToStr(rs_oc.Fields['
CM_NO'].Value);
AddVSTObject(VST, Wurzel_oc, TreeObject);
end;
except
TreeObject.Free;
end;
rs_oc.MoveNext;
end;
ADODataSet_oc.Close;
rs_oc.Close;
AddVstObject(VST,wurzel, TreeObject);
end;
except
TreeObject.Free;
end;
rs_sw.MoveNext;
end;
ADODataSet_sw.Close;
rs_sw.Close;
rs.MoveNext;
end;
except
on e :
Exception do
begin
MDialog(e.
Message,mtError,[mbOK]);
end;
end;
ADODataSet.Close;
ADODataSet.Free;
VST.EndUpdate;