Example #1
0
 public ArrayList GetRoles()
 {
     ArrayList resultado = new ArrayList();
     this.cmd.CommandText = "SELECT ID_ROLE, NAME, DESCRIPTION FROM ROLES";
     using (SqlDataReader reader = this.cmd.ExecuteReader()) {
         while (reader.Read()) {
             Int16 id_role = -1;
             string Name = "";
             string Description = "";
             if (!reader.IsDBNull(0)) {
                 id_role = reader.GetInt16(0);
             }
             if (!reader.IsDBNull(1)) {
                 Name = reader.GetString(1);
             }
             if (!reader.IsDBNull(2)) {
                 Description = reader.GetString(2);
             }
             RoleVO roleVO = new RoleVO();
             roleVO.ID = id_role;
             roleVO.Name = Name;
             roleVO.Description = Description;
             resultado.Add(roleVO);
         }
     }
     return resultado;
 }
Example #2
0
 public ArrayList GetRoles(string userName)
 {
     ArrayList resultado = new ArrayList();
     int id_user = -1;
     this.cmd.CommandText = "SELECT ID_USER FROM USERS WHERE USER_NAME = " + userName;
     using (SqlDataReader reader = this.cmd.ExecuteReader()) {
         if (reader.Read()) {
             if (!reader.IsDBNull(0)) {
                 id_user = reader.GetInt32(0);
             }
         }
     }
     if (id_user != -1) {
         this.cmd.CommandText = "SELECT ROLES.ID_ROLE, NAME, DESCRIPTION FROM ROLES INNER JOIN USERS_ROLES ON USERS_ROLES.ID_USER = "******" AND USERS_ROLES.ID_ROLE = ROLES.ID_ROLE";
         using (SqlDataReader reader = this.cmd.ExecuteReader()) {
             if (reader.Read()) {
                 Int16 id_role = -1;
                 string Name = "";
                 string Description = "";
                 if (!reader.IsDBNull(0)) {
                     id_role = reader.GetInt16(0);
                 }
                 if (!reader.IsDBNull(1)) {
                     Name = reader.GetString(1);
                 }
                 if (!reader.IsDBNull(2)) {
                     Description = reader.GetString(2);
                 }
                 RoleVO roleVO = new RoleVO();
                 roleVO.ID = id_role;
                 roleVO.Name = Name;
                 roleVO.Description = Description;
                 resultado.Add(roleVO);
             }
         }
     }
     return resultado;
 }