Example #1
0
        /// <summary>
        /// 增加二级管理员.
        /// </summary>
        /// <param name="empID"></param>
        /// <returns></returns>
        public string DoAddAdminer(string empID)
        {
            BP.Port.Emp emp = new BP.Port.Emp();
            emp.No = empID;
            if (emp.RetrieveFromDBSources() == 0)
            {
                return("err@管理员增加失败,ID=" + empID + "不存在用户表,您增加的管理员必须存在与Port_Emp用户表.");
            }

            AdminEmp adminEmp = new AdminEmp();

            adminEmp.No = empID;
            if (adminEmp.RetrieveFromDBSources() == 1)
            {
                return("err@管理员【" + adminEmp.Name + "】已经存在,您不需要在增加.");
            }

            adminEmp.Copy(emp);
            adminEmp.FK_Dept    = WebUser.FK_Dept;
            adminEmp.RootOfDept = WebUser.FK_Dept;
            adminEmp.UserType   = 1;
            adminEmp.Insert();

            return("增加成功,请关闭当前窗口查询到该管理员,设置他的权限。");
        }
Example #2
0
        public string SetSubInc(string userNo)
        {
            //检查是否有该用户.
            BP.Port.Emp emp = new BP.Port.Emp();
            emp.No = userNo;
            if (emp.RetrieveFromDBSources() == 0)
            {
                return("err@用户编号错误:" + userNo);
            }

            AdminEmp ad = new AdminEmp();

            ad.No = userNo + "@" + this.No;
            if (ad.RetrieveFromDBSources() == 1)
            {
                return("err@该用户已经是该公司的管理员了.");
            }

            ad.Copy(emp);
            ad.No         = userNo + "@" + this.No; //增加一个影子版本.
            ad.RootOfDept = this.No;
            ad.RootOfFlow = "Inc" + this.No;
            ad.RootOfForm = "Inc" + this.No;
            ad.UserType   = 1;
            ad.UseSta     = 1;
            ad.Insert();

            //设置二级管理员.
            ad.No = userNo;
            if (ad.RetrieveFromDBSources() == 0)
            {
                ad.Copy(emp);
                ad.RootOfDept = this.No;
                ad.RootOfFlow = "Inc" + this.No;
                ad.RootOfForm = "Inc" + this.No;
                ad.UserType   = 1;
                ad.UseSta     = 1;
                ad.Insert();
            }
            else
            {
                ad.RootOfDept = this.No;
                ad.RootOfFlow = "Inc" + this.No;
                ad.RootOfForm = "Inc" + this.No;
                ad.UserType   = 1;
                ad.UseSta     = 1;
                ad.Update();
            }

            //初始化表单树,流程树.
            InitFlowSortTree();

            return("设置成功,[" + ad.No + "," + ad.Name + "]重新登录就可以看到.");
        }
Example #3
0
        public string DoAdd(string empNo, string orgNo)
        {
            BP.Port.Emp emp = new BP.Port.Emp();
            emp.No = empNo;
            if (emp.RetrieveFromDBSources() == 0)
            {
                return("err@管理员增加失败,ID=" + empNo + "不存在用户表,您增加的管理员必须存在与Port_Emp用户表.");
            }

            BP.Port.Dept dept = new BP.Port.Dept();
            dept.No = orgNo;
            if (dept.RetrieveFromDBSources() == 0)
            {
                return("err@orgNo错误, 不存在 Port_Dept 里面。");
            }

            BP.WF.Port.Inc inc = new BP.WF.Port.Inc();
            inc.No = orgNo;
            if (inc.RetrieveFromDBSources() == 0)
            {
                return("err@orgNo错误, 不存在 Port_Inc 里面。");
            }

            //求根目录流程树.
            BP.WF.Template.FlowSort fsRoot = new WF.Template.FlowSort();
            fsRoot.Retrieve(BP.WF.Template.FlowSortAttr.ParentNo, "0");


            BP.WF.Template.FlowSort fs = new WF.Template.FlowSort();
            fs.No = "Inc" + orgNo;
            if (fs.RetrieveFromDBSources() == 1)
            {
                return("err@该组织已经初始化过流程树目录.");
            }

            fs.Name     = dept.Name + "-流程树";
            fs.ParentNo = fsRoot.No;
            fs.OrgNo    = dept.No;
            fs.Insert();


            //求根目录流程树.
            BP.Sys.FrmTree frmRoot = new BP.Sys.FrmTree();
            frmRoot.Retrieve(BP.WF.Template.FlowSortAttr.ParentNo, "0");

            BP.Sys.FrmTree frmTree = new BP.Sys.FrmTree();
            frmTree.No = "Inc" + orgNo;
            if (frmTree.RetrieveFromDBSources() == 1)
            {
                return("err@该组织已经初始化过表单树目录.");
            }

            frmTree.ParentNo = frmRoot.No;
            frmTree.Name     = dept.Name + "-表单树";
            frmTree.OrgNo    = dept.No;
            frmTree.Insert();


            AdminEmp ae = new AdminEmp();

            ae.No = empNo;
            if (ae.RetrieveFromDBSources() == 1)
            {
                if (ae.IsAdmin == true)
                {
                    return("err@该管理员已经存在,请删除该管理员重新增加delete from wf_emp where no='" + empNo + "'");
                }
                ae.Delete();
            }



            ae.Copy(emp);

            ae.UserType   = 1;
            ae.UseSta     = 1;
            ae.RootOfDept = orgNo;
            ae.RootOfFlow = "Inc" + orgNo;
            ae.RootOfForm = "Inc" + orgNo;
            ae.Insert();

            return("info@管理员增加成功.");
        }