Example #1
0
        /// <summary>
        ///  根据单位代码获取子单位信息
        ///  单位代为为空,查询所有单位
        /// </summary>
        /// <param name="unitID"></param>
        /// <returns></returns>
        public List <B01> GetB01Info(int user_id, string unitID = null)
        {
            List <B01> list = null;

            if (string.IsNullOrEmpty(unitID))
            {
                if (user_id <= 0)
                {
                    //查询所有单位
                    list = Select <int>(o => !string.IsNullOrEmpty(o.UnitID), o => o.DispOrder);
                }
                else
                {
                    T_PermissionsDAL pDal     = new T_PermissionsDAL();
                    List <int>       rolelist = pDal.GetRolesListById(user_id);
                    if (null == rolelist || rolelist.Count <= 0)
                    {
                        rolelist = new List <int>();
                        rolelist.Add(0);
                    }
                    StringBuilder sb = new StringBuilder();

                    /***
                     * 根据当前人员权限获取单位信息:注意包含两部分
                     * 1:用户管理 代管配置
                     * 2:权限管理允许新增单位管理权限,并对其配置
                     * 3:区域权限分配
                     **/
                    sb.Append(string.Format(@"SELECT e1.* FROM
                        (SELECT * FROM 
                        (SELECT DISTINCT c1.UnitID FROM
                        (SELECT per_id FROM dbo.T_RolePermissRelation WHERE role_id IN({0})) a1 INNER JOIN
                        (SELECT per_id FROM dbo.T_Permissions WHERE per_type = 'unitManager') b1 ON a1.per_id = b1.per_id INNER JOIN
                        (SELECT per_id,UnitID FROM dbo.T_B01PermissRelation) c1 ON a1.per_id = c1.per_id) d1 
                        UNION
                        SELECT * FROM 
                        (SELECT DISTINCT bb.UnitID FROM
                        (SELECT per_id FROM dbo.T_RolePermissRelation WHERE role_id IN({0})) aa1 INNER JOIN
                        (SELECT per_id FROM dbo.T_Permissions WHERE per_type = 'areaManager') pp1 ON aa1.per_id = pp1.per_id INNER JOIN
                        (SELECT per_id,area_code FROM dbo.T_AreaPermissRelation) area ON aa1.per_id = area.per_id INNER JOIN
                        (SELECT * FROM dbo.B01) bb ON bb.SSWG=area.area_code) dd1
                        UNION
                        (SELECT DISTINCT unit_id FROM dbo.T_UserUnitRelation WHERE user_id={1})) f1 INNER JOIN
                        (SELECT * FROM dbo.B01) e1 ON f1.UnitID = e1.UnitID ", string.Join(",", rolelist.ToArray()),
                                            user_id));
                    DataTable dt = HCQ2_Common.SQL.SqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text);
                    list = HCQ2_Common.Data.DataTableHelper.DataTableToIList <B01>(dt);
                }
            }
            else
            {
                //子单位UnitID.StartsWith(unitID):like '1001%'
                list = Select <int>(s => s.KeyParent == unitID, s => s.DispOrder);
            }
            return(list);
        }
Example #2
0
        /// <summary>
        ///  获取用户 授权区域
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public List <AreaModel> GetPermissAreaData(int user_id)
        {
            List <int> rolelist = new T_PermissionsDAL().GetRolesListById(user_id);

            if (null == rolelist || rolelist.Count <= 0)
            {
                rolelist = new List <int>();
                rolelist.Add(0);
            }
            sb?.Clear();
            sb.Append(string.Format(@"SELECT code.* FROM 
            (SELECT CodeItemID,CodeItemName,Parent,Child,JPSign FROM dbo.SM_CodeItems WHERE CodeID='AB') code INNER JOIN
            (SELECT DISTINCT area.area_code FROM 
            (SELECT per_id FROM dbo.T_RolePermissRelation WHERE role_id IN({0})) a1 INNER JOIN
            (SELECT per_id FROM dbo.T_Permissions WHERE per_type = 'areaManager') p1 ON a1.per_id = p1.per_id INNER JOIN
            (SELECT per_id,area_code FROM dbo.T_AreaPermissRelation) area ON a1.per_id = area.per_id) tt ON code.CodeItemID=tt.area_code;", string.Join(",", rolelist.ToArray())));
            DataTable dt = SqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text);

            return(HCQ2_Common.Data.DataTableHelper.DataTableToIList <AreaModel>(dt));
        }
Example #3
0
        /// <summary>
        /// 获取指定用户分配 模块集合
        /// </summary>
        /// <param name="user_id"></param>
        /// <returns></returns>
        public List <HCQ2_Model.T_SysModule> GetPermissById(int user_id)
        {
            HCQ2_IDAL.IT_PermissionsDAL Permissions = new T_PermissionsDAL();
            List <int> list = Permissions.GetRolesListById(user_id);

            if (null == list || list.Count <= 0)
            {
                return(null);
            }
            sb?.Clear();
            sb.Append(string.Format(@"select e1.* FROM
            (SELECT distinct c1.sm_id FROM
	        (SELECT per_id FROM dbo.T_RolePermissRelation WHERE role_id IN({0})) a1 INNER JOIN
	        (SELECT per_id FROM dbo.T_Permissions WHERE per_type = 'ModuleManager') b1 ON a1.per_id = b1.per_id  INNER JOIN
	        (SELECT per_id,sm_id FROM dbo.T_ModulePermissRelation) c1 ON b1.per_id = c1.per_id) d1 INNER JOIN
	        (SELECT * FROM dbo.T_SysModule WHERE if_start=1) e1 ON d1.sm_id = e1.sm_id ORDER BY e1.sm_order;"    , string.Join(",", list.ToArray())));
            DataTable dt = HCQ2_Common.SQL.SqlHelper.ExecuteDataTable(sb.ToString(), CommandType.Text);

            if (null == dt || dt.Rows.Count <= 0)
            {
                return(null);
            }
            return(HCQ2_Common.Data.DataTableHelper.DataTableToIList <HCQ2_Model.T_SysModule>(dt));
        }