爱
爱上猫的鱼
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure CreatWorkPart(tvTmp: TTreeView;
TmpConnection: TADOConnection);
var i: integer;
TmpQuery: TADOQuery;
RootNode: TTreeNode;//[red]TTreeNode类型的意思[/red]
FirstNode: TTreeNode;
FirstNodeID: String;
SecondNodeID: String;
FirstNodeText: String;
SecondNodeText: String;
begin
TmpQuery:= TADOQuery.Create(nil);
TmpQuery.Connection:= TmpConnection;
try
TmpQuery.SQL.Clear;
TmpQuery.SQL.Add(' select C.DeviceID,C.DeviceName, ');
TmpQuery.SQL.Add(' P.OperatorID,O.OperatorName ');
TmpQuery.SQL.Add(' from ck_ptDevice C ');
TmpQuery.SQL.Add(' left Outer join ck_ptDeviceOp P ');
TmpQuery.SQL.Add(' on ( P.DeviceID = C.DeviceID ) ');
TmpQuery.SQL.Add(' left outer join ck_Operator O ');
TmpQuery.SQL.Add(' on (O.OperatorID = P.OperatorID) ');
TmpQuery.Open;
tvTmp.Items.Clear;
RootNode:= tvTmp.Items.AddFirst(nil,'加工机器');
FirstNode:= nil;
While not TmpQuery.Eofdo
begin
if not TmpQuery.FieldByName('DeviceID').IsNull then
begin
FirstNodeID:=TmpQuery.FieldByName('DeviceID').AsString;
FirstNodeText:=TmpQuery.FieldByName('DeviceName').AsString;
end
else
begin
FirstNodeID:= '空';
FirstNodeText:= '空';
end;
if not TmpQuery.FieldByName('OperatorID').IsNull then
begin
SecondNodeID:=TmpQuery.FieldByName('OperatorID').AsString;
SecondNodeText:=TmpQuery.FieldByName('OperatorName').AsString;
end
else
begin
SecondNodeID:= '空';
SecondNodeText:= '空';
end;
if not (FirstNode = nil) then
begin
if FirstNodeID = Copy(FirstNode.Text,Pos('(',FirstNode.Text)+1,3) then
//上边那一段需要解释Copy(FirstNode.Text,Pos('(',FirstNode.Text)+1,3)
begin
tvTmp.Items.AddChildObject(FirstNode,//FirstNode放在这的意义?
SecondNodeText+'('+SecondNodeID+')',nil);//要解释整段
TmpQuery.Next;
end
else
begin
FirstNode:= tvTmp.Items.AddChildObject(RootNode,//RootNode放在这的意义
FirstNodeText+'('+FirstNodeID+')',nil);
tvTmp.Items.AddChildObject(FirstNode,//////FirstNode在这的意义??????
SecondNodeText+'('+SecondNodeID+')',nil);//为什么里边只能为三个参数不能为两个或者多个
TmpQuery.Next;
end;
end
else
begin
FirstNode:= tvTmp.Items.AddChildObject(RootNode,//????????????
FirstNodeText+'('+FirstNodeID+')',nil);
tvTmp.Items.AddChildObject(FirstNode,//???????????????
SecondNodeText+'('+SecondNodeID+')',nil);
TmpQuery.Next;
end;
end;
for i := 0 to tvTmp.Items.Count - 1do
begin
tvTmp.Items.ImageIndex := 0;//解释
tvTmp.Items.SelectedIndex :=1;//解释
end;
finally
TmpQuery.Close;
TmpQuery.Free;
end;
end;
上边有?号或者是//的都是需要解释的,请大侠们帮帮忙,在线等,答完给分
TmpConnection: TADOConnection);
var i: integer;
TmpQuery: TADOQuery;
RootNode: TTreeNode;//[red]TTreeNode类型的意思[/red]
FirstNode: TTreeNode;
FirstNodeID: String;
SecondNodeID: String;
FirstNodeText: String;
SecondNodeText: String;
begin
TmpQuery:= TADOQuery.Create(nil);
TmpQuery.Connection:= TmpConnection;
try
TmpQuery.SQL.Clear;
TmpQuery.SQL.Add(' select C.DeviceID,C.DeviceName, ');
TmpQuery.SQL.Add(' P.OperatorID,O.OperatorName ');
TmpQuery.SQL.Add(' from ck_ptDevice C ');
TmpQuery.SQL.Add(' left Outer join ck_ptDeviceOp P ');
TmpQuery.SQL.Add(' on ( P.DeviceID = C.DeviceID ) ');
TmpQuery.SQL.Add(' left outer join ck_Operator O ');
TmpQuery.SQL.Add(' on (O.OperatorID = P.OperatorID) ');
TmpQuery.Open;
tvTmp.Items.Clear;
RootNode:= tvTmp.Items.AddFirst(nil,'加工机器');
FirstNode:= nil;
While not TmpQuery.Eofdo
begin
if not TmpQuery.FieldByName('DeviceID').IsNull then
begin
FirstNodeID:=TmpQuery.FieldByName('DeviceID').AsString;
FirstNodeText:=TmpQuery.FieldByName('DeviceName').AsString;
end
else
begin
FirstNodeID:= '空';
FirstNodeText:= '空';
end;
if not TmpQuery.FieldByName('OperatorID').IsNull then
begin
SecondNodeID:=TmpQuery.FieldByName('OperatorID').AsString;
SecondNodeText:=TmpQuery.FieldByName('OperatorName').AsString;
end
else
begin
SecondNodeID:= '空';
SecondNodeText:= '空';
end;
if not (FirstNode = nil) then
begin
if FirstNodeID = Copy(FirstNode.Text,Pos('(',FirstNode.Text)+1,3) then
//上边那一段需要解释Copy(FirstNode.Text,Pos('(',FirstNode.Text)+1,3)
begin
tvTmp.Items.AddChildObject(FirstNode,//FirstNode放在这的意义?
SecondNodeText+'('+SecondNodeID+')',nil);//要解释整段
TmpQuery.Next;
end
else
begin
FirstNode:= tvTmp.Items.AddChildObject(RootNode,//RootNode放在这的意义
FirstNodeText+'('+FirstNodeID+')',nil);
tvTmp.Items.AddChildObject(FirstNode,//////FirstNode在这的意义??????
SecondNodeText+'('+SecondNodeID+')',nil);//为什么里边只能为三个参数不能为两个或者多个
TmpQuery.Next;
end;
end
else
begin
FirstNode:= tvTmp.Items.AddChildObject(RootNode,//????????????
FirstNodeText+'('+FirstNodeID+')',nil);
tvTmp.Items.AddChildObject(FirstNode,//???????????????
SecondNodeText+'('+SecondNodeID+')',nil);
TmpQuery.Next;
end;
end;
for i := 0 to tvTmp.Items.Count - 1do
begin
tvTmp.Items.ImageIndex := 0;//解释
tvTmp.Items.SelectedIndex :=1;//解释
end;
finally
TmpQuery.Close;
TmpQuery.Free;
end;
end;
上边有?号或者是//的都是需要解释的,请大侠们帮帮忙,在线等,答完给分