Procedure TSJJYSWJGXXX.FIELD_dsData_JSZD1CalcField(Field: TBizField; var Value: Variant);
Var
lValue: Integer;
begin
if Field.ID = 'JSKYKC' then
begin
lValue := DataSetCSTJJSZD.FieldByName('KCSL').AsInteger –
DataSetCSTJJSZD.FieldByName('ZKCL').AsInteger;
Value := lValue;
end;
end;
2、处理其它数据集中的字段,参考代码如下:
Procedure TSJJYSWJGXXX.FIELD_dsData_JSZD1CalcField(Field: TBizField; var Value: Variant);
var
lValue: Integer;
lQuery:TQuery;
begin
if Field.ID = 'TJKYKC' then
begin
lQuery:=TQuery.Create(nil);
try
// 给 Query 赋 ConnectionString
lQuery.ConnectionString:='DATABASEURL=
Biz:\ DEMO\DEMODATABASE.Database';
// TJKYKC 是命名的一个别名,目的是便于访问
lQuery.CommandText:='Select Sum(KCSL-ZKCL) as
TJKYKC from SJJ_WZKCB';
lQuery.Open;
lValue:=lQuery.FieldByName('TJKYKC').AsInteger;
Value := lValue;
finally
lQuery.Free;
end;
end;
end;