public static string AddAuthorizationByUserId(string myUserId, string myAuthorizationId, string myAuthorizationValue) { DataTable m_AuthorizationInfo = dal_ICommon.GetAuthorizationByUserId(myUserId, "system_Organization", "LevelCode", "Name"); if (m_AuthorizationInfo != null) { for (int i = 0; i < m_AuthorizationInfo.Rows.Count; i++) { string m_AuthorizationValueTemp = m_AuthorizationInfo.Rows[i]["AuthorizationValue"].ToString(); if (myAuthorizationValue == m_AuthorizationValueTemp) //有相同的数据授权 { return("系统内存在当前数据授权!"); } else if (myAuthorizationValue.Length > m_AuthorizationValueTemp.Length) //当新加入的节点是已经授权的孩子节点 { if (myAuthorizationValue.Substring(0, m_AuthorizationValueTemp.Length) == m_AuthorizationValueTemp) { return("已对当前授权的上级进行过授权!"); } } else if (myAuthorizationValue.Length < m_AuthorizationValueTemp.Length) { if (m_AuthorizationValueTemp.Substring(0, myAuthorizationValue.Length) == myAuthorizationValue) { return("已对当前授权的下级进行过授权,请先删除该授权的下级授权!"); } } } int m_ReturnValue = dal_ICommon.AddAuthorizationByUserId(myUserId, myAuthorizationId, myAuthorizationValue); m_ReturnValue = m_ReturnValue >= 1 ? 1 : m_ReturnValue; return(m_ReturnValue.ToString()); } else { int m_ReturnValue = dal_ICommon.AddAuthorizationByUserId(myUserId, myAuthorizationId, myAuthorizationValue); m_ReturnValue = m_ReturnValue >= 1 ? 1 : m_ReturnValue; return(m_ReturnValue.ToString()); } }