procedure TFrame4.GetClassInfo;
var intClassID, intClassLevel, intClassIndex: Integer;
sClassName: string;
pData: ^integer;
I: integer;
begin
tvProClass.Items.Clear;
with dm_Mysql do
begin
sqlMysql.Close;
sqlMysql.SQl.clear;
sqlMysql.SQL.Add('Select * from ProduceClass order By ClassLevel ,ClassIndex');
sqlMysql.open;
if sqlMysql.RecordCount <> 0 then
begin
for I := 0 to sqlMysql.RecordCount - 1 do
begin
new(pData);
intClassID := sqlMysql.fieldByname('ClassID').asinteger;
sClassName := SqlMysql.fieldByname('ClassName').asstring;
intClassLevel := sqlMysql.fieldByname('ClassLevel').asinteger;
intClassIndex := sqlMysql.fieldByname('ClassIndex').asinteger;
pData^ := intClassID;
if intClassLevel = 0 then //=0 即为顶级节点。
begin
tvProClass.Items.AddObject(GetNodeBydata(intClassIndex), sClassName, pData);
end
else
begin
tvProClass.items.AddChildObject(GetNodeByData(intClassIndex), sClassname, PData);
end;
sqlMysql.Next
end;
end;
tvProClass.FullExpand;
end;
end;
function TFrame4.GetNodeData: integer;
begin
if tvProClass.Selected <> nil then
begin
result := pinteger(tvProClass.Selected.Data)^;
end
else
begin
result := 0;
end;
end;
给分哦!