Пример #1
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected override void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);

        targetEmailAddress     = MultiStepWizards.AddContact.EmailAddress;
        targetIndividual       = MultiStepWizards.AddContact.Individual;
        targetRelationshipType = MultiStepWizards.AddContact.RelationshipType;
        sendInvitation         = MultiStepWizards.AddContact.SendInvitation;
    }
Пример #2
0
    protected void wizAddContact_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        switch (e.CurrentStepIndex)
        {
        case 0:
            lblAlreadyExists.Visible = false;
            targetEmailAddress       = tbEmailAddress.Text;
            MultiStepWizards.AddContact.EmailAddress = targetEmailAddress;

            string relationshipTypeId = string.IsNullOrWhiteSpace(RelationshipTypeId)
                                                ? ddlRelationshipType.SelectedValue
                                                : RelationshipTypeId;
            targetRelationshipType = LoadObjectFromAPI <msRelationshipType>(relationshipTypeId);
            MultiStepWizards.AddContact.RelationshipType = targetRelationshipType;

            targetIndividual = unbindAndSearch(targetEmailAddress);

            try
            {
                CRMLogic.ErrorOutIfOrganizationContactRestrictionApplies(
                    targetOrganization.ID,
                    targetRelationshipType.ID);
            }
            catch (Exception ex)
            {
                cvContactRestriction.ErrorMessage = ex.Message;
                cvContactRestriction.IsValid      = false;
                e.Cancel = true;
                return;
            }

            if (targetIndividual != null)
            {
                if (activeRelationshipExists(targetOrganization, targetIndividual, targetRelationshipType))
                {
                    lblAlreadyExists.Text =
                        string.Format("Email Address <b>{0}</b> was found related to <b>{1} {2}</b>, who already has an active <b>{3}</b> relationship to <b>{4}</b>.", targetEmailAddress, targetIndividual.FirstName, targetIndividual.LastName, targetRelationshipType.Name, targetOrganization.Name);
                    lblAlreadyExists.Visible = true;

                    e.Cancel = true;
                    return;
                }

                MultiStepWizards.AddContact.Individual = targetIndividual;
                wizAddContact.ActiveStepIndex          = 2;
            }

            break;

        case 1:
            targetIndividual = unbindNewIndividual();
            MultiStepWizards.AddContact.Individual     = targetIndividual;
            MultiStepWizards.AddContact.SendInvitation = chkSendInvitation.Checked;
            break;
        }
    }
Пример #3
0
    /// <summary>
    /// Initializes the target object for the page
    /// </summary>
    /// <remarks>Many pages have "target" objects that the page operates on. For instance, when viewing
    /// an event, the target object is an event. When looking up a directory, that's the target
    /// object. This method is intended to be overriden to initialize the target object for
    /// each page that needs it.</remarks>
    protected override void InitializeTargetObject()
    {
        base.InitializeTargetObject();

        targetRelationship = LoadObjectFromAPI <msRelationship>(ContextID);
        if (targetRelationship == null)
        {
            GoToMissingRecordPage();
            return;
        }

        targetRelationshipType = LoadObjectFromAPI <msRelationshipType>(targetRelationship.Type);
        if (targetRelationshipType == null)
        {
            GoToMissingRecordPage();
            return;
        }

        leftSide  = APIExtensions.LoadObjectFromAPI(targetRelationship.LeftSide);
        rightSide = APIExtensions.LoadObjectFromAPI(targetRelationship.RightSide);
    }
Пример #4
0
    protected bool activeRelationshipExists(msOrganization organization, msIndividual individual, msRelationshipType relationshipType)
    {
        Search sRelationship = new Search("RelationshipsForARecord");

        sRelationship.Context = organization.ID;
        sRelationship.AddOutputColumn("ID");
        sRelationship.AddCriteria(Expr.Equals("Type_ID", relationshipType.ID));
        sRelationship.AddCriteria(Expr.Equals("Target_ID", individual.ID));
        sRelationship.AddCriteria(Expr.Equals("IsActive", true));
        sRelationship.AddSortColumn("ID");

        SearchResult srRelationship = APIExtensions.GetSearchResult(sRelationship, 0, null);

        return(srRelationship.TotalRowCount > 0);
    }