Example #1
0
        public frmAMRol(Rol r)
        {
            InitializeComponent();

            rolActual = new Rol();
            modoAlta = true;
            if (r != null)
            {
                rolActual = r;
                modoAlta = false;
            }
        }
Example #2
0
 public List<Rol> Listar()
 {
     List<Rol> result = new List<Rol>();
     DataSet set = new ConexionRoles().Listar();
     foreach (DataRow actual in set.Tables[0].Rows)
     {
         Rol nuevo = new Rol();
         nuevo.Id = new Guid(actual.ItemArray[0].ToString());
         nuevo.Name = actual.ItemArray[1].ToString();
         result.Add(nuevo);
     }
     return result;
 }
Example #3
0
        public void agregarRolConFuncionalidades(Rol rolActual, List<Funcionalidad> funcionalidades)
        {
            AgregarRol(rolActual);
            rolActual.idRol = obtenerRolPorNombre(rolActual.nombreRol).idRol;

            string[] parametros = { "@idRol" };
            string[] parametros2 = { "@idRol", "@idFunc" };
            DatosSistema datos = new DatosSistema();
            datos.Ejecutar("[INFONIONIOS].[spEliminarFuncionalidadesDeRol]", parametros, rolActual.idRol);
            foreach (Funcionalidad f in funcionalidades)
            {
                datos.Ejecutar("[INFONIONIOS].[spAgregarFuncPorRol]", parametros2, rolActual.idRol, f.idFuncionalidad);
            }
        }
Example #4
0
        //Metodo para agregar una nueva Rol
        public int AgregarRol(Rol rol)
        {
            DatosSistema datos = new DatosSistema();
               //idRol = 0;
            string[] parametros = {"@operacion",
                                      "@idRol",
                                      "@nombreRol",
                                        "@habilitado"};

            return datos.Ejecutar("[INFONIONIOS].spRolIA",
                parametros, "I",
                System.DBNull.Value,
                rol.nombreRol,
                rol.habilitadoRol);
        }
Example #5
0
        //Metodo para actualizar una rol
        public int ActualizarRol(Rol rol)
        {
            DatosSistema datos = new DatosSistema();

            string[] parametros = {"@operacion",
                                      "@idRol",
                                      "@nombreRol",
                                      "@habilitado"};

            return datos.Ejecutar("[INFONIONIOS].spRolIA",
                parametros, "A",
                rol.idRol,
                rol.nombreRol,
                rol.habilitadoRol);
        }
Example #6
0
 public Login(Negocio.Rol r)
 {
     InitializeComponent();
     rolActual = r;
 }
Example #7
0
        private void dgvRoles_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
                return;

            Rol r = new Rol().obtenerRolPorId((int)dgvRoles.Rows[e.RowIndex].Cells[0].Value);
            //RutaAerea ruta = new RutaAerea().obtenerRutaAereaPorId((int)dgvRutaAerea.Rows[e.RowIndex].Cells[0].Value);

            if (r != null)
            {
                if (e.ColumnIndex == 3)
                {
                    var frm = new frmAMRol(r);
                    frm.ShowDialog();
                    limpiarDGV();
                    limpiarCampos();
                }
                else if (e.ColumnIndex == 4)
                {
                    if (!r.habilitadoRol) { MessageBox.Show("El rol ya se encuentra inhabilitado.", "Error"); return; }

                    var respuesta = MessageBox.Show(string.Format("¿Está seguro que desea inhabilitar el rol {0}?",r.nombreRol), "Atención", MessageBoxButtons.YesNo);
                    if (respuesta == DialogResult.Yes)
                    {
                        r.habilitadoRol = false;
                        r.ActualizarRol(r);
                        r.EliminarRolDeUsuarios(r);

                        //INHABILITAR USUARIOS DE ESE ROL

                        limpiarDGV();
                        limpiarCampos();
                    }
                }
            }
        }
Example #8
0
 public void EliminarRolDeUsuarios(Rol r)
 {
     string[] parametros = { "@idRol" };
     DatosSistema datos = new DatosSistema();
     datos.Ejecutar("[INFONIONIOS].[spEliminarRolDeUsuarios]", parametros, r.idRol);
 }
Example #9
0
        private Rol obtenerRolPorNombre(string nombre)
        {
            Rol rol = new Rol();
            string[] parametros = { "@nombre" };
            DatosSistema datos = new DatosSistema();
            DataTable dt = datos.getDatosTabla("[INFONIONIOS].[spObtenerRolPorNombre]", parametros, nombre);
            if (dt.Rows.Count != 0)
            {
                rol.idRol = Int32.Parse(dt.Rows[0]["ROL_ID"].ToString());
                rol.nombreRol = dt.Rows[0]["ROL_NOMBRE"].ToString();
                rol.habilitadoRol = Boolean.Parse(dt.Rows[0]["ROL_HABILITADO"].ToString());
            }
            else
            {
                return null;
            }

            return rol;
        }
Example #10
0
 public Rol obtenerRol(Rol r)
 {
     DatosSistema datos = new DatosSistema();
     Rol rol = new Rol();
     var dt = new DataTable();
     string[] parametros = {"@operacion"};
     dt = datos.getDatosTabla("[INFONIONIOS].spsIDRol", parametros, "s");
     foreach (DataRow fila in dt.Rows)
     {
         rol.idRol = Convert.ToInt32(fila["ROL_ID"]);
         rol.nombreRol = fila["ROL_NOMBRE"].ToString();
         rol.habilitadoRol = Convert.ToBoolean(fila["ROL_HABILITADO"]);
     }
     return rol;
 }
Example #11
0
 public void inhabilitarRolesUsuario(Rol rolActual)
 {
     string[] parametros = { "@idRol" };
     DatosSistema datos = new DatosSistema();
     datos.Ejecutar("[INFONIONIOS].[spInhabilitarRolesUsuario]", parametros, rolActual.idRol);
 }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Page.Form.Attributes.Add("enctype", "multipart/form-data");

                if (!GenericPrincipal.Current.IsInRole("Administrador"))
                {
                    Response.Redirect("~\\wfrmInicio.aspx");
                }

                Rol iRol = new Rol();
                List<Rol> roles = iRol.Listar();
                foreach (Rol actual in roles)
                {
                    ddlBusquedaRoles.Items.Add(new ListItem(actual.Name, actual.Id.ToString()));
                    ddlRol.Items.Add(new ListItem(actual.Name, actual.Id.ToString()));
                }

                List<Pais> paises = Pais.Listar();
                foreach (Pais actual in paises)
                {
                    ddlPais.Items.Add(new ListItem(actual.Nombre, actual.Id.ToString()));
                }

                List<EstadoCivil> estadosCiviles = EstadoCivil.Listar();
                foreach (EstadoCivil actual in estadosCiviles)
                {
                    ddlEstadoCivil.Items.Add(new ListItem(actual.Descripcion, actual.ID.ToString()));
                }
            }
        }