Example #1
0
        private void tbRoles_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            PermListDisp.Items.Clear();
            // select item
            txtRolName.Text = tbRoles.SelectedRows[0].Cells[1].Value.ToString();
            selectedRol     = int.Parse(tbRoles.SelectedRows[0].Cells[0].Value.ToString());
            rolstatus       = (tbRoles.SelectedRows[0].Cells[2].Value.ToString());
            if (selectedRol == 0)
            {
                Notification.Show("Seleccione un rol primero.", AlertType.warm);
                return;
            }
            // get and add perms to select list
            List <Permisos> savePerms = rc.getPermsByRol(selectedRol);

            foreach (Permisos per in savePerms)
            {
                PermListSelec.Items.Add(this.completeString(per.id_permiso + "") + " : " + per.descripcion);
            }

            // load perms in disp list
            foreach (Permisos allperms in perms.Values)
            {
                int bandera = 1;
                foreach (Permisos savepers in savePerms)
                {
                    if (allperms.id_permiso == savepers.id_permiso)
                    {
                        bandera = 0;
                        break;
                    }
                }
                if (bandera == 1)
                {
                    PermListDisp.Items.Add(completeString(allperms.id_permiso + "") + " : " + allperms.descripcion);
                }
            }

            if (rolstatus == "Activo")
            {
                btnDelete.ButtonText = "Dar de Baja";
            }
            else
            {
                btnDelete.ButtonText = "Dar de Alta";
            }
            // modificate data
            tabRegister.SelectedIndex = 1;
            tabPageRegister.Text      = "Modificar/Eliminar Rol";
            btnUpdate.Show();
            btnDelete.Show();
            btnCancel.Show();
            btnSave.Hide();
        }