/// <summary>
    /// Contact role selected event handler.
    /// </summary>
    protected void btn_Click(object sender, EventArgs e)
    {
        int    roleId = ValidationHelper.GetInteger(((IButtonControl)sender).CommandArgument, 0);
        string script = null;

        if (!isMassAction)
        {
            // Set contact role to specified account-contact relation
            aci.ContactRoleID = roleId;
            AccountContactInfoProvider.SetAccountContactInfo(aci);

            script = ScriptHelper.GetScript(@"
if (wopener.Refresh) {wopener.Refresh();}
setTimeout('CloseDialog()',200);
");
        }
        else
        {
            script = ScriptHelper.GetScript(@"
wopener.AssignContactRole_" + ValidationHelper.GetString(Parameters["clientid"], string.Empty) + @"(" + roleId + @");
setTimeout('CloseDialog()',200);
");
        }

        ScriptHelper.RegisterStartupScript(Page, typeof(string), "CloseWindow", script);
    }
示例#2
0
    private void SetContactRoleToAccount(int roleId, int accountContactId)
    {
        var aci = AccountContactInfoProvider.GetAccountContactInfo(accountContactId);

        if (aci != null)
        {
            aci.ContactRoleID = roleId;
            AccountContactInfoProvider.SetAccountContactInfo(aci);
        }
    }
示例#3
0
    /// <summary>
    /// Sets primary and secondary contacts.
    /// </summary>
    private bool AssignContacts()
    {
        ContactInfo        contact        = null;
        AccountContactInfo accountContact = null;

        // Assign primary contact to account and/or assign role
        if (primaryContact.ContactID > 0)
        {
            contact = ContactInfoProvider.GetContactInfo(primaryContact.ContactID);
            if (contact != null)
            {
                // Check if contact <-> account relation is already created
                accountContact = AccountContactInfoProvider.GetAccountContactInfo(ai.AccountID, primaryContact.ContactID);

                // Update relation
                if (accountContact != null)
                {
                    accountContact.ContactRoleID = contactRolePrimary.ContactRoleID;
                }
                AccountContactInfoProvider.SetAccountContactInfo(accountContact);
            }
            // Selected contact doesn't exist
            else
            {
                ShowError(GetString("om.contact.primarynotexists"));
                return(false);
            }
        }

        // Assign secondary contact to account and/or assign role
        if (secondaryContact.ContactID > 0)
        {
            contact = ContactInfoProvider.GetContactInfo(secondaryContact.ContactID);
            if (contact != null)
            {
                // Check if contact <-> account relation is already created
                accountContact = AccountContactInfoProvider.GetAccountContactInfo(ai.AccountID, secondaryContact.ContactID);

                // Update relation
                if (accountContact != null)
                {
                    accountContact.ContactRoleID = contactRoleSecondary.ContactRoleID;
                }
                AccountContactInfoProvider.SetAccountContactInfo(accountContact);
            }
            else
            {
                ShowError(GetString("om.contact.secondarynotexists"));
                return(false);
            }
        }

        return(true);
    }
示例#4
0
 private void AssignContactToAccount(
     int accountAccountId,
     ContactInfo monicaKing,
     ContactRoleInfo contactRoleInfo)
 {
     AccountContactInfoProvider.SetAccountContactInfo(new AccountContactInfo
     {
         ContactID     = monicaKing.ContactID,
         AccountID     = accountAccountId,
         ContactRoleID = contactRoleInfo.ContactRoleID
     });
 }
示例#5
0
    /// <summary>
    /// Sets primary and secondary contacts.
    /// </summary>
    private void AssignContacts()
    {
        ContactInfo        contact;
        AccountContactInfo accountContact;

        // Assign primary contact to account and/or assign role
        int contactID     = ValidationHelper.GetInteger(EditForm.EditedObject.GetValue("accountprimarycontactid"), -1);
        int contactRoleID = ValidationHelper.GetInteger(EditForm.FieldControls["accountprimarycontactroleid"].Value, -1);

        if (contactID > 0)
        {
            contact = ContactInfoProvider.GetContactInfo(contactID);
            if (contact != null)
            {
                accountContact = AccountContactInfoProvider.GetAccountContactInfo(ai.AccountID, contactID);

                // Update relation
                if (accountContact != null)
                {
                    accountContact.ContactRoleID = contactRoleID;
                    AccountContactInfoProvider.SetAccountContactInfo(accountContact);
                }
                else
                {
                    EditForm.EditedObject.SetValue("accountprimarycontactid", null);
                    ((UniSelector)EditForm.FieldControls["accountprimarycontactid"]).Reload(true);
                }
            }
            // Selected contact doesn't exist
            else
            {
                ShowError(GetString("om.contact.primarynotexists"));
                return;
            }
        }

        // Assign secondary contact to account and/or assign role
        contactID     = ValidationHelper.GetInteger(EditForm.EditedObject.GetValue("accountsecondarycontactid"), -1);
        contactRoleID = ValidationHelper.GetInteger(EditForm.FieldControls["accountsecondarycontactroleid"].Value, -1);

        // Assign secondary contact to account and/or assign role
        if (contactID > 0)
        {
            contact = ContactInfoProvider.GetContactInfo(contactID);
            if (contact != null)
            {
                accountContact = AccountContactInfoProvider.GetAccountContactInfo(ai.AccountID, contactID);

                // Update relation
                if (accountContact != null)
                {
                    accountContact.ContactRoleID = contactRoleID;
                    AccountContactInfoProvider.SetAccountContactInfo(accountContact);
                }
                else
                {
                    EditForm.EditedObject.SetValue("accountsecondarycontactid", null);
                    ((UniSelector)EditForm.FieldControls["accountsecondarycontactid"]).Reload(true);
                }
            }
            else
            {
                ShowError(GetString("om.contact.secondarynotexists"));
            }
        }
    }