procedure TfrmVSEditor.BOBrokerAfterApplyUpdates(Processor: TSmartProcessor;
var Applied: Boolean);
var
ds1: TSmartDataSet;
begin
inherited;
//后续拜访
if (processor.State in [psInsert]) and (MasterDataSet.FieldByName('VSAgain').AsString = '有') then
begin
if Supports(Self.BO, IFunKey) and ((Self.BO as IFunKey).GetFunKey(1) = '1') then
TfrmAskVSEditor.FollowUpVS(Self.MasterDataSet, True)
else
TfrmAskVSEditor.FollowUpVS(Self.MasterDataSet, False);
end;
//暫用最簡單方式處理
ds1 := TSqlProc.GetData('select Min(SDate) as FollowTime from crm_AskVS where VSID=''' + GuidToStr(MasterDataSet.FieldByName('ID').AsVariant) + '''');
ds1.Open;
try
MasterDataSet.Edit;
if not ds1.IsEmpty then
MasterDataSet.FieldByName('aFollowTime').AsDateTime := ds1.FieldByName('FollowTime').AsDateTime //回写下次拜访日期
else
MasterDataSet.FieldByName('aFollowTime').AsString := '';
MasterDataSet.Post;
finally
MasterDataSet.ApplyUpdates(0);
ds1.Close;
end;
end;
【注意】
不能用BOBrokerEndTrans事件, 因为执行BOBrokerEndTrans事件时数据并未真正完成写入到数据库,造成记录已被他人修改的错误,如果用MasterDataSet.MergeChangeLog 又不能更新Browser画面,最终用BOBrokerAfterApplyUpdates事件得以解决。