Business平台的人员并没有“性别”、“联系电话”的等人员对象的扩展属性信息。
但是可以通过在Business平台的人员表中增加“E”字母开头的字段来实现增加人员的扩展属性,增加后的属性可以在系统功能的“人员设计器”中看到。但是有时需要使用代码设置这些扩展信息,以下为使用代码设置人员扩展信息的示例。
procedure TMainForm.btnSetExtInfoClick(Sender: TObject);
var
I: integer;
FieldList: TStrings;
lTableDef: TBizTableDef;
lFieldDef: TBizFieldDef;
lDataField: TUserDataField;
ExtendInfoKind: TOrgSysExtendInfoKind;
OrgObjectURL: TBizURL;
lFileAttribute: TFileAttribute;
lField: TDataField;
lFieldName, lFieldValue: string;
DataSetExtInfo: TUserDataSet;
begin
{获取系统表}
DataSetExtInfo := TUserDataSet.Create(self);
ExtendInfoKind := TOrgSysExtendInfoKind.eikPerson;
lTableDef := TOrgSysExtendInfoManager.GetOrgSysTableDef(ExtendInfoKind);
if lTableDef = nil then Exit;
FieldList := TStringList.Create;
OrgObjectURL := TBizURL.Create;
try
FieldList.Clear;
OrgObjectURL.URL := 'Org:\PERSON\ZXX.psn';
lFileAttribute := FileSys.FileSystem.CreateAttribute(OrgObjectURL.FileName,
SysUtils.fmOpenWrite);
TOrgSysExtendInfoManager.GetOrgSysTableExtendFields(ExtendInfoKind, FieldList);
if FieldList.Count = 0 then Exit; //如果没有扩展字段则退出
for I := 0 to FieldList.Count - 1 do
begin
lFieldDef := TBizFieldDef(FieldList.Objects[I]);
lDataField := TUserDataField.Create(DataSetExtInfo);
lDataField.DataSet := DataSetExtInfo;
lDataField.ID := lFieldDef.ID;
lDataField.DisplayName := lFieldDef.DisplayName;
lFieldDef.AssignAttrTo(lDataField);
end;
DataSetExtInfo.Open;
DataSetExtInfo.Edit;
DataSetExtInfo.FieldByName('EXB').AsString := edtEXB.Text;
DataSetExtInfo.FieldByName('EDH').AsString := edtEDH.Text;
for I := 0 to DataSetExtInfo.FieldCount - 1 do
begin
lFieldName := FieldList[I];
lField := DataSetExtInfo.FieldByName(lFieldName);
case lField.DataType of
TFieldType.ftGraphic, TFieldType.ftBlob, TFieldType.ftOraBlob:
TOrgSysExtendInfoManager.SaveBlobFieldToOrgExtTable(OrgObjectURL,
TBlobField(lField), ExtendInfoKind)
else
lFieldValue := lField.AsString;
lFileAttribute.ValuesAsString[lFieldName] := lFieldValue;
MemoResult.Lines.Add('扩展字段ID:' + lField.FieldName + ',显示名称:'
+ lField.DisplayName + ',字段值:' + lField.AsString);
end;
end;
DataSetExtInfo.Post;
finally
DataSetExtInfo.Free;
lFileAttribute.Free;
FieldList.Free;
end;
end;
注意:此段代码所在功能的配置项目属性中先引入OrgSysCommLib公共库。 |