/// <summary> /// 检查是否有权限 /// </summary> public bool Exists(int role_id, int nav_id, string action_type) { GetModel(role_id); if (is_sys == 1) { return(true); } ax_manager_role_value modelt = manager_role_values.Find(p => p.nav_id == nav_id && p.action_type == action_type); if (modelt != null) { return(true); } return(false); }
/// <summary> /// 得到一个对象实体 /// </summary> public void GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,role_name,role_type,is_sys "); strSql.Append(" FROM [ax_manager_role] "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { this.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["role_name"] != null) { this.role_name = ds.Tables[0].Rows[0]["role_name"].ToString(); } if (ds.Tables[0].Rows[0]["role_type"] != null && ds.Tables[0].Rows[0]["role_type"].ToString() != "") { this.role_type = int.Parse(ds.Tables[0].Rows[0]["role_type"].ToString()); } if (ds.Tables[0].Rows[0]["is_sys"] != null && ds.Tables[0].Rows[0]["is_sys"].ToString() != "") { this.is_sys = int.Parse(ds.Tables[0].Rows[0]["is_sys"].ToString()); } #region 子表信息 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("select id,role_id,nav_id,action_type from ax_manager_role_value "); strSql2.Append(" where role_id=@role_id"); SqlParameter[] parameters2 = { new SqlParameter("@role_id", SqlDbType.Int, 4) }; parameters2[0].Value = id; DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2); if (ds2.Tables[0].Rows.Count > 0) { List <ax_manager_role_value> models = new List <ax_manager_role_value>(); ax_manager_role_value modelt; foreach (DataRow dr in ds2.Tables[0].Rows) { modelt = new ax_manager_role_value(); if (dr["id"].ToString() != "") { modelt.id = int.Parse(dr["id"].ToString()); } if (dr["role_id"].ToString() != "") { modelt.role_id = int.Parse(dr["role_id"].ToString()); } if (dr["nav_id"].ToString() != "") { modelt.nav_id = int.Parse(dr["nav_id"].ToString()); } modelt.action_type = dr["action_type"].ToString(); models.Add(modelt); } manager_role_values = models; } #endregion } }