Exemple #1
0
 private void ExtraerPropiedadesRoles()
 {
     Services.OperacionesRoles OR = new Services.OperacionesRoles();
     try
     {
         if (cbRoles.SelectedIndex >= 0)
         {
             List <DataRepository.PropiedadesRol> miLista = new List <DataRepository.PropiedadesRol>();
             idSeguridad = cbRoles.SelectedValue.ToString();
             foreach (var item in OR.PopularLista(int.Parse(idSeguridad)))
             {
                 lstpermisos.Items.Add(item);
             }
             SelecionarCheck();
             miLista             = OR.ConsultarRol(int.Parse(idSeguridad));
             txtNombre.Text      = miLista[0].Rol;
             txtDescripcion.Text = miLista[1].Descripcion;
         }
         else
         {
             txtNombre.Clear();
             txtDescripcion.Clear();
         }
     }
     catch (FormatException ex)
     {
     }
 }
Exemple #2
0
        public void SelecionarCheck()
        {
            Services.OperacionesRoles m = new Services.OperacionesRoles();


            if (lstpermisos.Items.Count > 0)
            {
                foreach (var item2 in m.PopularLista(int.Parse(cbRoles.SelectedValue.ToString())))
                {
                    if (item2.ToString() == chkcargos.Text)
                    {
                        chkcargos.Checked = true;
                    }
                    if (item2.ToString() == chkclientesProveedores.Text)
                    {
                        chkclientesProveedores.Checked = true;
                    }
                    if (item2.ToString() == chkcompras.Text)
                    {
                        chkcompras.Checked = true;
                    }
                    if (item2.ToString() == chkempleados.Text)
                    {
                        chkempleados.Checked = true;
                    }
                    if (item2.ToString() == chkimpuestos.Text)
                    {
                        chkimpuestos.Checked = true;
                    }
                    if (item2.ToString() == chkinventario.Text)
                    {
                        chkinventario.Checked = true;
                    }
                    if (item2.ToString() == chkroles.Text)
                    {
                        chkroles.Checked = true;
                    }
                    if (item2.ToString() == chksucursales.Text)
                    {
                        chksucursales.Checked = true;
                    }
                    if (item2.ToString() == chkusuario.Text)
                    {
                        chkusuario.Checked = true;
                    }
                    if (item2.ToString() == chkventas.Text)
                    {
                        chkventas.Checked = true;
                    }
                    if (item2.ToString() == chkDevoluciones.Text)
                    {
                        chkDevoluciones.Checked = true;
                    }
                    if (item2.ToString() == chklistar.Text)
                    {
                        chklistar.Checked = true;
                    }
                }
            }
        }
Exemple #3
0
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text.Any() && txtDescripcion.Text.Any() && lstpermisos.Items.Count > 0)
            {
                id = int.Parse(idSeguridad);
                DataRepository.PropiedadesRol PR = new DataRepository.PropiedadesRol();
                Services.OperacionesRoles     OR = new Services.OperacionesRoles();
                PR.Rol         = txtNombre.Text.ToString();
                PR.Descripcion = txtDescripcion.Text.ToString();
                OR.ModificarRol(PR, id);
                int id2;
                id2 = OR.ObtenerIdRol(txtNombre.Text.ToString());

                foreach (var item in OR.PopularLista(id2))
                {
                    OR.QuitarPermisos(id2, item.ToString());
                }
                foreach (var item in lstpermisos.Items)
                {
                    OR.AgregarPermisos(id2, item.ToString());
                }
                MessageBox.Show("Se ha actualizado exitosamente el rol.");
                chkselecionar.Text = "Seleccionar todo";
                cbRoles.DataSource = new List <string>();
                txtNombre.Clear();
                txtDescripcion.Clear();
                chkselecionar.Checked = false;
                lstpermisos.Items.Clear();
                selecionarFalse();
                txtNombre.Focus();
            }
            else
            {
                MessageBox.Show("Debe de ingresar datos para poder modificar.");
                txtNombre.Focus();
            }
        }