{ 办结 }
procedure TFRM_INFILEVIEW.tbnArchiveClick(Sender: TObject);
begin
if dsbInFile.DataSet.IsEmpty then
begin
ShowWarning('对不起,没有数据记录', '注意');
exit;
end;
if ConfirmBox('确实要办结本条记录吗?', '', 1) then
begin
LIB_GC.TLIB_GC.FinishFlowInTransaction(dsbInFile.DataSet, '2');
dsbInFile.DataSet.Refresh;
end;
end;
调用资源集
cSystemDataBase = 'DATABASEURL=Biz:\SYSTEM\System.DataBase';
static procedure TLIB_GC.FinishFlow(const AFlowID: string; AQuery: TQuery);
begin
AQuery.ConnectionString := cSystemDataBase;
AQuery.CommandText := 'UPDATE TFLOW SET FSTATE = ''fsFinished''' +
'WHERE FGUID = (SELECT FFLOWGUID FROM TFLOWID WHERE FID=''' + AFlowID + ''')';
AQuery.Execute;
AQuery.Close;
AQuery.CommandText := 'UPDATE TTASK SET FSTATE = ''tsFinished''' +
'WHERE FFLOWGUID = (SELECT FFLOWGUID FROM TFLOWID WHERE FID=''' + AFlowID + ''')';
AQuery.Execute;
AQuery.Close;
AQuery.CommandText := 'UPDATE TTASKMESSAGE SET FSTATE = ''tmsFinished''' +
'WHERE FTASKGUID IN (SELECT FGUID FROM TTASK WHERE FFLOWGUID = ' +
'(SELECT FFLOWGUID FROM TFLOWID WHERE FID = ''' + AFlowID + '''))';
AQuery.Execute;
end;
static procedure TLIB_GC.FinishFlowInTransaction(Ads: TDataSet; const AFlag: string);
var
lTransactionHandle: TTransactionHandle;
lQuery: TQuery;
begin
lQuery := TQuery.Create(nil);
try
lQuery.Connection := Ads.Connection;
lQuery.Connection.Transaction := Ads.Connection.Transaction;
with Ads.Connection.Transaction do
begin
lTransactionHandle := Start(False);
try
// 处理
Ads.Edit;
Ads.FieldByName('F_STATUS').AsString := AFlag;
Ads.ApplyUpdates(True);
lQuery.ConnectionString := cConnectionStr;
FinishFlow(Ads.FieldByName('F_FLOWID').AsString, lQuery);
Commit(lTransactionHandle);
except
Rollback(lTransactionHandle);
end;
end;
finally
lQuery.Free;
end;
end; |