Beispiel #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            nbPeople.Visible = false;

            if (!Page.IsPostBack)
            {
                int?setId = PageParameter("Set").AsIntegerOrNull();
                if (setId.HasValue)
                {
                    var selectedPersonIds = new EntitySetItemService(new RockContext())
                                            .GetByEntitySetId(setId.Value)
                                            .Select(i => i.EntityId)
                                            .Distinct()
                                            .ToList();

                    // Get the people selected
                    var people = new PersonService(new RockContext()).Queryable("CreatedByPersonAlias.Person,Users", true)
                                 .Where(p => selectedPersonIds.Contains(p.Id))
                                 .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData(people, headingKeys);
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsIntegerOrNull();

                // Save the primary header radio button's selection
                foreach (var col in gValues.Columns.OfType <PersonMergeField>())
                {
                    col.OnDelete += personCol_OnDelete;
                    if (primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex)
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }
        /// <summary>
        /// Handles the OnDelete event of the personCol control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void personCol_OnDelete(object sender, EventArgs e)
        {
            var personMergeField = sender as PersonMergeField;

            if (personMergeField != null)
            {
                var selectedPersonIds = MergeData.People
                                        .Where(p => p.Id != personMergeField.PersonId)
                                        .Select(p => p.Id).ToList();

                // Get the people selected
                var people = new PersonService(new RockContext()).Queryable("CreatedByPersonAlias.Person,Users")
                             .Where(p => selectedPersonIds.Contains(p.Id))
                             .ToList();

                // Rebuild mergdata, columns, and grid
                MergeData = new MergeData(people, headingKeys);
                BuildColumns();
                BindGrid();
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            nbPeople.Visible = false;

            if (!Page.IsPostBack)
            {
                string peopleIds = PageParameter("People");
                if (!string.IsNullOrWhiteSpace(peopleIds))
                {
                    var selectedPersonIds = peopleIds.SplitDelimitedValues().Select(p => p.AsInteger().Value).ToList();

                    // Get the people selected
                    var people = new PersonService(new RockContext()).Queryable("CreatedByPersonAlias.Person,Users")
                                 .Where(p => selectedPersonIds.Contains(p.Id))
                                 .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData(people, headingKeys);
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsInteger(false);

                // Save the primary header radio button's selection
                foreach (var col in gValues.Columns.OfType <PersonMergeField>())
                {
                    col.OnDelete += personCol_OnDelete;
                    if (primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex)
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }
        /// <summary>
        /// Handles the SelectPerson event of the ppAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ppAdd_SelectPerson(object sender, EventArgs e)
        {
            int?personId = ppAdd.PersonId;

            if (personId.HasValue && (MergeData == null || !MergeData.People.Any(p => p.Id == personId.Value)))
            {
                var selectedPersonIds = MergeData != null?MergeData.People.Select(p => p.Id).ToList() : new List <int>();

                selectedPersonIds.Add(personId.Value);

                // Get the people selected
                var people = new PersonService(new RockContext()).Queryable("CreatedByPersonAlias.Person,Users")
                             .Where(p => selectedPersonIds.Contains(p.Id))
                             .ToList();

                // Rebuild mergdata, columns, and grid
                MergeData = new MergeData(people, headingKeys);
                BuildColumns();
                BindGrid();
            }

            ppAdd.SetValue(null);
        }
Beispiel #5
0
        /// <summary>
        /// Loads the edit details.
        /// </summary>
        private void LoadEditDetails()
        {
            if ( !Page.IsPostBack )
            {
                int? setId = PageParameter( "Set" ).AsIntegerOrNull();
                if ( setId.HasValue )
                {
                    var selectedPersonIds = new EntitySetItemService( new RockContext() )
                        .GetByEntitySetId( setId.Value )
                        .Select( i => i.EntityId )
                        .Distinct()
                        .ToList();

                    if ( selectedPersonIds.Count == 0 )
                    {
                        ScriptManager.RegisterStartupScript( this, this.GetType(), "goBack", "history.go(-1);", true );
                    }

                    // Get the people selected
                    var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users", true )
                        .Where( p => selectedPersonIds.Contains( p.Id ) )
                        .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData( people, headingKeys, CurrentPerson );
                    MergeData.EntitySetId = setId.Value;
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsIntegerOrNull();

                // Save the primary header radio button's selection
                foreach ( var col in gValues.Columns.OfType<PersonMergeField>() )
                {
                    col.OnDelete += personCol_OnDelete;
                    if ( primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex )
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// Handles the SelectPerson event of the ppAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void ppAdd_SelectPerson( object sender, EventArgs e )
        {
            int? personId = ppAdd.PersonId;
            if ( personId.HasValue && ( MergeData == null || !MergeData.People.Any( p => p.Id == personId.Value ) ) )
            {
                var selectedPersonIds = MergeData != null ? MergeData.People.Select( p => p.Id ).ToList() : new List<int>();
                selectedPersonIds.Add( personId.Value );

                // Get the people selected
                var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users" )
                    .Where( p => selectedPersonIds.Contains( p.Id ) )
                    .ToList();

                // Rebuild mergdata, columns, and grid
                MergeData = new MergeData( people, headingKeys, CurrentPerson );
                BuildColumns();
                BindGrid();
            }

            ppAdd.SetValue( null );
        }
Beispiel #7
0
        /// <summary>
        /// Handles the OnDelete event of the personCol control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void personCol_OnDelete( object sender, EventArgs e )
        {
            var personMergeField = sender as PersonMergeField;
            if ( personMergeField != null )
            {
                var selectedPersonIds = MergeData.People
                    .Where( p => p.Id != personMergeField.PersonId )
                    .Select( p => p.Id ).ToList();

                // Get the people selected
                var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users" )
                    .Where( p => selectedPersonIds.Contains( p.Id ) )
                    .ToList();

                // Rebuild mergdata, columns, and grid
                MergeData = new MergeData( people, headingKeys, CurrentPerson );
                BuildColumns();
                BindGrid();
            }
        }
Beispiel #8
0
 /// <summary>
 /// Restores the view-state information from a previous user control request that was saved by the <see cref="M:System.Web.UI.UserControl.SaveViewState" /> method.
 /// </summary>
 /// <param name="savedState">An <see cref="T:System.Object" /> that represents the user control state to be restored.</param>
 protected override void LoadViewState( object savedState )
 {
     base.LoadViewState( savedState );
     MergeData = ViewState["MergeData"] as MergeData;
 }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            nbPeople.Visible = false;

            if ( !Page.IsPostBack )
            {
                string peopleIds = PageParameter( "People" );
                if ( !string.IsNullOrWhiteSpace( peopleIds ) )
                {
                    var selectedPersonIds = peopleIds.SplitDelimitedValues().Select( p => p.AsInteger().Value ).ToList();

                    // Get the people selected
                    var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users" )
                        .Where( p => selectedPersonIds.Contains( p.Id ) )
                        .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData( people, headingKeys );
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsInteger( false );

                // Save the primary header radio button's selection
                foreach ( var col in gValues.Columns.OfType<PersonMergeField>() )
                {
                    col.OnDelete += personCol_OnDelete;
                    if (primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex)
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            nbPeople.Visible = false;

            if ( !Page.IsPostBack )
            {
                int? setId = PageParameter( "Set" ).AsIntegerOrNull();
                if (setId.HasValue)
                {
                    var selectedPersonIds = new EntitySetItemService( new RockContext() )
                        .GetByEntitySetId( setId.Value )
                        .Select( i => i.EntityId )
                        .Distinct()
                        .ToList();

                    // Get the people selected
                    var people = new PersonService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person,Users", true )
                        .Where( p => selectedPersonIds.Contains( p.Id ) )
                        .ToList();

                    // Create the data structure used to build grid
                    MergeData = new MergeData( people, headingKeys );
                    BuildColumns();
                    BindGrid();
                }
            }
            else
            {
                var primaryColIndex = hfSelectedColumn.Value.AsIntegerOrNull();

                // Save the primary header radio button's selection
                foreach ( var col in gValues.Columns.OfType<PersonMergeField>() )
                {
                    col.OnDelete += personCol_OnDelete;
                    if (primaryColIndex.HasValue && primaryColIndex.Value == col.ColumnIndex)
                    {
                        MergeData.PrimaryPersonId = col.PersonId;
                    }
                }
            }
        }
 /// <summary>
 /// Restores the view-state information from a previous user control request that was saved by the <see cref="M:System.Web.UI.UserControl.SaveViewState" /> method.
 /// </summary>
 /// <param name="savedState">An <see cref="T:System.Object" /> that represents the user control state to be restored.</param>
 protected override void LoadViewState(object savedState)
 {
     base.LoadViewState(savedState);
     MergeData = ViewState["MergeData"] as MergeData;
 }