|
我自己做了一个人员录入界面,保存时经常会碰到如下图错误
,再点保存就会出现, 文件"Orgerson23010.dfd 00402.psn"已经存在 错误
代码如下
lPersonID := DataSetsdsDetail.FieldByName('PersonID').AsString;
lDisplayName := DataSetsdsDetail.FieldByName('PersonName').AsString;
lDeptURL := DataSetsdsDetail.FieldByName('DeptID').AsString;
lDept :=Business.Model.Org.OrgSys.OrgSystem.FindUnit(lDeptURL,'','');
lDeptURL := '';
lDeptURL := lDept.BizURL.URL;
nLength := Length(lDeptURL);
lDeptURL := Business.System.StringUtils.Copy(lDeptURL, 5, nLength - 4);
lPositionID := DataSetsdsDetail.FieldByName('PositionID').AsString;
CreatePersonAndAllocate(lPersonID, lDisplayName, lDeptURL, lPositionID);
procedure TFJ_3_RYJBXX.CreatePersonAndAllocate(APersonID, APersonDisplayName,
ADeptURL, APositionID: string);
var
lDeptURL: string;
lDeptBizURL, lPositionBizURL: TBizURL;
lPerson: TPerson;
lPositionMember: TOrgUnit;
begin
{ 存储时候没有'Org:', 对象使用时候都有前缀名 }
lDeptURL := FileSys.cOrgFilePrefix + ADeptURL;
lDeptBizURL := TBizURL.Create;
try
lDeptBizURL.URL := lDeptURL;
DataSetuse.open;
DataSetuse.Filter := 'FGUID = '''+ APositionID+'''';
DataSetuse.Filtered := true;
APositionID := DataSetuse.FieldByName('FID').asString;
lPositionBizURL:= Org.OrgSys.OrgSystem.FindPosition(APositionID).BizURL;
lPerson := Org.OrgSys.OrgSystem.CreatePerson(lDeptBizURL, APersonID, APersonDisplayName);
lPositionMember := GetPositionMember(lDeptBizURL, APositionID);
{ 如果指定岗位在指定部门下还没有,需要先分配岗位成员 }
if lPositionMember = nil then
lPositionMember := Org.OrgSys.OrgSystem.AssignPosition(lDeptBizURL, lPositionBizURL);
Org.OrgSys.OrgSystem.AssignPerson(lPositionMember.BizURL, lPerson.BizURL);
jsDialogs.showmsg('录入人员成功,人员编号是:'+APersonID, '返回信息');
finally
lDeptBizURL.Free;
end;
end;
|
|