if DataSetYPGYSJJ.FieldByName('yp_gxh').IsNull then
begin
with DataSetYPGYSJJ do
begin
if not active then open;
//dialogs.ShowMessage(Fmaxgxh);
edit;
FieldByName('yp_gxh').AsInteger := Fmaxgxh(FieldByName('yp_ypdh').AsString,FieldByName('yp_gybc').AsString);
end;
end;
function TYPXX_INFO.Fmaxgxh(ypdh :string;gybc :string) :Integer;
var
lQuery : TQuery;
begin
lQuery := TQuery.Create(nil);
try
lQuery.ConnectionString :='DATABASEURL=Biz:\XTGLPT_SPACE\XXXT_SPACE\XXXTSJK_DATA.DATABASE';
lQuery.CommandText := 'select (max(yp_gxh)+1) as gxh '+
'from ypgyb_table where yp_ypdh='''+ypdh+''' and yp_gybc='''+gybc+''' group by yp_ypdh,yp_gybc';
lQuery.open;
result := lQuery.FieldByName('gxh').AsInteger ;
finally
lQuery.Free;
end;
end;