这个我早看过了 一直没有解决 所以才开新贴
版本2435,下面是测试代码,当提交数据出错时,流程还是走到了下一个环节,不知问题出在哪儿?
procedure TMainForm.FlowBroker1AfterFlowOut(Sender: TObject; Command: TFlowOutCommand);
var
dstKC:TDataSet;
WLBM:String;
lTransHandle: TTransactionHandle;
begin
dstKC:=dstBrokerKC.DataSet;
with dstBrokerMain.DataSet.Connection do
begin
lTransHandle :=Transaction.Start(False);
with dstBrokeSlave.DataSet do
try
First;
DisableControls;
if not dstKC.Active then dstKC.Active:=True;
while not Eof do //库存处理
begin
WLBM:=FieldByName('WLBM').AsString;
if dstKC.Locate('WLBM',[WLBM],[]) then
begin
dstKC.Edit;
dstKC.FieldByName('SL').AsFloat:=dstKC.FieldByName('SL').AsFloat+FieldByName('SL').AsFloat;
end else
begin
dstKC.Append;
dstKC.FieldByName('WLBM').AsString:=WLBM;
dstKC.FieldByName('SL').AsFloat:=FieldByName('SL').AsFloat;
end;
Next;
end;
EnableControls;
dstKC.ApplyUpdates;
with dstBrokerMain.DataSet do //更新入库单状态
begin
Edit;
FieldByName('RKZT').AsInteger:=1;
ApplyUpdates;
end;
Transaction.Commit(lTransHandle);
except
Transaction.Rollback(lTransHandle);
Raise;
end;
end;
end;
procedure TMainForm.BizFormCreate(Sender: TObject);
begin
FlowBroker1.FlowControl.FlowManager.Transaction:=dstBrokerMain.DataSet.Connection.Transaction;
end; |