示例#1
0
        public List <RRolBE> ObtenerRoles()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["conRomSql"].ConnectionString;

            List <RRolBE> oLista = new List <RRolBE>();
            RRolBE        oRol;

            SqlConnection con = new SqlConnection();

            try
            {
                con.ConnectionString = connectionString;
                con.Open();
                string     nombreProcedure = "ObtenerRol";
                SqlCommand cmd             = new SqlCommand(nombreProcedure, con);
                cmd.CommandType = CommandType.StoredProcedure;

                using (IDataReader dataReader = cmd.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        oRol             = new RRolBE();
                        oRol.Id          = new Guid(dataReader["IdRol"].ToString());
                        oRol.Descripcion = dataReader["Rol"].ToString();

                        oLista.Add(oRol);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
            return(oLista);
        }
示例#2
0
        public RRolBE ObtenerRolPorId(string IdRol)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["conRomSql"].ConnectionString;

            RRolBE oRol = null;

            SqlConnection con = new SqlConnection();

            try
            {
                con.ConnectionString = connectionString;
                con.Open();
                string     nombreProcedure = "ObtenerRolPorId";
                SqlCommand cmd             = new SqlCommand(nombreProcedure, con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter par1 = new SqlParameter("@Id", IdRol);
                cmd.Parameters.Add(par1);

                using (IDataReader dataReader = cmd.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        oRol             = new RRolBE();
                        oRol.Id          = new Guid(dataReader["IdRol"].ToString());
                        oRol.Descripcion = dataReader["Rol"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
            return(oRol);
        }