示例#1
0
    /// <summary>
    /// Saves merge changes.
    /// </summary>
    private void Save()
    {
        parentAccount.AccountName           = cmbAccountName.Text.Trim();
        parentAccount.AccountAddress1       = cmbAccountAddress1.Text.Trim();
        parentAccount.AccountAddress2       = cmbAccountAddress2.Text.Trim();
        parentAccount.AccountCity           = cmbAccountCity.Text.Trim();
        parentAccount.AccountZIP            = cmbAccountZIP.Text.Trim();
        parentAccount.AccountStateID        = countrySelector.StateID;
        parentAccount.AccountCountryID      = countrySelector.CountryID;
        parentAccount.AccountWebSite        = cmbAccountWebSite.Text.Trim();
        parentAccount.AccountPhone          = cmbAccountPhone.Text.Trim();
        parentAccount.AccountEmail          = cmbAccountEmail.Text.Trim();
        parentAccount.AccountFax            = cmbAccountFax.Text.Trim();
        parentAccount.AccountStatusID       = accountStatusSelector.AccountStatusID;
        parentAccount.AccountNotes          = (string)htmlNotes.Value;
        parentAccount.AccountOwnerUserID    = CMSContext.CurrentUser.UserID;
        parentAccount.AccountSubsidiaryOfID = accountSelector.AccountID;

        // Save cusotm fields
        foreach (string key in customFields.Keys)
        {
            // Get value from
            object value = ((object[])customFields[key])[0];
            FormFieldDataTypeEnum datatype = (FormFieldDataTypeEnum)((object[])customFields[key])[1];
            string text = ((TextBox)value).Text;

            if (!String.IsNullOrEmpty(text))
            {
                // Save value according to specific data types
                switch (datatype)
                {
                case FormFieldDataTypeEnum.DateTime:
                    parentAccount.SetValue(key, ValidationHelper.GetDateTime(text, DateTime.Now));
                    break;

                case FormFieldDataTypeEnum.Boolean:
                    parentAccount.SetValue(key, ValidationHelper.GetBoolean(text, false));
                    break;

                case FormFieldDataTypeEnum.GUID:
                    parentAccount.SetValue(key, ValidationHelper.GetGuid(text, Guid.Empty));
                    break;

                case FormFieldDataTypeEnum.Integer:
                case FormFieldDataTypeEnum.LongInteger:
                    parentAccount.SetValue(key, ValidationHelper.GetInteger(text, 0));
                    break;

                case FormFieldDataTypeEnum.Decimal:
                    parentAccount.SetValue(key, ValidationHelper.GetDouble(text, 0));
                    break;

                default:
                    parentAccount.SetValue(key, text);
                    break;
                }
            }
        }
        AccountInfoProvider.SetAccountInfo(parentAccount);
    }
    /// <summary>
    /// Enable or disable field for translation according to actual Attribute Type (from DropDown list)
    /// </summary>
    private void SetFieldForTranslations()
    {
        FormFieldDataTypeEnum dataType = FormHelper.GetFormFieldDataType(AttributeType);

        if (TranslationServiceHelper.IsFieldForTranslation(dataType))
        {
            plcTranslation.Visible = true;
        }
        else
        {
            plcTranslation.Visible    = false;
            chkTranslateField.Checked = false;
        }
    }
示例#3
0
    /// <summary>
    /// Loads the new column type and size.
    /// </summary>
    /// <param name="dataType">Data type</param>
    /// <param name="newSize">New size</param>
    /// <param name="newColumnType">New column type</param>
    /// <param name="newColumnSize">New column size</param>
    protected void LoadColumnTypeAndSize(FormFieldDataTypeEnum dataType, int newSize, ref string newColumnType, ref string newColumnSize)
    {
        switch (dataType)
        {
            case FormFieldDataTypeEnum.Integer:
                newColumnType = SqlHelperClass.DATATYPE_INTEGER;
                break;

            case FormFieldDataTypeEnum.LongInteger:
                newColumnType = SqlHelperClass.DATATYPE_LONG;
                break;

            case FormFieldDataTypeEnum.Decimal:
                newColumnType = SqlHelperClass.DATATYPE_FLOAT;
                break;

            case FormFieldDataTypeEnum.Boolean:
                newColumnType = SqlHelperClass.DATATYPE_BOOLEAN;
                break;

            case FormFieldDataTypeEnum.DateTime:
                newColumnType = SqlHelperClass.DATATYPE_DATETIME;
                break;

            case FormFieldDataTypeEnum.LongText:
                newColumnType = SqlHelperClass.DATATYPE_LONGTEXT;
                break;

            case FormFieldDataTypeEnum.File:
            case FormFieldDataTypeEnum.GUID:
                newColumnType = SqlHelperClass.DATATYPE_GUID;
                break;

            case FormFieldDataTypeEnum.Binary:
                newColumnType = SqlHelperClass.DATATYPE_BINARY;
                break;

            default:
                newColumnSize = Convert.ToString(newSize);
                newColumnType = SqlHelperClass.DATATYPE_TEXT + "(" + newColumnSize + ")";
                break;
        }
    }
示例#4
0
    /// <summary>
    /// Fills tooltip with appropriate data.
    /// </summary>
    private void FillTooltipData(Image image, DataTable dt, string fieldName, string fieldValue, FormFieldDataTypeEnum dataType)
    {
        // Insert header into tooltip with parent value
        if (!String.IsNullOrEmpty(fieldValue))
        {
            // Datetime values
            if (dataType == FormFieldDataTypeEnum.DateTime)
            {
                image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> <strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>";
            }
            else
            {
                // Country
                image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> ";
                if (fieldName == "AccountCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (country != null)
                    {
                        image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>";
                    }
                    else
                    {
                        image.ToolTip += GetString("general.na");
                    }
                }
                // State
                else if (fieldName == "AccountStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (state != null)
                    {
                        image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>";
                    }
                    else
                    {
                        image.ToolTip += GetString("general.na");
                    }
                }
                // Otherwise
                else
                {
                    image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> <strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>";
                }
            }
        }
        else
        {
            image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> " + GetString("general.na");
        }
        image.ToolTip += "<br /><br /><em>" + GetString("om.account.mergedvalues") + "</em><br />";


        // Display N/A for empty merged records
        if (DataHelper.DataSourceIsEmpty(dt))
        {
            image.ToolTip += "<br /> " + GetString("general.na");
        }
        // Display values of merged records
        else
        {
            DataTable accounts;
            // Loop through all distinct values of given column
            foreach (DataRow dr in dt.Rows)
            {
                image.ToolTip += "<br />";
                // Sort accounts by full name
                mergedAccounts.Tables[0].DefaultView.Sort = "AccountName";
                mergedAccounts.CaseSensitive = true;

                // Need to transform status ID to displayname
                if (fieldName == "AccountStatusID")
                {
                    AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(status.AccountStatusDisplayName) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + status.AccountStatusID.ToString() + "'";
                }
                // Need to transform country ID to displayname
                else if (fieldName == "AccountCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + country.CountryID.ToString() + "'";
                }
                // Need to transform state ID to displayname
                else if (fieldName == "AccountStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + state.StateID.ToString() + "'";
                }
                // Date time type
                else if (dataType == FormFieldDataTypeEnum.DateTime)
                {
                    image.ToolTip += "<strong>" + ValidationHelper.GetDateTime(dr[fieldName], DateTimeHelper.ZERO_TIME) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Integer data type and boolean
                else if ((dataType == FormFieldDataTypeEnum.Integer) || (dataType == FormFieldDataTypeEnum.Boolean) || (dataType == FormFieldDataTypeEnum.Decimal) || (dataType == FormFieldDataTypeEnum.GUID) || (dataType == FormFieldDataTypeEnum.LongInteger))
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Get all contacts which have same string value
                else
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " LIKE '" + ContactHelper.EscapeString((string)dr[fieldName]) + "'";
                }

                // Display all accounts
                accounts = mergedAccounts.Tables[0].DefaultView.ToTable(false, "AccountName");
                foreach (DataRow row in accounts.Rows)
                {
                    image.ToolTip += "&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />";
                }
            }
        }
    }
示例#5
0
    /// <summary>
    /// Displays corresponding tooltip image.
    /// </summary>
    private bool DisplayTooltip(Image image, DataTable dt, string fieldName, string fieldValue, FormFieldDataTypeEnum dataType)
    {
        // Single value - not collision
        if (((!String.IsNullOrEmpty(fieldValue)) && (DataHelper.DataSourceIsEmpty(dt) || ((dt.Rows.Count == 1) && (ValidationHelper.GetString(dt.Rows[0][fieldName], null) == fieldValue)))) ||
            ((String.IsNullOrEmpty(fieldValue) || (((fieldName == "AccountCountryID") || (fieldName == "AccountStateID")) && (ValidationHelper.GetInteger(fieldValue, -1) == 0))) && (dt.Rows.Count == 1)))
        {
            FillTooltipData(image, dt, fieldName, fieldValue, dataType);
            image.ImageUrl = GetImageUrl("CMSModules/CMS_ContactManagement/resolved.png");
            image.Visible  = true;
        }
        // No data - hide icon
        else if (String.IsNullOrEmpty(fieldValue) && DataHelper.DataSourceIsEmpty(dt))
        {
            image.Visible = false;
        }
        // Multiple values - collision
        else
        {
            FillTooltipData(image, dt, fieldName, fieldValue, dataType);
            image.ImageUrl = GetImageUrl("CMSModules/CMS_ContactManagement/collision.png");
            image.Visible  = true;
        }
        image.Style.Add("cursor", "help");
        ScriptHelper.AppendTooltip(image, image.ToolTip, "help");

        // Reset row filter
        mergedAccounts.Tables[0].DefaultView.RowFilter = null;
        return(image.Visible);
    }
    /// <summary>
    /// Fills tooltip with appropriate data.
    /// </summary>
    private void FillTooltipData(Image image, DataTable dt, string fieldName, string fieldValue, FormFieldDataTypeEnum dataType)
    {
        // Insert header into tooltip with parent value
        if (!String.IsNullOrEmpty(fieldValue))
        {
            // Display birthday
            if (fieldName == "ContactBirthday")
            {
                image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME).ToShortDateString()) + "</strong>";
            }
            // Display gender
            else if (fieldName == "ContactGender")
            {
                int gender = ValidationHelper.GetInteger(fieldValue, 0);
                if (gender == (int)UserGenderEnum.Male)
                {
                    image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.male") + "</strong>";
                }
                else if (gender == (int)UserGenderEnum.Female)
                {
                    image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.female") + "</strong>";
                }
                else
                {
                    image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.unknown") + "</strong>";
                }
            }
            // Datetime values
            else if (dataType == FormFieldDataTypeEnum.DateTime)
            {
                image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>";
            }
            // Get all contacts which have same string value
            else
            {
                image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> ";
                if (fieldName == "ContactCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (country != null)
                    {
                        image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>";
                    }
                    else
                    {
                        image.ToolTip += GetString("general.na");
                    }
                }
                else if (fieldName == "ContactStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (state != null)
                    {
                        image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>";
                    }
                    else
                    {
                        image.ToolTip += GetString("general.na");
                    }
                }
                else
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>";
                }
            }
        }
        else
        {
            image.ToolTip += "<em>" + GetString("om.contact.parentvalue") + "</em> " + GetString("general.na");
        }
        image.ToolTip += "<br /><br /><em>" + GetString("om.contact.mergedvalues") + "</em><br />";

        // Display N/A for empty merged records
        if (DataHelper.DataSourceIsEmpty(dt))
        {
            image.ToolTip += "<br /> " + GetString("general.na");
        }
        // Display values of merged records
        else
        {
            DataTable contacts;
            // Loop through all distinct values of given column
            foreach (DataRow dr in dt.Rows)
            {
                image.ToolTip += "<br />";
                // Sort contacts by full name
                mergedContacts.Tables[0].DefaultView.Sort = "ContactFullNameJoined";
                mergedContacts.CaseSensitive = true;

                if (fieldName == "ContactBirthday")
                {
                    // Get all contacts which have same ContactBirthday value
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetDateTime(dr[fieldName], DateTimeHelper.ZERO_TIME).ToShortDateString()) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Display gender
                else if (fieldName == "ContactGender")
                {
                    int gender = ValidationHelper.GetInteger(dr[fieldName], 0);
                    if (gender == (int)UserGenderEnum.Male)
                    {
                        image.ToolTip += "<strong>" + GetString("general.male") + "</strong><br />";
                    }
                    else if (gender == (int)UserGenderEnum.Female)
                    {
                        image.ToolTip += "<strong>" + GetString("general.female") + "</strong><br />";
                    }
                    else
                    {
                        image.ToolTip += "<strong>" + GetString("general.unknown") + "</strong><br />";
                    }

                    if (String.IsNullOrEmpty(ValidationHelper.GetString(dr[fieldName], null)))
                    {
                        mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " IS NULL";
                    }
                    else
                    {
                        mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = " + dr[fieldName];
                    }
                }
                // Need to transform status ID to displayname
                else if (fieldName == "ContactStatusID")
                {
                    ContactStatusInfo status = ContactStatusInfoProvider.GetContactStatusInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ResHelper.LocalizeString(status.ContactStatusDisplayName)) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + status.ContactStatusID.ToString() + "'";
                }
                // Need to transform country ID to displayname
                else if (fieldName == "ContactCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + country.CountryID.ToString() + "'";
                }
                // Need to transform state ID to displayname
                else if (fieldName == "ContactStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + state.StateID.ToString() + "'";
                }
                // Date time type
                else if (dataType == FormFieldDataTypeEnum.DateTime)
                {
                    image.ToolTip += "<strong>" + ValidationHelper.GetDateTime(dr[fieldName], DateTimeHelper.ZERO_TIME) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Integer data type and boolean
                else if ((dataType == FormFieldDataTypeEnum.Integer) || (dataType == FormFieldDataTypeEnum.Boolean) || (dataType == FormFieldDataTypeEnum.Decimal) || (dataType == FormFieldDataTypeEnum.GUID) || (dataType == FormFieldDataTypeEnum.LongInteger))
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Get all contacts which have same string value
                else
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />";
                    mergedContacts.Tables[0].DefaultView.RowFilter = fieldName + " LIKE '" + ContactHelper.EscapeString((string)dr[fieldName]) + "'";
                }

                // Display all contact
                contacts = mergedContacts.Tables[0].DefaultView.ToTable(false, "ContactFullNameJoined");
                foreach (DataRow contactRow in contacts.Rows)
                {
                    image.ToolTip += "&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(contactRow["ContactFullNameJoined"], "").Trim()) + "<br />";
                }
            }
        }
    }
    /// <summary>
    /// Displays corresponding tooltip image.
    /// </summary>
    private bool DisplayTooltip(Image image, DataTable dt, string fieldName, string fieldValue, FormFieldDataTypeEnum dataType)
    {
        // Single value - not collision
        if (((!String.IsNullOrEmpty(fieldValue)) && (DataHelper.DataSourceIsEmpty(dt) || ((dt.Rows.Count == 1) && (ValidationHelper.GetString(dt.Rows[0][fieldName], null) == fieldValue))))
            || ((String.IsNullOrEmpty(fieldValue) || (((fieldName == "ContactCountryID") || (fieldName == "ContactStateID")) && (ValidationHelper.GetInteger(fieldValue, -1) == 0))) && (dt.Rows.Count == 1)))
        {
            FillTooltipData(image, dt, fieldName, fieldValue, dataType);
            image.ImageUrl = GetImageUrl("CMSModules/CMS_ContactManagement/resolved.png");
            image.Visible = true;
        }
        // Hide icon - no data for given field
        else if (String.IsNullOrEmpty(fieldValue) && DataHelper.DataSourceIsEmpty(dt))
        {
            image.Visible = false;
        }
        // Multiple values - collision
        else
        {
            FillTooltipData(image, dt, fieldName, fieldValue, dataType);
            image.ImageUrl = GetImageUrl("CMSModules/CMS_ContactManagement/collision.png");
            image.Visible = true;
        }
        image.Style.Add("cursor", "help");
        ScriptHelper.AppendTooltip(image, image.ToolTip, "help");

        // Reset row filter
        mergedContacts.Tables[0].DefaultView.RowFilter = null;
        return image.Visible;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check parameters
        if (!QueryHelper.ValidateHash("hash"))
        {
            ShowError("Validation of query hash failed.");
            pnlUpdate.Visible = false;
            btnOk.Visible = false;
        }
        else
        {
            // Register script for pendingCallbacks repair
            ScriptHelper.FixPendingCallbacks(Page);
            string parentClientId = QueryHelper.GetString("cid", string.Empty);

            ScriptHelper.RegisterStartupScript(this, typeof(string), "selectField", ScriptHelper.GetScript(
        @"
        function SelectFields(drpId) {
        var drpElem = document.getElementById(drpId);
        var value = drpElem.options[drpElem.selectedIndex].value;
        var text = drpElem.options[drpElem.selectedIndex].text;
        if ((wopener != null) && (wopener.SetValue_" + parentClientId + @" != null)) {
        wopener.SetValue_" + parentClientId + @"(value, text);
        }
        CloseDialog();
        }"));

            // Setup uniselector
            selectionElem.UniSelector.SelectionMode = SelectionModeEnum.SingleDropDownList;
            selectionElem.DisplayClearButton = false;
            selectionElem.DropDownSingleSelect.AutoPostBack = true;
            selectionElem.UniSelector.OnSelectionChanged += UniSelector_OnSelectionChanged;
            selectionElem.IsLiveSite = false;
            switch (ClassType)
            {
                // Custom tables
                case 0:
                    selectionElem.UniSelector.ObjectType = SettingsObjectType.CUSTOMTABLE;
                    CurrentMaster.Title.TitleText = GetString("attach.customtablefield");
                    lblClassNames.ResourceString = "objecttype.cms_customtable";
                    FieldType = FormFieldDataTypeEnum.Unknown;
                    break;

                // Document types
                case 1:
                default:
                    selectionElem.UniSelector.ObjectType = SettingsObjectType.DOCUMENTTYPE;
                    selectionElem.ShowOnlyCoupled = true;
                    CurrentMaster.Title.TitleText = GetString("attach.documenttypefield");
                    lblClassNames.ResourceString = "objecttype.cms_documenttype";
                    // Backward compatibility
                    FieldType = FormFieldDataTypeEnum.DocumentAttachments;
                    break;

                // System tables
                case 2:
                    selectionElem.UniSelector.ObjectType = SettingsObjectType.SYSTEMTABLE;
                    CurrentMaster.Title.TitleText = GetString("attach.systemtablefield");
                    lblClassNames.ResourceString = "objecttype.cms_systemtable";
                    FieldType = FormFieldDataTypeEnum.Unknown;
                    break;
            }
        }

        // Initialize master page
        CurrentMaster.Title.TitleImage = GetImageUrl("Design/Selectors/fieldselection.png");
        // Initialize buttons' functions
        btnOk.OnClientClick = "SelectFields('" + drpField.ClientID + "');  return false;";
        btnCancel.OnClientClick = "CloseDialog();  return false;";

        // Bind fields dropdown list
        if (!RequestHelper.IsPostBack())
        {
            selectionElem.ReloadData(false);
            selectionElem.DropDownSingleSelect.SelectedIndex = 0;
            LoadFields();
        }

        // Class name
        if (!string.IsNullOrEmpty(ClassName))
        {
            selectionElem.Value = ClassName;
            plcClassNames.Visible = false;
        }
    }
    /// <summary>
    /// Fills tooltip with appropriate data.
    /// </summary>
    private void FillTooltipData(Image image, DataTable dt, string fieldName, string fieldValue, FormFieldDataTypeEnum dataType)
    {
        // Insert header into tooltip with parent value
        if (!String.IsNullOrEmpty(fieldValue))
        {
            // Datetime values
            if (dataType == FormFieldDataTypeEnum.DateTime)
            {
                image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> <strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>";
            }
            else
            {
                // Country
                image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> ";
                if (fieldName == "AccountCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (country != null)
                    {
                        image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>";
                    }
                    else
                    {
                        image.ToolTip += GetString("general.na");
                    }
                }
                // State
                else if (fieldName == "AccountStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0));
                    if (state != null)
                    {
                        image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>";
                    }
                    else
                    {
                        image.ToolTip += GetString("general.na");
                    }
                }
                // Otherwise
                else
                {
                    image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> <strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>";
                }
            }
        }
        else
        {
            image.ToolTip += "<em>" + GetString("om.account.parentvalue") + "</em> " + GetString("general.na");
        }
        image.ToolTip += "<br /><br /><em>" + GetString("om.account.mergedvalues") + "</em><br />";

        // Display N/A for empty merged records
        if (DataHelper.DataSourceIsEmpty(dt))
        {
            image.ToolTip += "<br /> " + GetString("general.na");
        }
        // Display values of merged records
        else
        {
            DataTable accounts;
            // Loop through all distinct values of given column
            foreach (DataRow dr in dt.Rows)
            {
                image.ToolTip += "<br />";
                // Sort accounts by full name
                mergedAccounts.Tables[0].DefaultView.Sort = "AccountName";
                mergedAccounts.CaseSensitive = true;

                // Need to transform status ID to displayname
                if (fieldName == "AccountStatusID")
                {
                    AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(status.AccountStatusDisplayName) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + status.AccountStatusID.ToString() + "'";
                }
                // Need to transform country ID to displayname
                else if (fieldName == "AccountCountryID")
                {
                    CountryInfo country = CountryInfoProvider.GetCountryInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + country.CountryID.ToString() + "'";
                }
                // Need to transform state ID to displayname
                else if (fieldName == "AccountStateID")
                {
                    StateInfo state = StateInfoProvider.GetStateInfo((int)dr[fieldName]);
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + state.StateID.ToString() + "'";
                }
                // Date time type
                else if (dataType == FormFieldDataTypeEnum.DateTime)
                {
                    image.ToolTip += "<strong>" + ValidationHelper.GetDateTime(dr[fieldName], DateTimeHelper.ZERO_TIME) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Integer data type and boolean
                else if ((dataType == FormFieldDataTypeEnum.Integer) || (dataType == FormFieldDataTypeEnum.Boolean) || (dataType == FormFieldDataTypeEnum.Decimal) || (dataType == FormFieldDataTypeEnum.GUID) || (dataType == FormFieldDataTypeEnum.LongInteger))
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " = '" + dr[fieldName] + "'";
                }
                // Get all contacts which have same string value
                else
                {
                    image.ToolTip += "<strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr[fieldName], null)) + "</strong><br />";
                    mergedAccounts.Tables[0].DefaultView.RowFilter = fieldName + " LIKE '" + ContactHelper.EscapeString((string)dr[fieldName]) + "'";
                }

                // Display all accounts
                accounts = mergedAccounts.Tables[0].DefaultView.ToTable(false, "AccountName");
                foreach (DataRow row in accounts.Rows)
                {
                    image.ToolTip += "&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />";
                }
            }
        }
    }