Beispiel #1
0
        // 如果用户安装时选择不安装案例,则流程树、表单树和组织结构表都不存在根节点,此时需要手动添加根节点,
        // 流程设计器初始化时调用
        // 此功能应该添加到安装时,因为每次流程树加载都需要执行一次检查
        private bool TreeRootCheck()
        {
            try
            {
                // 流程树根节点校验
                string tmp = "SELECT Name FROM WF_FlowSort where ParentNo =0";
                tmp = DBAccess.RunSQLReturnString(tmp);
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "INSERT INTO WF_FlowSort(No,Name,ParentNo,TreeNo,idx,IsDir) values('99','流程树','0','',0,0)";
                    DBAccess.RunSQLReturnString(tmp);
                }

                // 表单树根节点校验
                tmp = "SELECT Name FROM Sys_FormTree where ParentNo =0";
                tmp = DBAccess.RunSQLReturnString(tmp);
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "INSERT INTO Sys_FormTree(No,Name,ParentNo,TreeNo,idx,IsDir) values('99','表单树','0','',0,0)";
                    DBAccess.RunSQLReturnString(tmp);
                }

                // 组织结构校验
                model = (OSModel)Enum.Parse(typeof(OSModel), this.GetConfig("OSModel"), true);
                if (model == BP.Sys.OSModel.OneOne)
                {
                    BP.GPM.Depts rootDepts = new BP.GPM.Depts("0");
                    if (rootDepts == null || rootDepts.Count == 0)
                    {
                        BP.GPM.Dept rootDept = new BP.GPM.Dept();
                        rootDept.Name = "集团总部";
                        rootDept.No   = "0";
                        rootDept.Idx  = 0;
                        rootDept.Insert();
                    }
                }
                else if (model == BP.Sys.OSModel.OneOne)
                {
                    BP.Port.Depts rootDepts = new BP.Port.Depts("0");
                    if (rootDepts == null || rootDepts.Count == 0)
                    {
                        BP.GPM.Dept rootDept = new BP.GPM.Dept();
                        rootDept.Name = "集团总部";
                        rootDept.No   = "0";
                        rootDept.Idx  = 0;
                        rootDept.Insert();
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                throw new Exception("流程树根节点检查错误", e);
            }
        }
Beispiel #2
0
        public static GPMEmp GenerData(GPMEmp en)
        {
            //增加拼音,以方便查找.
            string pinyinQP = BP.DA.DataType.ParseStringToPinyin(en.Name).ToLower();
            string pinyinJX = BP.DA.DataType.ParseStringToPinyinJianXie(en.Name).ToLower();

            en.PinYin = "," + pinyinQP + "," + pinyinJX + ",";

            //处理岗位信息.
            DeptEmpStations des = new DeptEmpStations();

            des.Retrieve(DeptEmpStationAttr.FK_Emp, en.No);

            string depts = "";
            string stas  = "";

            foreach (DeptEmpStation item in des)
            {
                BP.GPM.Dept dept = new BP.GPM.Dept();
                dept.No = item.FK_Dept;
                if (dept.RetrieveFromDBSources() == 0)
                {
                    item.Delete();
                    continue;
                }

                //给拼音重新定义值,让其加上部门的信息.
                en.PinYin = en.PinYin + pinyinJX + "/" + BP.DA.DataType.ParseStringToPinyinJianXie(dept.Name).ToLower() + ",";

                BP.Port.Station sta = new BP.Port.Station();
                sta.No = item.FK_Station;
                if (sta.RetrieveFromDBSources() == 0)
                {
                    item.Delete();
                    continue;
                }

                stas += "@" + dept.NameOfPath + "|" + sta.Name;

                if (depts.Contains("@" + dept.NameOfPath) == false)
                {
                    depts += "@" + dept.NameOfPath;
                }
            }
            return(en);
        }
Beispiel #3
0
        protected override bool beforeUpdateInsertAction()
        {
            //增加拼音,以方便查找.
            string pinyinQP = BP.DA.DataType.ParseStringToPinyin(this.Name).ToLower();
            string pinyinJX = BP.DA.DataType.ParseStringToPinyinJianXie(this.Name).ToLower();

            this.PinYin = "," + pinyinQP + "," + pinyinJX + ",";

            //处理岗位信息.
            DeptEmpStations des = new DeptEmpStations();

            des.Retrieve(DeptEmpStationAttr.FK_Emp, this.No);

            string depts = "";
            string stas  = "";

            foreach (DeptEmpStation item in des)
            {
                BP.GPM.Dept dept = new BP.GPM.Dept();
                dept.No = item.FK_Dept;
                if (dept.RetrieveFromDBSources() == 0)
                {
                    item.Delete();
                    continue;
                }

                //给拼音重新定义值,让其加上部门的信息.
                this.PinYin = this.PinYin + pinyinJX + "/" + BP.DA.DataType.ParseStringToPinyinJianXie(dept.Name).ToLower() + ",";

                BP.Port.Station sta = new Port.Station();
                sta.No = item.FK_Station;
                if (sta.RetrieveFromDBSources() == 0)
                {
                    item.Delete();
                    continue;
                }

                stas  += "@" + dept.NameOfPath + "|" + sta.Name;
                depts += "@" + dept.NameOfPath;
            }


            return(base.beforeUpdateInsertAction());
        }
Beispiel #4
0
        public static string GenerPinYin(string no, string name)
        {
            //增加拼音,以方便查找.
            string pinyinQP = BP.DA.DataType.ParseStringToPinyin(name).ToLower();
            string pinyinJX = BP.DA.DataType.ParseStringToPinyinJianXie(name).ToLower();
            string py       = "," + pinyinQP + "," + pinyinJX + ",";

            //处理岗位信息.
            DeptEmpStations des = new DeptEmpStations();

            des.Retrieve(DeptEmpStationAttr.FK_Emp, no);

            string depts = "";
            string stas  = "";

            foreach (DeptEmpStation item in des)
            {
                BP.GPM.Dept dept = new BP.GPM.Dept();
                dept.No = item.FK_Dept;
                if (dept.RetrieveFromDBSources() == 0)
                {
                    item.Delete();
                    continue;
                }

                //给拼音重新定义值,让其加上部门的信息.
                py = py + pinyinJX + "/" + BP.DA.DataType.ParseStringToPinyinJianXie(dept.Name).ToLower() + ",";

                BP.Port.Station sta = new Port.Station();
                sta.No = item.FK_Station;
                if (sta.RetrieveFromDBSources() == 0)
                {
                    item.Delete();
                    continue;
                }

                stas  += "@" + dept.NameOfPath + "|" + sta.Name;
                depts += "@" + dept.NameOfPath;
            }

            return(py);
        }
Beispiel #5
0
        /// <summary>
        /// 获取指定部门下一级子部门列表
        /// </summary>
        /// <returns></returns>
        public string Dot2DotTreeDeptModel_GetSubDepts()
        {
            string parentid = this.GetRequestVal("parentid");
            string nid      = this.GetRequestVal("nodeid");

            if (string.IsNullOrWhiteSpace(parentid))
            {
                throw new Exception("参数parentid不能为空");
            }
            if (string.IsNullOrWhiteSpace(nid))
            {
                throw new Exception("参数nodeid不能为空");
            }

            EasyuiTreeNode        node = null;
            List <EasyuiTreeNode> d    = new List <EasyuiTreeNode>();

            BP.WF.Template.NodeDepts sdepts = new BP.WF.Template.NodeDepts();

            sdepts.Retrieve(BP.WF.Template.NodeDeptAttr.FK_Node, int.Parse(nid));

            if (BP.WF.Glo.OSModel == OSModel.OneOne)
            {
                BP.Port.Dept  parentDept = new BP.Port.Dept(parentid);
                BP.Port.Depts depts      = new BP.Port.Depts();
                depts.Retrieve(BP.Port.DeptAttr.ParentNo, parentid);

                //增加部门
                foreach (BP.Port.Dept dept in depts)
                {
                    node                       = new EasyuiTreeNode();
                    node.id                    = "DEPT_" + dept.No;
                    node.text                  = dept.Name;
                    node.iconCls               = "icon-department";
                    node.@checked              = sdepts.GetEntityByKey(BP.WF.Template.NodeDeptAttr.FK_Dept, dept.No) != null;
                    node.attributes            = new EasyuiTreeNodeAttributes();
                    node.attributes.No         = dept.No;
                    node.attributes.Name       = dept.Name;
                    node.attributes.ParentNo   = parentDept.No;
                    node.attributes.ParentName = parentDept.Name;
                    node.attributes.TType      = "DEPT";
                    node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(dept.Name);
                    node.state                 = "closed";
                    node.children              = new List <EasyuiTreeNode>();
                    node.children.Add(new EasyuiTreeNode());
                    node.children[0].text = "loading...";

                    d.Add(node);
                }
            }
            else
            {
                BP.GPM.Dept  parentDept = new BP.GPM.Dept(parentid);
                BP.GPM.Depts depts      = new BP.GPM.Depts();
                depts.Retrieve(BP.GPM.DeptAttr.ParentNo, parentid, BP.GPM.DeptAttr.Idx);

                //增加部门
                foreach (BP.GPM.Dept dept in depts)
                {
                    node                       = new EasyuiTreeNode();
                    node.id                    = "DEPT_" + dept.No;
                    node.text                  = dept.Name;
                    node.iconCls               = "icon-department";
                    node.@checked              = sdepts.GetEntityByKey(BP.WF.Template.NodeDeptAttr.FK_Dept, dept.No) != null;
                    node.attributes            = new EasyuiTreeNodeAttributes();
                    node.attributes.No         = dept.No;
                    node.attributes.Name       = dept.Name;
                    node.attributes.ParentNo   = parentDept.No;
                    node.attributes.ParentName = parentDept.Name;
                    node.attributes.TType      = "DEPT";
                    node.attributes.Code       = BP.Tools.chs2py.ConvertStr2Code(dept.Name);
                    node.state                 = "closed";
                    node.children              = new List <EasyuiTreeNode>();
                    node.children.Add(new EasyuiTreeNode());
                    node.children[0].text = "loading...";

                    d.Add(node);
                }
            }

            return(Newtonsoft.Json.JsonConvert.SerializeObject(d));
        }
Beispiel #6
0
        /// <summary>
        /// 获取部门树根结点
        /// </summary>
        /// <returns></returns>
        public string Dot2DotTreeDeptModel_GetStructureTreeRoot()
        {
            JsonResultInnerData jr = new JsonResultInnerData();

            EasyuiTreeNode        node = null;
            List <EasyuiTreeNode> d    = new List <EasyuiTreeNode>();
            string parentrootid        = this.GetRequestVal("parentrootid");
            string nodeid = this.GetRequestVal("nodeid");

            if (string.IsNullOrWhiteSpace(parentrootid))
            {
                throw new Exception("参数parentrootid不能为空");
            }
            if (string.IsNullOrWhiteSpace(nodeid))
            {
                throw new Exception("参数nodeid不能为空");
            }

            if (BP.WF.Glo.OSModel == OSModel.OneOne)
            {
                BP.WF.Port.Dept dept = new BP.WF.Port.Dept();

                if (dept.Retrieve(BP.WF.Port.DeptAttr.ParentNo, parentrootid) == 0)
                {
                    dept.No       = "-1";
                    dept.Name     = "无部门";
                    dept.ParentNo = "";
                }

                node                     = new EasyuiTreeNode();
                node.id                  = "DEPT_" + dept.No;
                node.text                = dept.Name;
                node.iconCls             = "icon-department";
                node.attributes          = new EasyuiTreeNodeAttributes();
                node.attributes.No       = dept.No;
                node.attributes.Name     = dept.Name;
                node.attributes.ParentNo = dept.ParentNo;
                node.@checked            = new NodeDept().IsExit(NodeDeptAttr.FK_Node, int.Parse(nodeid), NodeDeptAttr.FK_Dept,
                                                                 dept.No);
                node.attributes.TType = "DEPT";
                node.state            = "closed";
                node.children         = new List <EasyuiTreeNode>();
                node.children.Add(new EasyuiTreeNode());
                node.children[0].text = "loading...";

                d.Add(node);
            }
            else
            {
                BP.GPM.Dept dept = new BP.GPM.Dept();

                if (dept.Retrieve(BP.GPM.DeptAttr.ParentNo, parentrootid) == 0)
                {
                    dept.No       = "-1";
                    dept.Name     = "无部门";
                    dept.ParentNo = "";
                }

                node                     = new EasyuiTreeNode();
                node.id                  = "DEPT_" + dept.No;
                node.text                = dept.Name;
                node.iconCls             = "icon-department";
                node.attributes          = new EasyuiTreeNodeAttributes();
                node.attributes.No       = dept.No;
                node.attributes.Name     = dept.Name;
                node.attributes.ParentNo = dept.ParentNo;
                node.@checked            = new NodeDept().IsExit(NodeDeptAttr.FK_Node, int.Parse(nodeid), NodeDeptAttr.FK_Dept,
                                                                 dept.No);
                node.attributes.TType = "DEPT";
                node.state            = "closed";
                node.children         = new List <EasyuiTreeNode>();
                node.children.Add(new EasyuiTreeNode());
                node.children[0].text = "loading...";

                d.Add(node);
            }

            jr.InnerData = d;

            return(Newtonsoft.Json.JsonConvert.SerializeObject(jr));
        }
Beispiel #7
0
        protected void btnImport_Click(object sender, EventArgs e)
        {
            if (!file.HasFile)
            {
                AlertAndBack("请选择组织结构Excel文件(*.xls)!");
                return;
            }

            //检查是否是.xls格式,2007格式,下面的方法有问题,暂时限定为xls格式
            if (Path.GetExtension(file.PostedFile.FileName).ToLower() != ".xls")
            {
                AlertAndBack("组织结构Excel文件必须是*.xls(Microsoft Excel 97-2003格式)!");
                return;
            }

            var updir = Path.Combine(BP.Sys.SystemConfig.PathOfDataUser, "UploadFile");

            if (Directory.Exists(updir) == false)
            {
                Directory.CreateDirectory(updir);
            }

            var xls = Path.Combine(updir, "Org_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls");

            file.PostedFile.SaveAs(xls);

            var excel = new NPOIExcel(xls);

            //检查是否包含3个表
            var sheets = excel.GetSheetNames();// BP.DA.DBLoad.GenerTableNames(xls);

            if (sheets.Contains("岗位") == false || sheets.Contains("部门") == false || sheets.Contains("人员") == false)
            {
                DeleteFile(xls);
                AlertAndBack("组织结构Excel文件必须由“ccflow组织结构批量导入模板”文件编辑而成,请下载模板文件重新编辑,再进行导入!");
                return;
            }

            var colStations = new[] { "岗位名称", "岗位类型" };
            var colDepts    = new[] { "部门名称", "上级部门名称", "部门负责人" };
            var colEmps     = new[] { "人员帐号", "人员姓名", "人员编号", "部门", "岗位", "职务", "电话", "邮箱", "直属领导" };

            var dtStation = excel.ExcelToDataTable("岗位", true); // BP.DA.DBLoad.GetTableByExt(xls, "SELECT * FROM [岗位$]"); //岗位名称*,岗位类型*
            var dtDept    = excel.ExcelToDataTable("部门", true); // BP.DA.DBLoad.GetTableByExt(xls, "SELECT * FROM [部门$]");    //部门名称*,上级部门名称*,部门负责人
            var dtEmp     = excel.ExcelToDataTable("人员", true); // BP.DA.DBLoad.GetTableByExt(xls, "SELECT * FROM [人员$]");     //人员帐号*,人员姓名*,人员编号,部门*,岗位*,职务,电话,邮箱,直属领导

            //初步检查列数
            if (dtStation.Columns.Count < 2 || dtDept.Columns.Count < 3 || dtEmp.Columns.Count < 9)
            {
                AlertAndBack("组织结构Excel文件结构错误,请重新下载模板文件编辑后,再进行导入!");
                return;
            }

            //检查岗位列
            if (CheckColumns(dtStation, colStations, "岗位") == false)
            {
                return;
            }

            //检查部门列
            if (CheckColumns(dtDept, colDepts, "部门") == false)
            {
                return;
            }

            //检查人员列
            if (CheckColumns(dtEmp, colEmps, "人员") == false)
            {
                return;
            }

            excel.Dispose();
            //return;
            //获取数据库中已有数据,便于下面的数据对比
            var isBPM        = BP.WF.Glo.OSModel == BP.WF.OSModel.BPM;
            var stations     = new BP.GPM.Stations();
            var stationTypes = new BP.GPM.StationTypes();
            var depts        = new BP.GPM.Depts();
            var emps         = new BP.GPM.Emps();
            var deptEmpSts   = new BP.GPM.DeptEmpStations();

            stations.RetrieveAll();
            stationTypes.RetrieveAll();
            depts.RetrieveAll();
            emps.RetrieveAll();
            deptEmpSts.RetrieveAll();

            //集成模式,涉及数据
            var empDepts = new EmpDepts();
            var empSts   = new EmpStations();

            empDepts.RetrieveAll();
            empSts.RetrieveAll();

            //BPM独立模式,涉及数据
            var duties     = new BP.GPM.Dutys();
            var deptDuties = new BP.GPM.DeptDutys();
            var deptSts    = new BP.GPM.DeptStations();
            var deptEmps   = new BP.GPM.DeptEmps();

            duties.RetrieveAll();
            deptDuties.RetrieveAll();
            deptSts.RetrieveAll();
            deptEmps.RetrieveAll();

            //定义错误记录存储表
            var     dtStationError = dtStation.Clone();
            var     dtDeptError    = dtDept.Clone();
            var     dtEmpError     = dtEmp.Clone();
            DataRow drError        = null;
            bool    haveDuty       = false;

            BP.GPM.Station        st       = null;
            BP.GPM.StationType    stType   = null;
            BP.GPM.Dept           dept     = null;
            BP.GPM.Emp            emp      = null;
            BP.GPM.DeptEmpStation des      = null;
            BP.Port.EmpDept       empDept  = null;
            BP.Port.EmpStation    empSt    = null;
            BP.GPM.Duty           duty     = null;
            BP.GPM.DeptDuty       deptDuty = null;
            BP.GPM.DeptStation    deptSt   = null;
            BP.GPM.DeptEmp        deptEmp  = null;

            //检查数据,并将符合规范的数据写入数据库

            #region //岗位信息
            foreach (DataRow dr in dtStation.Rows)
            {
                drError = dtStationError.NewRow();
                dtStationError.Rows.Add(drError);

                //检查岗位,名称、类型必须填写,且名称不能重复
                if (IsCellNull(dr, "岗位名称"))
                {
                    drError["岗位名称"] = "岗位名称必须填写!";
                    continue;
                }

                if (IsCellNull(dr, "岗位类型"))
                {
                    drError["岗位类型"] = "岗位类型必须填写!";
                    continue;
                }

                //判断数据库中是否已经存在
                if (stations.GetEntityByKey(BP.GPM.StationAttr.Name, dr["岗位名称"].ToString()) != null)
                {
                    continue;
                }

                stType = stationTypes.GetEntityByKey(BP.GPM.StationTypeAttr.Name, dr["岗位类型"].ToString()) as BP.GPM.StationType;

                if (stType == null)
                {
                    stType = new BP.GPM.StationType {
                        Name = dr["岗位类型"].ToString()
                    };
                    stType.No = stType.GenerNewNo;
                    stType.Insert();
                    stationTypes.AddEntity(stType);
                }

                st = new BP.GPM.Station
                {
                    Name           = dr["岗位名称"].ToString(),
                    FK_StationType = stType.No
                };
                //st.No = st.GenerNewNo;
                st.Insert();
                stations.AddEntity(st);
            }
            #endregion

            #region  //部门信息
            BP.GPM.Dept parentDept = null;

            foreach (DataRow dr in dtDept.Rows)
            {
                drError = dtDeptError.NewRow();
                dtDeptError.Rows.Add(drError);

                //检查部门,名称必须填写,且名称不能重复
                if (IsCellNull(dr, "部门名称"))
                {
                    drError["部门名称"] = "部门名称必须填写!";
                    continue;
                }

                if (!IsCellNull(dr, "上级部门名称"))
                {
                    parentDept = depts.GetEntityByKey(EntityTreeAttr.Name, dr["上级部门名称"].ToString()) as BP.GPM.Dept;

                    if (parentDept == null)
                    {
                        drError["上级部门名称"] = "上级部门名称 填写错误,未找到上级部门“" + dr["上级部门名称"] + "”!";
                        continue;
                    }
                }
                else
                {
                    parentDept = null;
                }

                //判断数据库中是否已经存在
                if (depts.GetEntityByKey(EntityTreeAttr.Name, dr["部门名称"].ToString(), EntityTreeAttr.ParentNo, parentDept == null ? "0" : parentDept.No) != null)
                {
                    continue;
                }

                if (parentDept == null)
                {
                    //增加根部门
                    dept = depts.GetEntityByKey(EntityTreeAttr.ParentNo, "0") as BP.GPM.Dept;
                    if (dept == null)
                    {
                        //不存在根部门
                        dept = new BP.GPM.Dept
                        {
                            No       = "100",
                            Name     = dr["部门名称"].ToString(),
                            ParentNo = "0",
                            Leader   = dr["部门负责人"].ToString(),
                            IsDir    = false
                        };

                        dept.Insert();
                    }
                    else
                    {
                        //已经存在根部门,建立一个同级别的根部门
                        dept.Name   = dr["部门名称"].ToString();
                        dept.Leader = dr["部门负责人"].ToString();

                        //var currDept = dept.DoCreateSameLevelNode();

                        //dept = new BP.GPM.Dept(currDept.No)
                        //           {
                        //               Name = dr["部门名称"].ToString(),
                        //               Leader = dr["部门负责人"].ToString()
                        //           };

                        dept.Update();
                    }

                    depts.AddEntity(dept);
                }
                else
                {
                    //增加非根部门
                    var currDept = parentDept.DoCreateSubNode();

                    dept = new BP.GPM.Dept(currDept.No)
                    {
                        Name   = dr["部门名称"].ToString(),
                        Leader = dr["部门负责人"].ToString()
                    };

                    dept.Update();
                    depts.AddEntity(dept);
                }
            }
            #endregion

            #region //人员信息
            foreach (DataRow dr in dtEmp.Rows)
            {
                drError = dtEmpError.NewRow();
                dtEmpError.Rows.Add(drError);

                #region //检查人员,帐号、姓名、部门、岗位必须填写
                if (IsCellNull(dr, "人员帐号"))
                {
                    drError["人员帐号"] = "人员帐号必须填写!";
                    continue;
                }

                if (IsCellNull(dr, "人员姓名"))
                {
                    drError["人员姓名"] = "人员姓名必须填写!";
                    continue;
                }

                if (IsCellNull(dr, "部门"))
                {
                    drError["部门"] = "部门必须填写!";
                    continue;
                }

                if (IsCellNull(dr, "岗位"))
                {
                    drError["岗位"] = "岗位必须填写!";
                    continue;
                }
                #endregion

                //判断人员在数据库中是否已经存在
                emp = emps.GetEntityByKey(EntityNoAttr.No, dr["人员帐号"].ToString(), EntityNoNameAttr.Name,
                                          dr["人员姓名"].ToString()) as BP.GPM.Emp;
                dept = depts.GetEntityByKey(BP.GPM.DeptAttr.Name, dr["部门"].ToString()) as BP.GPM.Dept;
                st   = stations.GetEntityByKey(BP.GPM.StationAttr.Name, dr["岗位"].ToString()) as BP.GPM.Station;

                if (dept == null)
                {
                    drError["部门"] = string.Format("部门填写错误,“{0}” 在部门中未查到!", dr["部门"]);
                    continue;
                }

                if (st == null)
                {
                    drError["岗位"] = string.Format("岗位填写错误,“{0}” 在岗位中未查到!", dr["岗位"]);
                    continue;
                }

                if (isBPM)
                {
                    //BPM模式,Duty,DeptDuty
                    if (!IsCellNull(dr, "职务"))
                    {
                        duty = duties.GetEntityByKey(BP.GPM.DutyAttr.Name, dr["职务"].ToString()) as BP.GPM.Duty;
                    }
                    else
                    {
                        if (duties.Count == 0)
                        {
                            duty = new BP.GPM.Duty {
                                Name = "默认职务"
                            };
                            duty.Insert();
                            duties.AddEntity(duty);
                        }
                        else
                        {
                            duty = duties[0] as BP.GPM.Duty;
                        }
                    }

                    if (duty == null)
                    {
                        duty = new BP.GPM.Duty {
                            Name = dr["职务"].ToString()
                        };
                        //duty.No = duty.GenerNewNo;
                        duty.Insert();
                        duties.AddEntity(duty);
                    }

                    deptDuty =
                        deptDuties.GetEntityByKey(BP.GPM.DeptDutyAttr.FK_Dept, dept.No, BP.GPM.DeptDutyAttr.FK_Duty,
                                                  duty.No) as BP.GPM.DeptDuty;

                    if (deptDuty == null)
                    {
                        deptDuty = new BP.GPM.DeptDuty {
                            FK_Dept = dept.No, FK_Duty = duty.No
                        };
                        deptDuty.Insert();
                        deptDuties.AddEntity(deptDuty);
                    }
                }

                if (emp != null)
                {
                    //如果人员存在,则判断此人员的部门与岗位,如果部门、岗位不存在,则增加部门岗位关联等
                    //此处不对已存在人员的其他信息进行比对修改,如人员编号,邮箱,电话等
                    des = deptEmpSts.GetEntityByKey(BP.GPM.DeptEmpStationAttr.FK_Emp, emp.No,
                                                    BP.GPM.DeptEmpStationAttr.FK_Dept, dept.No,
                                                    BP.GPM.DeptEmpStationAttr.FK_Station, st.No) as BP.GPM.DeptEmpStation;

                    if (des != null)
                    {
                        drError["人员帐号"]   = drError["人员姓名"] =
                            drError["部门"] = drError["岗位"] = "此人员已经增加过,“人员+部门+岗位”不能重复!";
                        continue;
                    }
                }
                else
                {
                    //此人员不存在
                    emp = new BP.GPM.Emp
                    {
                        No      = dr["人员帐号"].ToString(),
                        Name    = dr["人员姓名"].ToString(),
                        Pass    = "******",
                        FK_Dept = dept.No
                    };

                    if (isBPM)
                    {
                        emp.EmpNo   = dr["人员编号"] as string;
                        emp.FK_Duty = duty.No;
                        emp.Email   = dr["邮箱"] as string;
                        emp.Tel     = dr["电话"] as string;
                        emp.Leader  = dr["直属领导"] as string;
                        emp.SetValByKey(BP.GPM.EmpAttr.NumOfDept, 1);
                    }

                    emp.Insert();
                    emps.AddEntity(emp);
                }

                des = new BP.GPM.DeptEmpStation
                {
                    FK_Emp     = emp.No,
                    FK_Dept    = dept.No,
                    FK_Station = st.No
                };

                des.Insert();
                deptEmpSts.AddEntity(des);

                if (isBPM)
                {
                    //BPM模式,DeptStation,DeptEmp
                    deptSt = deptSts.GetEntityByKey(BP.GPM.DeptStationAttr.FK_Dept, dept.No,
                                                    BP.GPM.DeptStationAttr.FK_Station, st.No) as BP.GPM.DeptStation;

                    if (deptSt == null)
                    {
                        deptSt = new BP.GPM.DeptStation {
                            FK_Dept = dept.No, FK_Station = st.No
                        };
                        deptSt.Insert();
                        deptSts.AddEntity(deptSt);
                    }

                    deptEmp =
                        deptEmps.GetEntityByKey(BP.GPM.DeptEmpAttr.FK_Dept, dept.No, BP.GPM.DeptEmpAttr.FK_Emp,
                                                emp.No) as BP.GPM.DeptEmp;

                    if (deptEmp == null)
                    {
                        deptEmp = new BP.GPM.DeptEmp
                        {
                            FK_Dept = dept.No,
                            FK_Emp  = emp.No,
                            FK_Duty = duty.No
                        };
                        deptEmp.Insert();
                        deptEmps.AddEntity(deptEmp);
                    }
                }
                else
                {
                    //集成模式,EmpDept,EmpStation
                    empDept =
                        empDepts.GetEntityByKey(EmpDeptAttr.FK_Dept, dept.No, EmpDeptAttr.FK_Emp, emp.No) as EmpDept;

                    if (empDept == null)
                    {
                        empDept = new EmpDept {
                            FK_Emp = emp.No, FK_Dept = dept.No
                        };
                        empDept.Insert();
                        empDepts.AddEntity(empDept);
                    }

                    empSt =
                        empSts.GetEntityByKey(EmpStationAttr.FK_Emp, emp.No, EmpStationAttr.FK_Station, st.No) as
                        EmpStation;

                    if (empSt == null)
                    {
                        empSt = new EmpStation {
                            FK_Emp = emp.No, FK_Station = st.No
                        };
                        empSt.Insert();
                        empSts.AddEntity(empSt);
                    }
                }
            }
            #endregion

            #region //前台输出岗位信息

            pub1.AddTableNormal();
            pub1.AddTR();
            pub1.AddTDGroupTitle("style='text-align:center;width:60px;'", "序");
            pub1.AddTDGroupTitle("style='width:140px;'", "名称");
            pub1.AddTDGroupTitle("类型");
            pub1.AddTREnd();

            for (var i = 0; i < dtStation.Rows.Count; i++)
            {
                drError = dtStationError.Rows[i];

                pub1.AddTR();
                pub1.AddTDIdx(i + 1);

                if (IsCellNull(drError, "岗位名称"))
                {
                    pub1.AddTD(dtStation.Rows[i]["岗位名称"].ToString());
                }
                else
                {
                    pub1.AddTD("style='background-color:yellow;color:red;' title='" + drError["岗位名称"] + "'",
                               dtStation.Rows[i]["岗位名称"].ToString());
                }

                if (IsCellNull(drError, "岗位类型"))
                {
                    pub1.AddTD(dtStation.Rows[i]["岗位类型"].ToString());
                }
                else
                {
                    pub1.AddTD("style='background-color:yellow;color:red;' title='" + drError["岗位类型"] + "'",
                               dtStation.Rows[i]["岗位类型"].ToString());
                }

                pub1.AddTREnd();
            }

            pub1.AddTableEnd();
            #endregion

            #region //前台输出部门信息

            pub2.AddTableNormal();
            pub2.AddTR();
            pub2.AddTDGroupTitle("style='text-align:center;width:60px;'", "序");
            pub2.AddTDGroupTitle("style='width:140px;'", "名称");
            pub2.AddTDGroupTitle("style='width:140px;'", "上级名称");
            pub2.AddTDGroupTitle("部门负责人");
            pub2.AddTREnd();

            for (var i = 0; i < dtDept.Rows.Count; i++)
            {
                drError = dtDeptError.Rows[i];

                pub2.AddTR();
                pub2.AddTDIdx(i + 1);

                if (IsCellNull(drError, "部门名称"))
                {
                    pub2.AddTD(dtDept.Rows[i]["部门名称"].ToString());
                }
                else
                {
                    pub2.AddTD("style='background-color:yellow;color:red;' title='" + drError["部门名称"] + "'",
                               dtDept.Rows[i]["部门名称"].ToString());
                }

                if (IsCellNull(drError, "上级部门名称"))
                {
                    pub2.AddTD(dtDept.Rows[i]["上级部门名称"].ToString());
                }
                else
                {
                    pub2.AddTD("style='background-color:yellow;color:red;' title='" + drError["上级部门名称"] + "'",
                               dtDept.Rows[i]["上级部门名称"].ToString());
                }

                pub2.AddTD(dtDept.Rows[i]["部门负责人"].ToString());
                pub2.AddTREnd();
            }

            pub2.AddTableEnd();
            #endregion

            #region //前台输出人员信息

            pub3.AddTableNormal();
            pub3.AddTR();
            pub3.AddTDGroupTitle("style='text-align:center;width:60px;'", "序");
            pub3.AddTDGroupTitle("style='width:120px;'", "帐号");
            pub3.AddTDGroupTitle("style='width:100px;'", "姓名");

            if (isBPM)
            {
                pub3.AddTDGroupTitle("style='width:100px;'", "编号");
            }

            pub3.AddTDGroupTitle("style='width:180px;'", "部门");

            if (!isBPM)
            {
                pub3.AddTDGroupTitle("岗位");
            }
            else
            {
                pub3.AddTDGroupTitle("style='width:100px;'", "岗位");
                pub3.AddTDGroupTitle("style='width:100px;'", "职务");
                pub3.AddTDGroupTitle("style='width:120px;'", "电话");
                pub3.AddTDGroupTitle("style='width:160px;'", "邮箱");
                pub3.AddTDGroupTitle("直属领导");
            }

            pub3.AddTREnd();

            for (var i = 0; i < dtEmp.Rows.Count; i++)
            {
                drError = dtEmpError.Rows[i];

                pub3.AddTR();
                pub3.AddTDIdx(i + 1);

                if (IsCellNull(drError, "人员帐号"))
                {
                    pub3.AddTD(dtEmp.Rows[i]["人员帐号"].ToString());
                }
                else
                {
                    pub3.AddTD("style='background-color:yellow;color:red;' title='" + drError["人员帐号"] + "'",
                               dtEmp.Rows[i]["人员帐号"].ToString());
                }

                if (IsCellNull(drError, "人员姓名"))
                {
                    pub3.AddTD(dtEmp.Rows[i]["人员姓名"].ToString());
                }
                else
                {
                    pub3.AddTD("style='background-color:yellow;color:red;' title='" + drError["人员姓名"] + "'",
                               dtEmp.Rows[i]["人员姓名"].ToString());
                }

                if (isBPM)
                {
                    pub3.AddTD(dtEmp.Rows[i]["人员编号"].ToString());
                }

                if (IsCellNull(drError, "部门"))
                {
                    pub3.AddTD(dtEmp.Rows[i]["部门"].ToString());
                }
                else
                {
                    pub3.AddTD("style='background-color:yellow;color:red;' title='" + drError["部门"] + "'",
                               dtEmp.Rows[i]["部门"].ToString());
                }

                if (IsCellNull(drError, "岗位"))
                {
                    pub3.AddTD(dtEmp.Rows[i]["岗位"].ToString());
                }
                else
                {
                    pub3.AddTD("style='background-color:yellow;color:red;' title='" + drError["岗位"] + "'",
                               dtEmp.Rows[i]["岗位"].ToString());
                }

                if (isBPM)
                {
                    pub3.AddTD(dtEmp.Rows[i]["职务"].ToString());
                    pub3.AddTD(dtEmp.Rows[i]["电话"].ToString());
                    pub3.AddTD(dtEmp.Rows[i]["邮箱"].ToString());
                    pub3.AddTD(dtEmp.Rows[i]["直属领导"].ToString());
                }

                pub3.AddTREnd();
            }

            pub3.AddTableEnd();
            #endregion
        }