/// <summary> /// Fills tooltip with appropriate data. /// </summary> private string FillTooltipData(DataTable dt, string fieldName, string fieldValue, string dataType) { var output = String.Empty; // Insert header into tooltip with parent value if (!String.IsNullOrEmpty(fieldValue)) { output += "<em>" + GetString("om.account.parentvalue") + "</em> "; // Datetime values if (dataType == FieldDataType.DateTime) { output += "<strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>"; } else { // Country if (fieldName == "AccountCountryID") { CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (country != null) { output += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>"; } else { output += GetString("general.na"); } } // State else if (fieldName == "AccountStateID") { StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (state != null) { output += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>"; } else { output += GetString("general.na"); } } // Status else if (fieldName == "AccountStatusID") { AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (status != null) { output += "<strong>" + HTMLHelper.HTMLEncode(status.AccountStatusDisplayName) + "</strong>"; } else { output += GetString("general.na"); } } // Otherwise else { output += "<strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>"; } } } else { output += "<em>" + GetString("om.account.parentvalue") + "</em> " + GetString("general.na"); } output += "<br /><br /><em>" + GetString("om.account.mergedvalues") + "</em><br />"; // Display N/A for empty merged records if (DataHelper.DataSourceIsEmpty(dt)) { output += "<br /> " + GetString("general.na"); } // Display values of merged records else { // Loop through all distinct values of given column foreach (DataRow dr in dt.Rows) { output += "<br />"; // Sort accounts by full name var accountsView = mMergedAccounts.Tables[0].DefaultView; accountsView.Sort = "AccountName"; mMergedAccounts.CaseSensitive = true; var value = dr[fieldName]; // Need to transform status ID to displayname if (fieldName == "AccountStatusID") { AccountStatusInfo status = AccountStatusInfoProvider.GetAccountStatusInfo((int)value); output += GetTooltipItem(ResHelper.LocalizeString(status.AccountStatusDisplayName)); accountsView.RowFilter = fieldName + " = '" + status.AccountStatusID + "'"; } // Need to transform country ID to displayname else if (fieldName == "AccountCountryID") { CountryInfo country = CountryInfoProvider.GetCountryInfo((int)value); output += GetTooltipItem(country.CountryDisplayName); accountsView.RowFilter = fieldName + " = '" + country.CountryID + "'"; } // Need to transform state ID to displayname else if (fieldName == "AccountStateID") { StateInfo state = StateInfoProvider.GetStateInfo((int)value); output += GetTooltipItem(state.StateDisplayName); accountsView.RowFilter = fieldName + " = '" + state.StateID + "'"; } // Other fields, process based on field type else { output += GetTooltipItem(ValidationHelper.GetString(value, null)); accountsView.RowFilter = fieldName + " = '" + ContactHelper.EscapeString((string)value) + "'"; } // Display all accounts var accounts = accountsView.ToTable(false, "AccountName"); foreach (DataRow row in accounts.Rows) { output += " - " + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />"; } } } return(output); }
/// <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 += " - " + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />"; } } } }
/// <summary> /// Fills tooltip with appropriate data. /// </summary> private string FillTooltipData(DataTable dt, string fieldName, string fieldValue, string dataType) { var output = String.Empty; // Insert header into tooltip with parent value if (!String.IsNullOrEmpty(fieldValue)) { // Display birthday if (fieldName == "ContactBirthday") { output += "<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) { output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.male") + "</strong>"; } else if (gender == (int)UserGenderEnum.Female) { output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.female") + "</strong>"; } else { output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + GetString("general.unknown") + "</strong>"; } } // Datetime values else if (dataType == FieldDataType.DateTime) { output += "<em>" + GetString("om.contact.parentvalue") + "</em> <strong>" + ValidationHelper.GetDateTime(fieldValue, DateTimeHelper.ZERO_TIME) + "</strong>"; } // Get all contacts which have same string value else { output += "<em>" + GetString("om.contact.parentvalue") + "</em> "; if (fieldName == "ContactCountryID") { CountryInfo country = CountryInfoProvider.GetCountryInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (country != null) { output += "<strong>" + HTMLHelper.HTMLEncode(country.CountryDisplayName) + "</strong>"; } else { output += GetString("general.na"); } } else if (fieldName == "ContactStateID") { StateInfo state = StateInfoProvider.GetStateInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (state != null) { output += "<strong>" + HTMLHelper.HTMLEncode(state.StateDisplayName) + "</strong>"; } else { output += GetString("general.na"); } } else if (fieldName == "ContactStatusID") { ContactStatusInfo status = ContactStatusInfoProvider.GetContactStatusInfo(ValidationHelper.GetInteger(fieldValue, 0)); if (status != null) { output += "<strong>" + HTMLHelper.HTMLEncode(status.ContactStatusDisplayName) + "</strong>"; } else { output += GetString("general.na"); } } else { output += "<strong>" + HTMLHelper.HTMLEncode(fieldValue) + "</strong>"; } } } else { output += "<em>" + GetString("om.contact.parentvalue") + "</em> " + GetString("general.na"); } output += "<div><em>" + GetString("om.contact.mergedvalues") + "</em></div>"; // Display N/A for empty merged records if (DataHelper.DataSourceIsEmpty(dt)) { output += "<div>" + GetString("general.na") + "</div>"; } // Display values of merged records else { // Loop through all distinct values of given column foreach (DataRow dr in dt.Rows) { output += "<div>"; // Sort contacts by full name var contactsView = mMergedContacts.Tables[0].DefaultView; contactsView.Sort = "ContactFullNameJoined"; mMergedContacts.CaseSensitive = true; var value = dr[fieldName]; if (fieldName == "ContactBirthday") { // Get all contacts which have same ContactBirthday value output += "<div><strong>" + HTMLHelper.HTMLEncode(ValidationHelper.GetDateTime(value, DateTimeHelper.ZERO_TIME).ToShortDateString()) + "</strong></div>"; contactsView.RowFilter = fieldName + " = '" + value + "'"; } // Display gender else if (fieldName == "ContactGender") { int gender = ValidationHelper.GetInteger(value, 0); if (gender == (int)UserGenderEnum.Male) { output += GetTooltipItem(GetString("general.male")); } else if (gender == (int)UserGenderEnum.Female) { output += GetTooltipItem(GetString("general.female")); } else { output += GetTooltipItem(GetString("general.unknown")); } if (String.IsNullOrEmpty(ValidationHelper.GetString(value, null))) { contactsView.RowFilter = fieldName + " IS NULL"; } else { contactsView.RowFilter = fieldName + " = " + value; } } // Need to transform status ID to displayname else if (fieldName == "ContactStatusID") { ContactStatusInfo status = ContactStatusInfoProvider.GetContactStatusInfo((int)value); output += GetTooltipItem(ResHelper.LocalizeString(status.ContactStatusDisplayName)); contactsView.RowFilter = fieldName + " = '" + status.ContactStatusID + "'"; } // Need to transform country ID to displayname else if (fieldName == "ContactCountryID") { CountryInfo country = CountryInfoProvider.GetCountryInfo((int)value); output += GetTooltipItem(country.CountryDisplayName); contactsView.RowFilter = fieldName + " = '" + country.CountryID + "'"; } // Need to transform state ID to displayname else if (fieldName == "ContactStateID") { StateInfo state = StateInfoProvider.GetStateInfo((int)value); output += GetTooltipItem(state.StateDisplayName); contactsView.RowFilter = fieldName + " = '" + state.StateID + "'"; } // Other fields, process based on field type else { output += GetTooltipItem(ValidationHelper.GetString(value, null)); contactsView.RowFilter = fieldName + " = '" + ContactHelper.EscapeString(ValidationHelper.GetString(value, "")) + "'"; } // Display all contact DataTable contacts = contactsView.ToTable(false, "ContactFullNameJoined"); foreach (DataRow contactRow in contacts.Rows) { output += "<div> - " + HTMLHelper.HTMLEncode(ValidationHelper.GetString(contactRow["ContactFullNameJoined"], "").Trim()) + "</div>"; } output += "</div>"; } } return(output); }