procedure TCustomBill.Save;
begin
if MasterDataSet.State in [TDataSetState.dsEdit,TDataSetState.dsInsert] then MasterDataSet.Post;
if DetailDataSet.State in [TDataSetState.dsEdit,TDataSetState.dsInsert] then DetailDataSet.Post;
with MasterDataSet.Connection.Transaction do begin
FTrans:=Start(False);
try
if MasterDataSet.ChangeCount>0 then MasterDataSet.ApplyUpdates;
if DetailDataSet.ChangeCount>0 then DetailDataSet.ApplyUpdates;
Commit(FTrans);
finally
RollBack(FTrans);
jsDialogs.OkCancelBox('' , '', 1) ;
end;
end;
end;
在以上的DetailDataSet的Connection与MasterDataSet的Connection是否为同一个Connection.如果不是这样的事务处理,存在缺陷,那么自己控制事务应该如何处理呢。请帮忙。。。 |