private void btnAceptar_Click(object sender, EventArgs e)
 {
     ControlsToRoles c = null;
     foreach (gestionalumnos.Entities.Controls controlID in lstControles.SelectedItems)
     {
         foreach (Roles item in lstRoles.SelectedItems)
         {
             c = new ControlsToRoles();
             c.FKRole = item.RoleID;
             c.FKPage = controlID.Page;
             c.FKControlID = controlID.ControlID;
             c.Invisible = chkInvisible.Checked ? 1 : 0;
             c.Disabled = chkDisabled.Checked ? 1 : 0;
             int res = oGCR.Insertar(c);
             if (res < 1 || res > 2)
             {
                 DisplayError(controlID.ControlID, item.RoleID, "Permisos insertados = " + res.ToString());
             }
         }
     }
     LoadArbolPermisos();
 }
        private void HabilitarControles(int idRol, List<Controls> lstCtrl)
        {
            GestorControlsToRole oGCR = new GestorControlsToRole();
            List<ControlsToRoles> list = new List<ControlsToRoles>();
            List<ControlsToRoles> listaux = new List<ControlsToRoles>();
            ControlsToRoles c = new ControlsToRoles();
            c.FKRole = idRol;
            ControlsToRoles aux = new ControlsToRoles();

            for (int i = 0; i < lstCtrl.Count; i++)
            {
                c.FKControlID = lstCtrl[i].ControlID;
                c.FKPage = this.Name;
                listaux = oGCR.Habilitar(c).ToList();
                foreach (ControlsToRoles item in listaux)
                {
                    list.Add(item);
                }
            }
            //list=oGCR.Habilitar(

            foreach (Control controlChotex in this.Controls)
            {
                foreach (ControlsToRoles item in list)
                {
                    if (item.FKControlID == controlChotex.Name)
                    {
                        if (item.Invisible == 1)
                        {
                            controlChotex.Visible = false;
                        }
                        else
                        {
                            controlChotex.Visible = true;
                        }
                        if (item.Disabled==1)
                        {
                            controlChotex.Enabled = false;
                        }
                        else
                        {
                            controlChotex.Enabled = true;
                        }
                    }
                }
            }
        }