}//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
}//END getSection method. //=================================================================================== /// <summary> /// This class adds the total row after a section. /// </summary> /// <param name="section">EvReportSection: a report section</param> /// <returns>String: a total string</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Validate the secion is not null and empty /// /// 2. Paint a new table row for total value /// /// 3. Loop through the detail columns of the row. /// /// 4. If title does not exists, paint title and add total value /// /// 5. If title exists, add total value. /// </remarks> // ---------------------------------------------------------------------------------- private String addTotal(EdReportSection section) { this.writeDebugLogMethod("addTotal method."); int span = getMaxColSpan(section); string stHtml = String.Empty; // // If this section is not null. // if (section.DetailColumnsList == null && section.Acumulator == null) { return(String.Empty); } // // If this section is not empty. // if (section.DetailColumnsList.Count > 0 && section.Acumulator.Count > 0) { // // Paint total new table row // stHtml += "<tr class='Rpt_Alt'>\n\r"; //stHtml += "<tr class='" + getClassNameForDetail ( recordNumber + 1 ) + "'>\n\r"; // // The title should be set one column before the first total, // and should span from the first column to this. // bool isTitleSet = false; // // Iterate over all of the details columns. // for (int j = 0; j < section.DetailColumnsList.Count; j++) { String cell = null; // // If there is no title yet and we are not at the end of the array // if (!isTitleSet && (j + 1) < section.DetailColumnsList.Count) { EdReportColumn nextColumn = (EdReportColumn)section.DetailColumnsList [j + 1]; // // Obtains the acumulated value for the next column. // String nextValue = (String)section.Acumulator [nextColumn.HeaderText]; // // If the accumulated value for the next column is not empty, then place the total label in this column. // if (nextValue != null && nextValue != String.Empty) { int spanValue = j + 1; if (nextColumn.GroupingType == EdReport.GroupingTypes.Total) { cell = "<td colspan='" + spanValue + "' class='Rpt_Total' style='background-color: white' ><strong>Total " + section.GroupingColumnValue + ":</strong></td>\r\n"; } else if (nextColumn.GroupingType == EdReport.GroupingTypes.Count) { cell = "<td colspan='" + spanValue + "' class='Rpt_Total' style='background-color: white' ><strong>" + section.GroupingColumnValue + " total quantity:</strong></td>\r\n"; } isTitleSet = true; } } // // If the title is already set, then paint the totals. // else { EdReportColumn currentColumn = (EdReportColumn)section.DetailColumnsList [j]; String value = (String)section.Acumulator [currentColumn.HeaderText]; if (value != null) { cell = "<td class='Rpt_Total'><strong>" + EvcStatics.formatDoubleString(value, currentColumn.ValueFormatingString) + "</strong></td>\r\n"; } } if (cell != null && cell != String.Empty) { stHtml += cell; } else if (isTitleSet) { stHtml += "<td class='Rpt_Item'></td>\r\n"; } } stHtml += "</tr>\n\r<tr><td class='Rpt_Item' colspan='" + span + "' style='width:100%'> </td></tr>"; } return(stHtml); }//End addTotal method