private void loadGroups()
 {
     try
     {
         //groupName.Visible = true;
         //cblGroupName.Visible = true;
         btnSaveChanges.Visible   = true;
         btnCancelChanges.Visible = true;
         //Utils.GetLookUpData<CheckBoxList>(ref cblGroupName, LookUps.Groups, true);
         int       roleid    = Conversion.ParseInt(ddlRole.SelectedValue);
         int       subroleid = Conversion.ParseInt(ddlSubRole.SelectedValue);
         DataTable dt        = RoleManagement.GetRoleSubroleNGroupByIds(roleid, subroleid);
         if (dt != null && dt.Rows.Count > 0)
         {
             foreach (ListItem i in cblGroupName.Items)
             {
                 for (int j = 0; j < dt.Rows.Count; j++)
                 {
                     string groupid = dt.Rows[j]["intGroupID"].ToString();
                     if (i.Value == groupid)
                     {
                         i.Selected = true;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         new SqlLog().InsertSqlLog(0, "GroupPermission.aspx.loadGroups", ex);
     }
 }
    private void loadsecuritycode()
    {
        // updating token
        try
        {
            int         roleId      = Convert.ToInt32(ddlRole.SelectedValue.ToString());
            AccessToken token       = new AccessToken();
            string      accessToken = AccessToken.ReturnEmptyToken();
            //accessToken = ReadPermissions(accessToken, token);

            // loading existing token
            int        roleid    = Conversion.ParseInt(ddlRole.SelectedValue);
            int        subroleid = Conversion.ParseInt(ddlSubRole.SelectedValue);
            DataTable  dt        = RoleManagement.GetRoleSubroleNGroupByIds(roleid, subroleid);
            List <int> groupids  = new List <int>();
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    string groupid = dt.Rows[j]["intGroupID"].ToString();
                    groupids.Add(Convert.ToInt32(groupid));
                }
                System.Data.DataTable resourceTopics = GroupPages.GetAllResources();
                for (int i = 0; i < resourceTopics.Rows.Count; i++)
                {
                    DataRow row        = resourceTopics.Rows[i];
                    int     resourceid = Convert.ToInt32(row["intResourceId"].ToString());
                    //foreach (ResourceType item in Enum.GetValues(typeof(ResourceType)))
                    //{
                    List <string> securityTokens = new List <string>();
                    foreach (int gid in groupids)
                    {
                        securityTokens.Add(RoleManagement.GetSecurityToken(Convert.ToInt32(gid)));
                    }
                    canView = canAdd = canUpdate = canDelete = false;
                    foreach (string st in securityTokens)
                    {
                        PermissionManagement.GetPermissionOnlyFalsed(resourceid, ref canView, ref canAdd, ref canUpdate, ref canDelete, st);
                    }
                    accessToken = ReadDetailPermissions(resourceid, canView, canAdd, canUpdate, canDelete, accessToken, token);
                    //}
                }
            }
            // generating new token
            RoleManagement.UpdateSecurityTokenbyRoleId(subroleid, accessToken);
        }
        catch (Exception ex)
        {
            new SqlLog().InsertSqlLog(0, "GroupPermission.aspx.loadsecuritycode", ex);
        }
    }