删除业务判断
function CheckCanDelete(const EntityID: Integer):Boolean;
var aSQLQuery:TSQLQuery;
begin
Result:=False;
aSQLQuery:=TSQLQuery.Create(nil);
with aSQLQuery do try
Close;SQL.Clear;
SQLConnection:=SQLConn;
SQL.Add('Select EntityID from OutWorkBillsItems');
SQL.Add('where SysID=:SysID and EntityID=:EntityID');
ParamByName('SysID').AsInteger:=GetSysID;
ParamByName('EntityID').AsInteger:=EntityID;
Open;
if Eof and Bof then begin
Result:=True;
Exit;
end else begin
if MessageDLG('提单明细已经存在,确定要同时删除吗?', mtConfirmation, [mbYes, mbNo], 0)<>mrYes then
// Showmessage('存在明细项目,不允许删除 !') //Result:=False;
Exit;
Close;SQL.Clear;
SQL.Add('Delete from OutWorkBillsItems');
SQL.Add('where SysID=:SysID and EntityID=:EntityID');
ParamByName('SysID').AsInteger:=GetSysID;
ParamByName('EntityID').AsInteger:=EntityID;
ExecSQL(False);
Result:=True;
end;
finally
Free;
end;
end;
procedure OnBeforeDeleteEntity(const ActID, EntityID: Integer; var CanDelete: Boolean);
begin
CanDelete:=CheckCanDelete(EntityID);
end