示例#1
0
 /// <summary>
 /// UniGrid action handler.
 /// </summary>
 private void Grid_OnAction(string actionName, object actionArgument)
 {
     if (actionName == "delete")
     {
         AccountStatusInfo asi = AccountStatusInfoProvider.GetAccountStatusInfo(ValidationHelper.GetInteger(actionArgument, 0));
         if (asi != null)
         {
             //  Check modify permission for given object
             if (ConfigurationHelper.AuthorizedModifyConfiguration(asi.AccountStatusSiteID, true))
             {
                 AccountStatusInfoProvider.DeleteAccountStatusInfo(asi);
             }
         }
     }
 }
    /// <summary>
    /// Initializes account status selector.
    /// </summary>
    private void InitAccountStatus()
    {
        DataTable table = SortGroupAccountsByColumn("AccountStatusID", "AccountStatusID > 0", "AccountStatusID");

        // Preselect account status with data from parent
        if (parentAccount.AccountStatusID > 0)
        {
            accountStatusSelector.Value = parentAccount.AccountStatusID;
        }
        // Preselect account status with data from merged accounts only if single value exists in merged items
        else if ((table.Rows != null) && (table.Rows.Count > 0))
        {
            accountStatusSelector.Value = ValidationHelper.GetInteger(table.Rows[0][0], 0);
        }

        AccountStatusInfo asi = AccountStatusInfoProvider.GetAccountStatusInfo(parentAccount.AccountStatusID);
        string statusName = asi == null ? null : HTMLHelper.HTMLEncode(ResHelper.LocalizeString(asi.AccountStatusDisplayName));
        DisplayTooltip(imgAccountStatus, table, "AccountStatusID", statusName, FormFieldDataTypeEnum.Unknown);
    }
示例#3
0
    /// <summary>
    /// Initializes account status selector.
    /// </summary>
    private void InitAccountStatus()
    {
        mergedAccounts.Tables[0].DefaultView.Sort      = "AccountStatusID";
        mergedAccounts.Tables[0].DefaultView.RowFilter = "AccountStatusID > 0";
        DataTable table = mergedAccounts.Tables[0].DefaultView.ToTable(true, "AccountStatusID");

        // Preselect account status with data from parent
        if (parentAccount.AccountStatusID > 0)
        {
            accountStatusSelector.Value = parentAccount.AccountStatusID;
        }
        // Preselect account status with data from merged accounts only if single value exists in merged items
        else if ((table.Rows != null) && (table.Rows.Count > 0))
        {
            accountStatusSelector.Value = ValidationHelper.GetInteger(table.Rows[0][0], 0);
        }

        AccountStatusInfo asi        = AccountStatusInfoProvider.GetAccountStatusInfo(parentAccount.AccountStatusID);
        string            statusName = asi == null ? null : HTMLHelper.HTMLEncode(asi.AccountStatusDisplayName);

        DisplayTooltip(imgAccountStatus, table, "AccountStatusID", statusName, FormFieldDataTypeEnum.Unknown);
    }
示例#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>
    /// 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 += "&nbsp;-&nbsp;" + HTMLHelper.HTMLEncode(((string)row["AccountName"]).Trim()) + "<br />";
                }
            }
        }

        return(output);
    }