private void ShowViewForPerson( Guid targetPersonGuid ) { // check for a specific person in the query string Person targetPerson = null; Location targetPersonLocation = null; targetPerson = new PersonService( new RockContext() ).Queryable().Where( p => p.Guid == targetPersonGuid ).FirstOrDefault(); targetPersonLocation = targetPerson.GetHomeLocation(); if ( targetPerson != null ) { lTitle.Text = String.Format( "<h4 class='margin-t-none'>Groups for {0}</h4>", targetPerson.FullName ); acAddress.SetValues( targetPersonLocation ); acAddress.Visible = false; phFilterControls.Visible = false; btnSearch.Visible = false; btnClear.Visible = false; if ( targetPersonLocation != null && targetPersonLocation.GeoPoint != null ) { lTitle.Text += String.Format( "<p>Search based on: {0}</p>", targetPersonLocation.ToString() ); ShowResults(); } else if ( targetPersonLocation != null ) { lTitle.Text += String.Format( "<p>The position of the address on file ({0}) could not be determined.</p>", targetPersonLocation.ToString() ); } else { lTitle.Text += String.Format( "<p>The person does not have an address on file.</p>" ); } } }
/// <summary> /// Handles the SelectPerson event of the ppPerson 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 ppPerson_SelectPerson( object sender, EventArgs e ) { if ( ppPerson.PersonId != null ) { Person person = new PersonService( new RockContext() ).Get( ppPerson.PersonId.Value ); if ( person != null ) { // Make sure that the FirstName box gets either FirstName or NickName of person. if (!string.IsNullOrWhiteSpace(person.FirstName)) { dtbFirstName.Text = person.FirstName; } else if ( !string.IsNullOrWhiteSpace( person.NickName ) ) { dtbFirstName.Text = person.NickName; } //If both FirstName and NickName are blank, let them edit it manually dtbFirstName.Enabled = string.IsNullOrWhiteSpace(dtbFirstName.Text); dtbLastName.Text = person.LastName; //If both LastName is blank, let them edit it manually dtbLastName.Enabled = string.IsNullOrWhiteSpace( dtbLastName.Text ); ; ddlConnectionStatus.SetValue( person.ConnectionStatusValueId ); ddlConnectionStatus.Enabled = false; var homePhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid() ); if ( homePhoneType != null ) { var homePhone = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == homePhoneType.Id ); if ( homePhone != null ) { pnbHomePhone.Text = homePhone.NumberFormatted; pnbHomePhone.Enabled = false; } } var mobilePhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid() ); if ( mobilePhoneType != null ) { var mobileNumber = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == mobilePhoneType.Id ); if ( mobileNumber != null ) { pnbCellPhone.Text = mobileNumber.NumberFormatted; pnbCellPhone.Enabled = false; } } var workPhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK.AsGuid() ); if ( workPhoneType != null ) { var workPhone = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == workPhoneType.Id ); if ( workPhone != null ) { pnbWorkPhone.Text = workPhone.NumberFormatted; pnbWorkPhone.Enabled = false; } } ebEmail.Text = person.Email; ebEmail.Enabled = false; lapAddress.SetValue( person.GetHomeLocation() ); lapAddress.Enabled = false; // set the campus but not on page load (e will be null) unless from the person profile page (in which case BenevolenceRequestId in the query string will be 0) int? requestId = Request["BenevolenceRequestId"].AsIntegerOrNull(); if ( !cpCampus.SelectedCampusId.HasValue && ( e != null || (requestId.HasValue && requestId == 0 ) ) ) { var personCampus = person.GetCampus(); cpCampus.SelectedCampusId = personCampus != null ? personCampus.Id : (int?)null; } } } else { dtbFirstName.Enabled = true; dtbLastName.Enabled = true; ddlConnectionStatus.Enabled = true; pnbHomePhone.Enabled = true; pnbCellPhone.Enabled = true; pnbWorkPhone.Enabled = true; ebEmail.Enabled = true; lapAddress.Enabled = true; } }
/// <summary> /// Handles the SelectPerson event of the ppPerson 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 ppPerson_SelectPerson( object sender, EventArgs e ) { if ( ppPerson.PersonId != null ) { Person person = new PersonService( new RockContext() ).Get( ppPerson.PersonId.Value ); if ( person != null ) { dtbFirstName.Text = person.FirstName; dtbFirstName.Enabled = false; dtbLastName.Text = person.LastName; dtbLastName.Enabled = false; ddlConnectionStatus.SelectedValue = person.ConnectionStatusValueId.ToString(); ddlConnectionStatus.Enabled = false; var homePhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid() ); if ( homePhoneType != null ) { var homePhone = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == homePhoneType.Id ); if ( homePhone != null ) { pnbHomePhone.Text = homePhone.NumberFormatted; pnbHomePhone.Enabled = false; } } var mobilePhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid() ); if ( mobilePhoneType != null ) { var mobileNumber = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == mobilePhoneType.Id ); if ( mobileNumber != null ) { pnbCellPhone.Text = mobileNumber.NumberFormatted; pnbCellPhone.Enabled = false; } } var workPhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK.AsGuid() ); if ( workPhoneType != null ) { var workPhone = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == workPhoneType.Id ); if ( workPhone != null ) { pnbWorkPhone.Text = workPhone.NumberFormatted; pnbWorkPhone.Enabled = false; } } ebEmail.Text = person.Email; ebEmail.Enabled = false; lapAddress.SetValue( person.GetHomeLocation() ); lapAddress.Enabled = false; } } else { dtbFirstName.Enabled = true; dtbLastName.Enabled = true; ddlConnectionStatus.Enabled = true; pnbHomePhone.Enabled = true; pnbCellPhone.Enabled = true; pnbWorkPhone.Enabled = true; ebEmail.Enabled = true; lapAddress.Enabled = true; } }
/// <summary> /// Handles the SelectPerson event of the ppPerson 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 ppPerson_SelectPerson( object sender, EventArgs e ) { if ( ppPerson.PersonId != null ) { Person person = new PersonService( new RockContext() ).Get( ppPerson.PersonId.Value ); if ( person != null ) { // Make sure that the FirstName box gets either FirstName or NickName of person. if (!string.IsNullOrWhiteSpace(person.FirstName)) { dtbFirstName.Text = person.FirstName; } else if ( !string.IsNullOrWhiteSpace( person.NickName ) ) { dtbFirstName.Text = person.NickName; } //If both FirstName and NickName are blank, let them edit it manually dtbFirstName.Enabled = string.IsNullOrWhiteSpace(dtbFirstName.Text); dtbLastName.Text = person.LastName; //If both LastName is blank, let them edit it manually dtbLastName.Enabled = string.IsNullOrWhiteSpace( dtbLastName.Text ); ; ddlConnectionStatus.SetValue( person.ConnectionStatusValueId ); ddlConnectionStatus.Enabled = false; var homePhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_HOME.AsGuid() ); if ( homePhoneType != null ) { var homePhone = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == homePhoneType.Id ); if ( homePhone != null ) { pnbHomePhone.Text = homePhone.NumberFormatted; pnbHomePhone.Enabled = false; } } var mobilePhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_MOBILE.AsGuid() ); if ( mobilePhoneType != null ) { var mobileNumber = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == mobilePhoneType.Id ); if ( mobileNumber != null ) { pnbCellPhone.Text = mobileNumber.NumberFormatted; pnbCellPhone.Enabled = false; } } var workPhoneType = DefinedValueCache.Read( Rock.SystemGuid.DefinedValue.PERSON_PHONE_TYPE_WORK.AsGuid() ); if ( workPhoneType != null ) { var workPhone = person.PhoneNumbers.FirstOrDefault( n => n.NumberTypeValueId == workPhoneType.Id ); if ( workPhone != null ) { pnbWorkPhone.Text = workPhone.NumberFormatted; pnbWorkPhone.Enabled = false; } } ebEmail.Text = person.Email; ebEmail.Enabled = false; lapAddress.SetValue( person.GetHomeLocation() ); lapAddress.Enabled = false; } } else { dtbFirstName.Enabled = true; dtbLastName.Enabled = true; ddlConnectionStatus.Enabled = true; pnbHomePhone.Enabled = true; pnbCellPhone.Enabled = true; pnbWorkPhone.Enabled = true; ebEmail.Enabled = true; lapAddress.Enabled = true; } }