procedure TfrmMain.Button1Click(Sender: TObject);
var
  MyLogisticsCompanyApi: TLogisticsCompanyApi;
begin
  MyLogisticsCompanyApi := TLogisticsCompanyApi.Create;
  try
    ShowMessage(MyLogisticsCompanyApi.GetCompanyCodeListStr);

  finally
    MyLogisticsCompanyApi.Free;
  end;
end;

 

function TLogisticsCompanyApi.GetCompanyCodeListStr: string;
var
  MyFqApi: TFqApi;
  MyList: TStringList;
begin
  MyFqApi := TFqApi.Create(nil);
  MyList := TStringList.Create;
  try
    MyFqApi.Connection := frmClientDm.MyMainCon;
    with MyFqApi do
    begin
      SQL.Text := 'SELECT top_company_code FROM top_logistics_company ORDER BY top_company_precedence';
      Open;
    end;
    if not MyFqApi.IsEmpty then
    begin
      //去除重复,不sort就无效
      MyList.Duplicates := dupIgnore;
      while not MyFqApi.Eof do
      begin
        MyList.Add(MyFqApi.FieldByName('top_company_code').AsString);
        MyFqApi.Next;
      end;
      //返回数据
      Exit(MyList.CommaText);
    end else begin
      //说明为空,返回异常
      Exit('');
    end;
  finally
    MyFqApi.Free;
    MyList.Free;
  end;
end;

posted on 2014-04-23 12:06  del88  阅读(16)  评论(0)    收藏  举报