Esempio n. 1
0
        private void cmdApply_Click(object sender, System.EventArgs e)
        {
            CheckBox chkGrant;

            Permission.GrantType grant;
            string      perm, otype = GetObjectType();;
            int         prinID = (int)dgRoles.DataKeys[dgRoles.SelectedIndex], oid = GetID();
            int         courseID = GetCourseID();
            Permissions permda   = new Permissions(Globals.CurrentIdentity);

            foreach (DataGridItem item in dgPerms.Items)
            {
                perm  = (string)dgPerms.DataKeys[item.ItemIndex];
                grant = new Permissions(Globals.CurrentIdentity).CheckPermission(prinID, courseID,
                                                                                 otype, perm, oid);
                chkGrant = (CheckBox)item.FindControl("chkGrant");
                try {
                    if (chkGrant.Checked && grant == Permission.GrantType.DENY)
                    {
                        permda.Assign(prinID, otype, perm, oid, courseID);
                    }
                    else if (!chkGrant.Checked && grant == Permission.GrantType.DIRECT)
                    {
                        permda.Deny(prinID, otype, perm, oid, courseID);
                    }
                } catch (DataAccessException er) {
                    PageError(er.Message);
                    break;
                }
            }
            BindPermissions();
        }