这种情况怎么改进!
我的情况是这样的,程序是三层结构,系统查询提交给服务器中间件查询,但是返回的时间很慢,请问用什么方法可以解决,如果开一个线程的要怎么用,因为我这个窗体是继承下来的.
procedure TfrwBillQuery.SumOfOrgan(Sender: TObject);
var
cStartDate: String;
cEndDate: String;
oSumList: Variant;
oSumTotal: Variant;
oSumSales: Variant;
oSumOrgan: Variant;
cPath: String;
cParentPath: String;
cPointNo: String;
cPointName: String;
oNode: TTreenode;
pNode: ^String;
nLen: Integer;
nLevel: Integer;
i: Integer;
begin
cStartDate := DateToStr(Self.dtpStart.Date);
cEndDate := DateToStr(Self.dtpEnd.Date);
gcPointNo := '';
oNode := Self.tvOrgan.Selected;
Self.lblUnitName4.Caption := '统计单位: '+oNode.Text;
Self.lblUnitName3.Caption := '统计单位: '+oNode.Text;
Self.lblUnitName2.Caption := '统计单位: '+oNode.Text;
Self.lblUnitName1.Caption := '统计单位: '+oNode.Text;
Self.lblUnitName.Caption := '统计单位: '+oNode.Text;
pNode := oNode.Data;
nLevel := oNode.Level + 1;
cParentPath := pNode^;
nLen := Length(cParentPath);
Self.tbGroups.Close;
Self.tbGroups.CreateDataSet;
for i := 0 to Self.tvOrgan.Items.Count - 1 do
begin
oNode := Self.tvOrgan.Items.Item[i];
cPointNo := oNode.Text;
cPointName := Copy(cPointNo,6,Length(cPointNo)-5);
cPointNo := Copy(cPointNo,1,4);
pNode := oNode.Data;
cPath := pNode^;
if Copy(cPath,1,nLen) = cParentPath then
begin
if Length(cPath) <> nLen then
begin
Self.tbGroups.Append;
Self.tbGroups.FieldByName('PointNo').AsString := cPointNo;
Self.tbGroups.FieldByName('PointName').AsString := cPointName;
Self.tbGroups.FieldByName('Paths').AsString := cPath;
Self.tbGroups.FieldByName('PathGroup').AsString := Copy(cPath,1,nLen+4);
while oNode.Level > nLevel do
begin
oNode := oNode.Parent;
end;
cPointNo := oNode.Text;
cPointName := Copy(cPointNo,6,Length(cPointNo)-5);
cPointNo := Copy(cPointNo,1,4);
Self.tbGroups.FieldByName('GroupPointNo').AsString := cPointNo;
Self.tbGroups.FieldByName('GroupPointName').AsString := cPointName;
Self.tbGroups.Post;
end;
end;
end;
Self.tbSumList.Close;
Self.tbSumTotal.Close;
Self.tbSumSales.Close;
Self.tbSumOrgan.Close;
if Self.tbGroups.RecordCount > 0 then
begin
if dmMain.scMain.AppServer.SumOfPoints(cStartDate,cEndDate,
Self.tbGroups.Data,oSumList,oSumTotal,oSumSales,oSumOrgan) = '1' then
begin
Self.tbSumList.Data := oSumList;
Self.tbSumTotal.Data := oSumTotal;
Self.tbSumSales.Data := oSumSales;
Self.tbSumOrgan.Data := oSumOrgan;
end;
end;
//Self.tbGroups.Close;
Self.SumSortByQty(Sender);
Self.SumSortByMoney(Sender);
end;
这句
if dmMain.scMain.AppServer.SumOfPoints(cStartDate,cEndDate,
Self.tbGroups.Data,oSumList,oSumTotal,oSumSales,oSumOrgan) = '1' then
是提交服务器运行,但是返回的结果很慢,如果开一个线程要怎么处理,由于本人没有用过,请各位大侠指点.