Example #1
0
        private void btnRemoveRole_Click(object sender, EventArgs e)
        {
            // get selected security role id
            int  index          = dgvRoles.CurrentRow.Index;
            Guid securityRoleId = new Guid(dgvRoles.Rows[index].Cells["Id"].Value.ToString());

            // get all user security roles in list data type
            DataTable dtUserSecurityRole = VSP.Business.Entities.UserSecurityRole.GetActive();
            List <VSP.Business.Entities.UserSecurityRole> userSecurityRoles = new List <VSP.Business.Entities.UserSecurityRole>();

            foreach (DataRow row in dtUserSecurityRole.Rows)
            {
                Guid userSecurityRoleId = new Guid(row[0].ToString());
                var  userSecurityRole   = new VSP.Business.Entities.UserSecurityRole(userSecurityRoleId);
                userSecurityRoles.Add(userSecurityRole);
            }

            // delete associated user security roles w/ selected security role
            var userSecurityRolesMatch = userSecurityRoles.FindAll(x => x.UserId == CurrentUser.UserId && x.SecurityRoleId == securityRoleId);

            foreach (VSP.Business.Entities.UserSecurityRole userSecurityRole in userSecurityRolesMatch)
            {
                userSecurityRole.DeleteRecordFromDatabase();
            }

            LoadDgvRoles();
        }
Example #2
0
        private void frmSelectRecord_RecordSelected(object sender, EventArgs e)
        {
            Guid securityRoleId = (Guid)sender;

            VSP.Business.Entities.UserSecurityRole userSecurityRole = new VSP.Business.Entities.UserSecurityRole();
            userSecurityRole.SecurityRoleId = securityRoleId;
            userSecurityRole.UserId         = CurrentUser.UserId;
            userSecurityRole.SaveRecordToDatabase(frmMain_Parent.CurrentUser.UserId);

            LoadDgvRoles();
        }