帮我看看这段代码有什么问题么?
procedure TMainForm.DataNavigatorBeforeAction(Sender: TObject; var Accept: Boolean);
var
lRegPerson: string;
lMsg: string;
flowEng: TFlowEngine;
fParam: TLoadFlowParam;
tParam: TLoadTaskParam;
flowGuid: string;
begin
case (Sender as TBizDataSetAction).ID of
BizActnConsts.ActionDataSetAppend:
if ViewMode = TViewMode.vmList then
begin
Accept := False;
ViewMode := TViewMode.vmDetail;
DocListDataSet.Active := True;
DocListDataSet.Insert;
end;
BizActnConsts.ActionDataSetDelete:
begin
Accept := False;
case ViewMode of
TViewMode.vmList, TViewMode.vmDetail:
begin
if ViewMode = TViewMode.vmList then
begin
lRegPerson := DocIndexDataSet.FieldByName('UserName').AsString;
end
else
begin
lRegPerson := DocListDataSet.FieldByName('UserName').AsString;
end;
flowGuid := TCOMMONFUNC.GetFlowGuidById(DocListDataSet.FieldByName('DocId').AsString);
if lRegPerson <> WDLZInfo.GetOperatorName then
jsDialogs.ShowWarning('不是当前客户的登记人,不能删除客户信息', '提示')
else
begin
if jsDialogs.ConfirmBox('确认要删除当前记录吗?', '提问', 1) then
begin
DocListDataSet.Delete;
DocListDataSet.ApplyUpdates;
flowEng := TFlowEngine.Create;
fParam := TLoadFlowParam.Create;
tParam := TLoadTaskParam.Create;
try
fParam.GUIDs.Add(flowGuid);
tParam.FlowGUIDs.Add(flowGuid);
flowEng.DeleteFlows(fParam,tParam);
flowEng.DeleteTasks(tParam);
finally
fParam.Free;
tParam.Free;
flowEng.Free;
end;
DocListDataSet.First;
end;
end;
end;
TViewMode.vmEncloses: //2006-11-15 补充
begin
DSEncloses.DataSet.Delete;
DSEncloses.DataSet.ApplyUpdates;
end;
end;
end;
BizActnConsts.ActionDataSetCancel:
begin
if DataNavigator.DataSource.DataSet.State = TDataSetState.dsInsert then
lMsg := '确认要取消新增记录吗?'
else
lMsg := '确认要取消当前修改吗?';
if not jsDialogs.ConfirmBox(lMsg, '提问', 1) then
Accept := False;
end;
end;
end; |