Example #1
0
        /// <summary>
        /// 提交选择的部门。
        /// </summary>
        /// <returns></returns>
        public string ChangeDept_Submit()
        {
            string deptNo = this.GetRequestVal("DeptNo");

            BP.GPM.Dept dept = new GPM.Dept(deptNo);

            BP.Web.WebUser.FK_Dept           = dept.No;
            BP.Web.WebUser.FK_DeptName       = dept.Name;
            BP.Web.WebUser.FK_DeptNameOfFull = dept.NameOfPath;

            ////重新设置cookies.
            //string strs = "";
            //strs += "@No=" + WebUser.No;
            //strs += "@Name=" + WebUser.Name;
            //strs += "@FK_Dept=" + WebUser.FK_Dept;
            //strs += "@FK_DeptName=" + WebUser.FK_DeptName;
            //strs += "@FK_DeptNameOfFull=" + WebUser.FK_DeptNameOfFull;
            //BP.Web.WebUser.SetValToCookie(strs);

            BP.WF.Port.WFEmp emp = new Port.WFEmp(WebUser.No);
            emp.StartFlows = "";
            emp.Update();

            try
            {
                string sql = "UPDATE Port_Emp Set fk_dept='" + deptNo + "' WHERE no='" + WebUser.No + "'";
                DBAccess.RunSQL(sql);
                BP.WF.Dev2Interface.Port_Login(WebUser.No);
            }
            catch (Exception ex)
            {
            }

            return("@执行成功,已经切换到{" + BP.Web.WebUser.FK_DeptName + "}部门上。");
        }
Example #2
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <returns>返回执行结果</returns>
        public override object Do()
        {
            if (DBAccess.IsExitsTableCol("Port_Dept", "TreeNo") == false)
            {
                return("err@ Port_Dept 没有找到 TreeNo 的列.");
            }

            BP.GPM.Dept dept = new GPM.Dept();
            int         i    = dept.Retrieve(DeptAttr.ParentNo, "0");

            if (i == 0)
            {
                return("err@没有找到ParentNo=0的根节点.");
            }

            //更新跟节点的TreeNo.
            string sql = "UPDATE Port_Dept SET TreeNo='01' WHERE No='" + dept.No + "'";

            DBAccess.RunSQL(sql);

            BP.Port.Depts depts = new Depts();
            depts.Retrieve(BP.Port.DeptAttr.ParentNo, dept.No);

            int idx = 0;

            foreach (BP.Port.Dept item in depts)
            {
                idx++;

                string subNo = idx.ToString().PadLeft(2, '0');
                sql = "UPDATE Port_Dept SET TreeNo='01" + subNo + "' WHERE No='" + item.No + "'";
                DBAccess.RunSQL(sql);

                sql = "UPDATE Port_DeptEmp SET DeptTreeNo='01" + subNo + "' WHERE FK_Dept='" + item.No + "'";
                DBAccess.RunSQL(sql);
                sql = "UPDATE Port_DeptEmpStation SET DeptTreeNo='01" + subNo + "' WHERE FK_Dept='" + item.No + "'";
                DBAccess.RunSQL(sql);

                SetDeptTreeNo(item, "01" + subNo);
            }

            return("执行成功.");
        }