}//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, EdReportColumn 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 EdReport.DataTypes.Currency: case EdReport.DataTypes.Float: case EdReport.DataTypes.Integer: { return(EvcStatics.formatDoubleString(value, pattern)); } case EdReport.DataTypes.Date: { return(EvcStatics.formatDateString(value, pattern)); } default: { return(value); } } //END switch } //END formatUsingMask class
}//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(EdReportSection section, EdReportColumn 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(" "); } return(retVal); } // // Switch column datatype and update the html string with value defining by datatypes // switch (column.DataType) { case EdReport.DataTypes.Bool: stHtml += "<input type='checkbox' id='" + column.HeaderText + "-" + section.RowNumber + "' "; stHtml += parseBoolean(currentValue) ? "CHECKED " : ""; stHtml += _report.SelectionOn ? "" : "DISABLED "; stHtml += "/>"; return(stHtml); case EdReport.DataTypes.Text: stHtml = currentValue; stHtml = stHtml.Replace("[[br]]", "[[BR]]"); stHtml = stHtml.Replace("[[BR]]", "<br/>"); stHtml = stHtml.Replace("\b", "<br/>"); return(stHtml); case EdReport.DataTypes.Currency: return(EvcStatics.formatDoubleString(currentValue, "$###,##0")); case EdReport.DataTypes.Date: return(EvcStatics.formatDateString(currentValue, "dd/MM/yyyy")); case EdReport.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