to Sachow 把代码帖出来,让咱也参考一下呀,我的请大家指教
服务层
procedure TFinDeptPrivTrxDM.dspFinDeptPrivBeforeGetRecords(Sender: TObject;
var OwnerData: OleVariant);
var
FilterStr:string;
begin
FinDeptPriv.Close;
{*********************************************************************************}
{Create date: 2002-09-14 By SYZ begin
}
{OwnerData: [0] - FinDeptID }
{ [1] - ModuleID }
{ [2] - FunctionID }
{*********************************************************************************}
if VarIsArray(OwnerData) then
begin
FilterStr:='';
if OwnerData[0] <> '' then
begin
FilterStr := FilterStr + 'FinDeptID = ''' + OwnerData[0] + '''';
end;
if OwnerData[1] <> '' then
begin
if FilterStr <> '' then
FilterStr := FilterStr + ' AND ';
FilterStr := FilterStr + 'ModuleID = ''' + OwnerData[1] + '''';
end;
if OwnerData[2] <> '' then
begin
if FilterStr <> '' then
FilterStr := FilterStr + ' AND ';
FilterStr := FilterStr + 'FunctionID = ''' + OwnerData[2] + '''';
end;
if FilterStr <> '' then
begin
FinDeptPriv.Filter := FilterStr;
FinDeptPriv.Filtered := True;
end;
end
else
begin
FinDeptPriv.Filter := '';
FinDeptPriv.Filtered := False;
end;
end;
协调层
function TFinDeptPrivTrxQryObj.GetFinDeptPrivByID(SID: OleVariant;
const FinDeptID: WideString;
var Data: OleVariant): WordBool;
var
TrxDM: IFinDeptPrivTrxDM;
Server: string;
Options: TGetRecordOptions;
RecsOut: Integer;
Params: OleVariant;
OwnerData: OleVariant;
begin
if not CheckSID(SID) then
Exit;
Options := [grMetaData, grReset];
Server := reg.GetProviderServer;
try
if Server = '' then
TrxDM := CoFinDeptPrivTrxDM.Create
else
TrxDM := CoFinDeptPrivTrxDM.CreateRemote(Server);
OwnerData := VarArrayOf([FinDeptID,'', '']);
Data := TrxDM.AS_GetRecords('dspFinDeptPriv', -1, RecsOut,
Byte(Options), '', Params, OwnerData);
SetComplete;
Result := True;
except
SetAbort;
raise;
end;
end;
客户端
procedure TFinDeptPrivFrm.FormCreate(Sender: TObject);
begin
PixelsPerInch := Screen.PixelsPerInch;
if gCurUser.ServerName = '' then
begin
FinDepartmentQryObj:=CoFinDepartmentTrxQryObj.Create ;
FinDeptPrivQryObj:=CoFinDeptPrivTrxQryObj.Create ;
SysFunctionQryObj:=CoSysFunctionTrxQryObj.Create ;
FinDeptPrivUpdObj:=CoFinDeptPrivTrxUpdObj.Create ;
end
else
begin
FinDepartmentQryObj:=CoFinDepartmentTrxQryObj.CreateRemote(gCurUser.ServerName);
FinDeptPrivQryObj:=CoFinDeptPrivTrxQryObj.CreateRemote(gCurUser.ServerName);
SysFunctionQryObj:=CoSysFunctionTrxQryObj.CreateRemote(gCurUser.ServerName);
FinDeptPrivUpdObj:=CoFinDeptPrivTrxUpdObj.CreateRemote(gCurUser.ServerName);
end;
cdsSysFunction.GetRemoteData;
cdsFinDepartment.GetRemoteData;
end;