Exemplo n.º 1
0
        }//End getMaxColSpan class

        //  =================================================================================
        /// <summary>
        /// This class formats the string value using the pattern
        /// </summary>
        /// <param name="value">String: value to be formatted in its string representation</param>
        /// <param name="column">EvReportColumn: a column object</param>
        /// <returns>string: a string format using mask</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a pattern string
        ///
        /// 2. Validate whether the pattern is not null and empty
        ///
        /// 3. Switch the datatype of column and update the numberic value defining by the datatypes.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private string formatUsingMask(String value, EvReportColumn column)
        {
            //
            // Initialize a pattern string
            //
            String pattern = column.ValueFormatingString;

            //
            // Validate whether the pattern is not null and empty
            //
            if (pattern == null || pattern.Equals(String.Empty))
            {
                return(value);
            }

            //
            // Switch the datatype of column and update the numberic value defining by the datatypes.
            //
            switch (column.DataType)
            {
            case EvReport.DataTypes.Currency:
            case EvReport.DataTypes.Float:
            case EvReport.DataTypes.Integer:
            {
                return(EvcStatics.formatDoubleString(value, pattern));
            }

            case EvReport.DataTypes.Date:
            {
                return(EvcStatics.formatDateString(value, pattern));
            }

            default:
            {
                return(value);
            }
            } //END switch
        }     //END formatUsingMask class
Exemplo n.º 2
0
        }//End getTabulatedSection class

        //  =================================================================================
        /// <summary>
        /// This class obtains the formatted value of the column. It can be a currency, or a check box etc.
        /// </summary>
        /// <param name="section">EvReportSection: a report section</param>
        /// <param name="column">EvReportColumn: a section column</param>
        /// <returns>string: a formatted value string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a html string, column value string and column pattern string.
        ///
        /// 2. If a pattern string is not empty, return a formatted value column
        ///
        /// 3. Switch column datatype and update the html string with value defining by datatypes
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private string getFormattedValue(EvReportSection section, EvReportColumn column)
        {
            this.writeDebugLogMethod("getFormattedValue method.");
            //
            // Initialize a html string, column value string and column pattern string.
            //
            String stHtml       = String.Empty;
            string currentValue = (string)section.ColumnValuesByHeaderText [column.HeaderText];
            String pattern      = column.ValueFormatingString == null ? String.Empty : column.ValueFormatingString.Trim( );

            //
            // If a pattern string is not empty, return a formatted value column
            //
            if (pattern != String.Empty)
            {
                String retVal = formatUsingMask(currentValue, column);

                if (retVal.Trim( ) == String.Empty)
                {
                    return("&nbsp;");
                }

                return(retVal);
            }

            //
            // Switch column datatype and update the html string with value defining by datatypes
            //
            switch (column.DataType)
            {
            case EvReport.DataTypes.Bool:
                stHtml += "<input type='checkbox' id='" + column.HeaderText + "-" + section.RowNumber + "' ";
                stHtml += parseBoolean(currentValue) ? "CHECKED " : "";
                stHtml += _report.SelectionOn ? "" : "DISABLED ";
                stHtml += "/>";
                return(stHtml);

            case EvReport.DataTypes.Text:
                stHtml = currentValue;
                stHtml = stHtml.Replace("[[br]]", "[[BR]]");
                stHtml = stHtml.Replace("[[BR]]", "<br/>");
                stHtml = stHtml.Replace("\b", "<br/>");
                return(stHtml);

            case EvReport.DataTypes.Currency:
                return(EvcStatics.formatDoubleString(currentValue, "$###,##0"));

            case EvReport.DataTypes.Date:
                return(EvcStatics.formatDateString(currentValue, "dd/MM/yyyy"));

            case EvReport.DataTypes.Percent:
                try
                {
                    double dVal = double.Parse(currentValue);
                    dVal = dVal / 100;
                    return(dVal.ToString("p1"));
                }
                catch (Exception)
                {
                    return(currentValue);
                }

            default:
                return(currentValue);
            } //END switch
        }     //End getFormattedValue class