Ejemplo n.º 1
0
        public static void RegistrarRol(RolEn _rol)
        {
            try
            {
                using (SqlConnection con = DataBaseManager.OpenSqlDatabase(user, pass, servidor, baseDatos))
                {
                    using (SqlCommand command = con.CreateCommand())
                    {
                        command.CommandText = "sp_registrar_usuario";
                        command.CommandType = System.Data.CommandType.StoredProcedure;

                        command.Parameters.AddWithValue("@p_id_rol", _rol.Id_rol);
                        command.Parameters.AddWithValue("@p_desc_rol", _rol.Desc_rol);



                        command.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
 public static void RegistrarRol(RolEn _rol)
 {
     try
     {
         ConsultasAd.RegistrarRol(_rol);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 3
0
        public static List <RolEn> ConsultaRoles()
        {
            List <RolEn> response = new List <RolEn>();

            try
            {
                using (SqlConnection con = DataBaseManager.OpenSqlDatabase(user, pass, servidor, baseDatos))
                {
                    using (SqlCommand command = con.CreateCommand())
                    {
                        command.CommandText = "sp_consulta_roles";
                        command.CommandType = System.Data.CommandType.StoredProcedure;


                        using (SqlDataReader dr = command.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                RolEn tmp = new RolEn();

                                tmp.Desc_rol = dr["id_rol"].ToString() ?? string.Empty;
                                tmp.Id_rol   = dr["DESC_ROL"] != DBNull.Value ? Convert.ToInt32(dr["id_rol"]) : 0;

                                response.Add(tmp);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }