起步软件技术论坛-X3

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: 枣庄矿务局

【搞定】[小问题]组织机构编码维护的问题!(感谢龚明)

[复制链接]
发表于 2004-5-8 19:12:46 | 显示全部楼层

我做了一个例子功能“自定义组织机构设计器”,打包上传,以供参考。

unit CustomOrgDsgnForm;

interface

uses
  Business.System, Business.Forms, Business.Model, Business.Model.Org;

type
  TCustomOrgDsgnForm = class(SYSORGANDESIGNFORM.TBaseOrgDsgnForm)
    procedure actNewOrganExecute(Sender: TObject);
    procedure actNewDeptExecute(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
   { 自定义新建组织单元 }
    function CustomNewOrgUnit(const Parent: TBizURL; const AKind: TOrgUnitKind): TOrgUnit;
  end;

implementation


function TCustomOrgDsgnForm.CustomNewOrgUnit(const Parent: TBizURL;
  const AKind: TOrgUnitKind): TOrgUnit;
var
  lID, lDisplayName: string;
begin
  Result := nil;

  {!!! 在此对 lID 和 lDisplayName 进行赋值,赋值为你经过计算加 1 后的ID,相加
    计算的代码我不写,你自己补写,当是机构和部门时我暂且分别赋值为 001 和 中国
    总公司、 001001 和 XXX部门 }
  case AKind of
    TBizObjectKind.boOrgan:
      begin
        lID := '001';
        lDisplayName := '中国总公司';
      end;
    TBizObjectKind.boDept:
      begin
        lID := '001001';
        lDisplayName := 'XXX部门';
      end;
  end;

  if ShowInputIDNameDialog(AKind, Parent, lID, lDisplayName) then
    Result := Org.OrgSys.OrgSystem.CreateUnit(Parent, lID, AKind, lDisplayName);
end;


procedure TCustomOrgDsgnForm.actNewOrganExecute(Sender: TObject);
begin
  {不调用前代的方法,完全自己做。
  Inherited; }
  CustomNewOrgUnit(SelectedBizNode.BizURL, TBizObjectKind.boOrgan);
end;

procedure TCustomOrgDsgnForm.actNewDeptExecute(Sender: TObject);
begin
  {不调用前代的方法,完全自己做。
  Inherited; }
  CustomNewOrgUnit(SelectedBizNode.BizURL, TBizObjectKind.boDept);
end;

end.

自定义组织机构设计器.zip

20.17 KB, 下载次数: 26

回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-5-8 20:45:36 | 显示全部楼层
谢谢!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-5-9 10:05:07 | 显示全部楼层
unit CustomOrgDsgnForm;

interface

uses
  Business.System, Business.Forms, Business.Model, Business.Model.Org;

type
  TCustomOrgDsgnForm = class(SYSORGANDESIGNFORM.TBaseOrgDsgnForm)
    procedure actNewOrganExecute(Sender: TObject);
    procedure actNewDeptExecute(Sender: TObject);
  private
    {private declarations}
  public
    {public declarations}
   { 自定义新建组织单元 }
    function CustomNewOrgUnit(const Parent: TBizURL; const AKind: TOrgUnitKind): TOrgUnit;
  end;

implementation


function TCustomOrgDsgnForm.CustomNewOrgUnit(const Parent: TBizURL;
  const AKind: TOrgUnitKind): TOrgUnit;
var
  lID, lDisplayName: string;
begin
  Result := nil;
//    取子部门是这样的吗?   

  lOrgUnit := Org.OrgSys.OrgSystem.GetUnit(Parent);
  lSubordinations:=TOrgSubordinationItems.Create;
  lSubordinations.Assign(lOrgUnit.Module.Subordinations);

         for i:=0 to lSubordinations.Count-1 do
          begin
            lSubItem := TOrgSubordinationItem(lSubordinations.Items);
            if lMax<SysUtils.StrToInt(lSubItem.DeptID.Substring(0,lSubItem.DeptID.Length-3)) then
               lMax:=SysUtils.StrToInt(lSubItem.DeptID.Substring(0,lSubItem.DeptID.Length-3));
          end;

//为什么每次lMax都是0呢?是不是写错了


  {!!! 在此对 lID 和 lDisplayName 进行赋值,赋值为你经过计算加 1 后的ID,相加
    计算的代码我不写,你自己补写,当是机构和部门时我暂且分别赋值为 001 和 中国
    总公司、 001001 和 XXX部门 }
  case AKind of
    TBizObjectKind.boOrgan:
      begin
        lID := '001';
        lDisplayName := '中国总公司';
      end;
    TBizObjectKind.boDept:
      begin
        lID := '001001';
        lDisplayName := 'XXX部门';
      end;
  end;

  if ShowInputIDNameDialog(AKind, Parent, lID, lDisplayName) then
    Result := Org.OrgSys.OrgSystem.CreateUnit(Parent, lID, AKind, lDisplayName);
end;


procedure TCustomOrgDsgnForm.actNewOrganExecute(Sender: TObject);
begin
  {不调用前代的方法,完全自己做。
  Inherited; }
  CustomNewOrgUnit(SelectedBizNode.BizURL, TBizObjectKind.boOrgan);
end;

procedure TCustomOrgDsgnForm.actNewDeptExecute(Sender: TObject);
begin
  {不调用前代的方法,完全自己做。
  Inherited; }
  CustomNewOrgUnit(SelectedBizNode.BizURL, TBizObjectKind.boDept);
end;

end.
回复 支持 反对

使用道具 举报

发表于 2004-5-9 10:29:20 | 显示全部楼层

GetAllSubordination方法是用来取管理的下属的,要设置了管理权限以后才取得到。要取

GetAllSubordination方法是用来取管理的下属的,要设置了管理权限以后才取得到。要取子部门,需要调用文件系统的搜索方法搜索当前文件下的子文件。稍后我传一个例子上来......
回复 支持 反对

使用道具 举报

发表于 2004-5-9 10:32:06 | 显示全部楼层

先上传一篇组织模型相关类的文章供参考。

先上传一篇组织模型相关类的文章供参考。

第十一章 第6节 组织模型.zip

91.55 KB, 下载次数: 36

回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-5-9 10:44:20 | 显示全部楼层
已经下载!谢谢
回复 支持 反对

使用道具 举报

发表于 2004-5-9 10:45:41 | 显示全部楼层

取子部门的参考代码:

取子部门的参考代码如下:

function TCustomOrgDsgnForm.CustomNewOrgUnit(const Parent: TBizURL;
  const AKind: TOrgUnitKind): TOrgUnit;
var
  I: Integer;
  lID, lDisplayName: string;
  lSearchPath, lMathFileName: string;
  lFileList: TStringList;
  lSearchParam: TSearchFileParam;
  lDeptFileName: string;
begin
  Result := nil;

  { !!! 取子部门 }
  lFileList := TStringList.Create;
  try
    lSearchPath := FileSys.FileUtils.AddPathSeparator(Parent.FileName);
    lMathFileName := '*' + BizObjConsts.cDeptExt;
    lSearchParam := FileSys.SearchFileParam(lMathFileName, False);
    { 调用文件系统接口搜索子部门 }
    FileSys.FileSystem.SearchFile(lSearchPath, lSearchParam, lFileList);
    for I := 0 to lFileList.Count - 1 do
    begin
      lDeptFileName := lFileList[I];
      {
      ...
      !!! 在此计算部门编号。lDeptFileName 就是子部门的文件名。
      }
    end;
  finally
    lFileList.Free;
  end;



  {!!! 在此对 lID 和 lDisplayName 进行赋值,赋值为你经过计算加 1 后的ID,相加
    计算的代码我不写,你自己补写,当是机构和部门时我暂且分别赋值为 001 和 中国
    总公司、 001001 和 XXX部门 }
  case AKind of
    TBizObjectKind.boOrgan:
      begin
        lID := '001';
        lDisplayName := '中国总公司';
      end;
    TBizObjectKind.boDept:
      begin
        lID := '001001';
        lDisplayName := 'XXX部门';
      end;
  end;

  if ShowInputIDNameDialog(AKind, Parent, lID, lDisplayName) then
    Result := Org.OrgSys.OrgSystem.CreateUnit(Parent, lID, AKind, lDisplayName);
end;
回复 支持 反对

使用道具 举报

 楼主| 发表于 2004-5-9 11:05:22 | 显示全部楼层
lFileList.Count - 1
怎么每次都是0  还有搜索的是*.dpt  那么搜索*.ogn 怎么处理呢?

用这个吧 BizObjConsts.cOrganExt

返回的lDeptFileName 是有扩展的吗? 是以下的那种

Org:\ROOT\002.OGN\002001.ogn

002001.ogn
回复 支持 反对

使用道具 举报

发表于 2004-5-9 11:11:55 | 显示全部楼层

要搜索机构,将 lMathFileName := '*' + BizObjConsts.cDeptExt;

要搜索机构,将
   lMathFileName := '*' + BizObjConsts.cDeptExt;
换成
   lMathFileName := '*' + BizObjConsts.cOrganExt;
即可。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-5-4 13:16 , Processed in 0.047350 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表