}//End getFlatSection class

        //  =================================================================================
        /// <summary>
        /// This class obtains the maximun coloum span for this section.
        /// Usually is the amount of colums of the detail of the report.
        /// </summary>
        /// <param name="section">EvReportSection: a report section</param>
        /// <returns>integer: a maximum column span number</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Validate whether the column details is not null
        ///
        /// 2. Iterate over all of the detail columns,
        ///
        /// 3. Only add the not hidden columns to the span value.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private static int getMaxColSpan(EvReportSection section)
        {
            int span = 0;

            //
            // Since the report is on big table, the upper sections should
            // span to the number of columns in the detail.
            //
            if (section.DetailColumnsList != null)
            {
                //
                // Iterate over all of the detail columns,
                // but only add the not hidden columns to the span value.
                //
                for (int i = 0; i < section.DetailColumnsList.Count; i++)
                {
                    EvReportColumn column = (EvReportColumn)section.DetailColumnsList [i];

                    if (column.DataType != EvReport.DataTypes.Hidden)
                    {
                        span++;
                    }
                }
            }
            return(span);
        }//End getMaxColSpan class
示例#2
0
        } //END getsection method

        //===================================================================================
        /// <summary>
        /// This class paints the section in a flat format.
        /// </summary>
        /// <param name="section">EvReportSection: a section to be painted</param>
        /// <returns>string: a flate section</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a csv string and a columnlist array.
        ///
        /// 2. Go through all of the columns of this report.
        ///
        /// 3. Format the current column with header, separator and format text
        ///
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private string getFlatSection(EvReportSection section)
        {
            //
            // Initialize a csv string and a columnlist array.
            //
            String    stCsv      = String.Empty;
            ArrayList columnList = section.ColumnList;

            stCsv += "\n";

            //
            // Go through all of the columns of this report.
            //
            for (int i = 0; i < columnList.Count; i++)
            {
                //
                // Format the current column with header, separator and format text
                //
                EvReportColumn currentColumn = (EvReportColumn)columnList [i];
                stCsv += getTextCSV(currentColumn.HeaderText)
                         + _separator
                         + formatText((string)section.ColumnValuesByHeaderText [currentColumn.HeaderText], currentColumn.DataType)
                         + "\n";
            }

            return(stCsv);
        } //END getflatsection method.
        /// <summary>
        /// This class obtains the section header. The hader depends of the type of the section.
        /// AFC 6 nov 2009
        /// </summary>
        /// <param name="section">EvReportSection: section</param>
        /// <returns>String: a section tabular header</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loop through the columnlist of the section and validate a hidden column
        ///
        /// 2. Generate header cells
        /// </remarks>
        private String getSectionHeader(EvReportSection section)
        {
            this.writeDebugLogMethod("getSectionHeader method.");
            string stHtml = String.Empty;

            if (section.Layout == EvReportSection.LayoutTypes.Tabular)
            {
                stHtml = "<tr>";

                //
                // Loop through the columnlist of the section and validate a hidden column
                //
                for (int i = 0; i < section.ColumnList.Count; i++)
                {
                    EvReportColumn currentColumn = (EvReportColumn)section.ColumnList [i];

                    //
                    // If the column is hiddent don't process it at all.
                    //
                    if (currentColumn.DataType == EvReport.DataTypes.Hidden)
                    {
                        continue;
                    }

                    //
                    // Generate the header cells
                    //
                    String headerCell = "<td class='Rpt_Header' ";

                    if (currentColumn.StyleWidth != String.Empty)
                    {
                        headerCell += "style='width:" + currentColumn.StyleWidth + "'";
                    }

                    headerCell += ">" + currentColumn.HeaderText + "</td>\r\n";

                    //
                    // If the headers are only for totals, and the grouping type is none, then dont show the header.
                    //
                    if (section.OnlyShowHeadersForTotalColumns == true)
                    {
                        if (currentColumn.GroupingType == EvReport.GroupingTypes.None)
                        {
                            headerCell = "<td>&nbsp;</td>";
                        }
                    }

                    stHtml += headerCell;
                }

                stHtml += "</tr>\n\r";
            }

            return(stHtml);
        }//END getSectionHeader method.
示例#4
0
        }//End getTabulatedSection method

        //===================================================================================
        /// <summary>
        /// This class obtains the section header. The hader depends of the type of the section.
        /// Andres Castano 9 nov 2009
        /// </summary>
        /// <param name="section">EvReportSection: a report section</param>
        /// <returns>String: a section header</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a csv string
        ///
        /// 2. Creates the header for a tabular section.
        ///
        /// 3. Iterate over all of the columns until the datatype is not hidden.
        ///
        /// 4. If the headers are totals, and the grouping type is none,
        /// then dont show the header.
        ///
        /// 5. If this is the last value, dont add the separator.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private String getSectionHeader(EvReportSection section)
        {
            //
            // Initialize a csv string
            //
            string stCsv = String.Empty;

            //
            // Creates the header for a tabular section.
            //
            if (section.Layout == EvReportSection.LayoutTypes.Tabular)
            {
                //
                // Iterate over all of the columns until the datatype is not hidden.
                //
                for (int i = 0; i < section.ColumnList.Count; i++)
                {
                    EvReportColumn currentColumn = (EvReportColumn)section.ColumnList [i];

                    if (currentColumn.DataType == EvReport.DataTypes.Hidden)
                    {
                        continue;
                    }

                    String headerText = getTextCSV(currentColumn.HeaderText);

                    //
                    // If the headers are totals, and the grouping type is none,
                    // then dont show the header.
                    //
                    if (section.OnlyShowHeadersForTotalColumns == true)
                    {
                        if (currentColumn.GroupingType == EvReport.GroupingTypes.None)
                        {
                            headerText = String.Empty;
                        }
                    }

                    stCsv += headerText;

                    //
                    // If this is the last value, dont add the separator.
                    //
                    if (i < section.ColumnList.Count - 1)
                    {
                        stCsv += _separator;
                    }
                }// End of headers loop

                stCsv += "\n";
            }// End of if it is tabular

            return(stCsv);
        }//End getSectionHeader method
        }     //End getFormattedValue class

        //  =================================================================================
        /// <summary>
        /// This method paints the section in a flat format.
        /// </summary>
        /// <param name="section">EvReportSection: a section to be painted</param>
        /// <returns>string: a flat section of the report</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a html string, a columnlist array and a span number
        ///
        /// 2. Go through all of the columns of this report.
        ///
        /// 3. If it is the first row, then open a new table row
        ///
        /// 4. Append a span class to the html string
        ///
        /// 5. If it is not the last row, then break line, else close table row.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private string getFlatSection(EvReportSection section)
        {
            this.writeDebugLogMethod("getFlatSection method.");
            //
            // Initialize a html string, a columnlist array and a span number
            //
            String    stHtml     = String.Empty;
            ArrayList columnList = section.ColumnList;
            int       span       = getMaxColSpan(section);

            //
            // Go through all of the columns of this report.
            //
            for (int i = 0; i < columnList.Count; i++)
            {
                //
                // If it is the first row, then open a new table row
                //
                if (i == 0)
                {
                    stHtml += "<tr>\n\r"
                              + "<td colspan='" + span + "' class='" + getClassNameForFlatRow(section.SectionLevel) + "'>";
                }

                EvReportColumn currentColumn = (EvReportColumn)columnList [i];

                //
                // Append a span class to the html string
                //
                stHtml += "<span class='Flat_Rpt_Field_Name'>" + currentColumn.HeaderText + ": </span><span class='Flat_Rpt_Field_Value'> "
                          + formatUsingMask((String)section.ColumnValuesByHeaderText [currentColumn.HeaderText], currentColumn)
                          + "</span>";

                //
                // If it is not the last row, then break line, else close table row.
                //
                if (i != columnList.Count - 1)
                {
                    stHtml += "<br>";
                }
                else
                {
                    stHtml += "</td></tr>\n\r";
                }
            }

            return(stHtml);
        }//End getFlatSection class
        }//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
示例#7
0
        } //END getflatsection method.

        //  ================================================================================
        /// <summary>
        /// This class returns the section in a tabulated format.
        /// </summary>
        /// <param name="section">EvReportSection: a section to be painted</param>
        /// <returns>String: a tabulated section</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a csv string and a columnlist array
        ///
        /// 2. Loop through the columnlist array until data type is not hidden
        ///
        /// 3. Convert the csv string into a tabulated format
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private String getTabulatedSection(EvReportSection section)
        {
            //
            // Initialize a csv string and a columnlist array
            //
            String    stCsv      = String.Empty;
            ArrayList columnList = section.ColumnList;

            //
            // Loop through the columnlist array until data type is not hidden
            //
            for (int j = 0; j < columnList.Count; j++)
            {
                EvReportColumn currentColumn = (EvReportColumn)columnList [j];

                if (currentColumn.DataType == EvReport.DataTypes.Hidden)
                {
                    continue;
                }

                //
                // Convert the csv string into a tabulated format
                //
                stCsv += formatText((string)section.ColumnValuesByHeaderText [currentColumn.HeaderText], currentColumn.DataType);

                //
                // If this is the last value, dont add the separator.
                //
                if (j < columnList.Count - 1)
                {
                    stCsv += _separator;
                }
            }//End of columns loop

            stCsv += "\n";
            return(stCsv);
        }//End getTabulatedSection method
示例#8
0
        // ==================================================================================
        /// <summary>
        /// This is the method who will return the actual text of the report.
        /// Depending on the implementation, it will return an html report,
        /// an xml report a csv report and so on.
        /// </summary>
        /// <returns>string: a report text</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loads the herarchy model of Section of Objects.
        ///
        /// 2. If there is no data then do not build the report
        ///
        /// 3. Generates the report header. This includes the titles and the queries.
        ///
        /// 4. Generates the grouped report. To pain a flat report,
        /// only the detail should be specified.
        ///
        /// 5. Return the report content formatted as Csv.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public override string getReportData( )
        {
            this.LogMethod("getReportData method.");
            //
            // Define the methods variables and objects.
            //
            StringBuilder stCsv = new StringBuilder( );

            //
            // If there is no data then do not build the report
            //
            if (this._report == null)
            {
                this.LogValue("No Data.");
                return(String.Empty);
            }

            //
            // Add the query name to the output data.
            //
            String QueryData  = String.Empty;
            int    queryCount = 0;

            foreach (EvReportQuery query in this._report.Queries)
            {
                if (query == null)
                {
                    continue;
                }

                if (query.FieldName != String.Empty)
                {
                    if (queryCount > 0)
                    {
                        QueryData += this._separator;
                    }
                    QueryData += this.getTextCSV("Q:" + query.FieldName);
                }
                queryCount++;
            }//END query header iteration loop.

            if (QueryData != String.Empty)
            {
                stCsv.Append(QueryData);
                stCsv.Append(this._separator);
            }

            //
            // Output the report column header.
            //
            for (int col = 0; col < this._report.Columns.Count; col++)
            {
                EvReportColumn column = this._report.Columns [col];
                if (col > 0)
                {
                    stCsv.Append(this._separator);
                }
                if (column.ColumnId == String.Empty)
                {
                    stCsv.Append(this.getTextCSV(column.SourceField));
                }
                else
                {
                    stCsv.Append(this.getTextCSV(column.ColumnId));
                }
            }
            stCsv.AppendLine("");



            //
            // Add the query values to the output data.
            //
            QueryData  = String.Empty;
            queryCount = 0;
            foreach (EvReportQuery query in this._report.Queries)
            {
                if (query == null)
                {
                    continue;
                }

                if (query.FieldName != String.Empty)
                {
                    if (queryCount > 0)
                    {
                        QueryData += this._separator;
                    }
                    QueryData += this.getTextCSV(query.Value);
                }
                queryCount++;
            }//END query value iteration loop.

            //
            // Output the report data.
            //
            for (int row = 0; row < this._report.DataRecords.Count; row++)
            {
                if (QueryData != String.Empty)
                {
                    stCsv.Append(QueryData);
                    stCsv.Append(this._separator);
                }

                //
                // the row of data.
                //
                EvReportRow rowData = this._report.DataRecords [row];

                //
                // column interation loop.
                //
                for (int col = 0; col < rowData.ColumnValues.Length; col++)
                {
                    if (col > 0)
                    {
                        stCsv.Append(this._separator);
                    }

                    stCsv.Append(this.getTextCSV(rowData.ColumnValues [col]));
                }//END column interation loop.

                stCsv.AppendLine("");
            }//END row interation loop

            //
            // Return the report content formatted as Csv.
            //
            this.LogMethodEnd("getReportData");
            return(stCsv.ToString());
        }//End getReportData class
示例#9
0
        }//End getSectionHeader 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. Initialize a csv string and a tempRow string.
        ///
        /// 2. Validate whether this section has totals.
        ///
        /// 3. Iterate over all of the details columns.
        ///
        /// 4. If title does not exist, continue loop and
        /// place the total label in this column.
        ///
        /// 5. If the title is already set, then paint the totals.
        ///
        /// 6. If this is the last value, dont add the separator.
        /// </remarks>
        // ----------------------------------------------------------------------------------
        private String addTotal(EvReportSection section)
        {
            //
            // Initialize a csv string and a tempRow string.
            //
            string stCsv   = String.Empty;
            string tempRow = String.Empty;

            //
            // Validate whether this section has totals.
            //
            if (section.DetailColumnsList != null && section.Acumulator != null)
            {
                //
                // 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++)
                {
                    //
                    // If there is no title yet and we are not at the end of the array
                    //
                    if (!isTitleSet && (j + 1) < section.DetailColumnsList.Count)
                    {
                        EvReportColumn nextColumn = (EvReportColumn)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)
                        {
                            if (nextColumn.GroupingType == EvReport.GroupingTypes.Total)
                            {
                                tempRow += getTextCSV("Total " + section.GroupingColumnValue + ":");
                            }
                            else if (nextColumn.GroupingType == EvReport.GroupingTypes.Count)
                            {
                                tempRow += getTextCSV(section.GroupingColumnValue + " total quantity:");
                            }

                            isTitleSet = true;
                        }
                    }

                    //
                    // If the title is already set, then paint the totals.
                    //
                    else
                    {
                        EvReportColumn currentColumn = (EvReportColumn)section.DetailColumnsList [j];
                        String         value         = (String)section.Acumulator [currentColumn.HeaderText];

                        if (value != null)
                        {
                            tempRow += formatText(value, currentColumn.DataType);
                        }
                    }//end if is title set

                    //
                    // If this is the last value, dont add the separator.
                    //
                    if (j < section.DetailColumnsList.Count - 1)
                    {
                        tempRow += _separator;
                    }
                }// end of detail column iteration.

                if (isTitleSet)
                {
                    stCsv = tempRow + "\n";
                }
            }

            return(stCsv);
        }//End Add total
        }//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
        }//End addTotal method

        //  =================================================================================
        /// <summary>
        /// This class paints the section in a tabulated format.
        /// </summary>
        /// <param name="section">EvReportSection: a section to be painted</param>
        /// <param name="recordNumber">Integer: a number of the record</param>
        /// <returns>String: a tabulated section of the report</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize a html string and a columnlist array
        ///
        /// 2. Add a row to a html string.
        ///
        /// 3. Iterate through the columnlist of the row
        ///
        /// 4. Validate whether the column is not hiddent
        ///
        /// 5. Add a column to a html string.
        ///
        /// 6. If numeric, move to the right but if not, move to center
        /// </remarks>
        //  ---------------------------------------------------------------------------------
        private String getTabulatedSection(EvReportSection section, int recordNumber)
        {
            this.writeDebugLogMethod("getTabulatedSection method.");
            //
            // Initialize a html string and a columnlist array
            //
            String    stHtml     = String.Empty;
            ArrayList columnList = section.ColumnList;

            //
            // Add a row to a html string.
            //
            stHtml += "<tr class='" + getClassNameForDetail(recordNumber) + "'>\n\r";

            //
            // Iterate through the columnlist of the row
            //
            for (int j = 0; j < columnList.Count; j++)
            {
                EvReportColumn currentColumn = (EvReportColumn)columnList [j];

                //
                // If the column is hidden, do nothing.
                //
                if (currentColumn.DataType == EvReport.DataTypes.Hidden)
                {
                    continue;
                }

                //
                // Add a column to Html string
                //
                stHtml += "<td class='" + getClassNameForDetail(recordNumber) + "' ";

                //
                // If the coulmn is numeric, align to the right.
                //
                if (currentColumn.DataType == EvReport.DataTypes.Integer ||
                    currentColumn.DataType == EvReport.DataTypes.Float ||
                    currentColumn.DataType == EvReport.DataTypes.Currency)
                {
                    stHtml += "style='text-align:right' ";
                }
                else if (currentColumn.DataType == EvReport.DataTypes.Bool ||
                         currentColumn.DataType == EvReport.DataTypes.Date ||
                         currentColumn.DataType == EvReport.DataTypes.Percent)
                {
                    stHtml += "style='text-align:center' ";
                }

                //
                // Close the column
                //
                stHtml += ">"
                          + this.getFormattedValue(section, currentColumn)
                          + "</td>\r\n";
            }

            //
            // Close the row
            //
            stHtml += "</tr>\n\r";
            return(stHtml);
        }//End getTabulatedSection 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(EvReportSection 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)
                    {
                        EvReportColumn nextColumn = (EvReportColumn)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 == EvReport.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 == EvReport.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
                    {
                        EvReportColumn currentColumn = (EvReportColumn)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%'>&nbsp</td></tr>";
            }

            return(stHtml);
        }//End addTotal method
        //===================================================================================
        /// <summary>
        /// This class loads the EvReportSection model from the flat table given in this report object.
        /// The model is a herarchy of EvReportSection Objects.
        /// AFC 6 nov 2009
        /// </summary>
        /// <returns>EvReportSection: a report section model</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Initialize report section properties: top section, section, detail, low section
        ///
        /// 2. Iterate through the report data records.
        ///
        /// 3. Iterate through the columns.
        ///
        /// 4. If column is not a detail column, use detail column functionality
        ///
        /// 5. If not a detail column, use non-detail column functionality
        /// </remarks>
        // ----------------------------------------------------------------------------------
        public EvReportSection loadModel(EvReport report)
        {
            this.writeDebugLogMethod("loadModel method.");
            //
            // This is the main section and contains the whole report.
            // It has some special characteristichs such as the level and the column values.
            //
            EvReportSection wholeReport = getTopSection( );

            //
            // Stores group column value for each level in the report.
            // This value is used to determine when a group value has changed, to then close that group and
            // all child groups including the detailed group.
            //
            String [] lastIndexValue = new String [5];

            //
            // Define a section for each level in the report.
            //
            EvReportSection [] sections = new EvReportSection [5];

            //
            // Define the detailed section separately as it treated separately.
            //
            EvReportSection detail = null;

            //
            // This stores the lower section before the detail. Is used since this section
            // has a specialized format.
            //
            EvReportSection lowerSection = null;

            //
            // True if the section has changed in this row.
            // This is used for initialize sections when iterating trhough columns.
            //
            bool [] sectionHasChangedInThisRow = new bool [5];

            //
            // Iterate through the report data records.
            //
            for (int record = 0; record < report.DataRecords.Count; record++)
            {
                //
                // Get a data report row
                //
                EvReportRow row = report.DataRecords [record];

                //
                // Iterate through the columns.
                //
                for (int column = 0; column < row.ColumnValues.Length; column++)
                {
                    //
                    // Retrieve the curren column
                    //
                    EvReportColumn currentColumn = report.Columns [column];

                    if (currentColumn.HeaderText == String.Empty)
                    {
                        continue;
                    }

                    //
                    // Extract the value of the current column
                    //
                    String currentValue = row.ColumnValues [column];

                    this.writeDebugLogLine("CurrentValue: " + currentValue);

                    int sectionLvl = currentColumn.SectionLvl;

                    //
                    // If the column is not the detail level, then this must be a group column
                    //
                    // So process the column using group column functionality.
                    //
                    if (sectionLvl != EvReportSection.Detail_Level)
                    {
                        //
                        // Test whether the group index has changed its value.
                        //
                        if (currentColumn.GroupingIndex &&
                            lastIndexValue [currentColumn.SectionLvl] != currentValue)
                        {
                            //
                            // Resets all the lower levels.
                            //
                            for (int level = currentColumn.SectionLvl; level < 5; level++)
                            {
                                lastIndexValue [level] = null;
                            }

                            //
                            // Open a new level.
                            //
                            lastIndexValue [currentColumn.SectionLvl] = currentValue;
                            sections [sectionLvl] = new EvReportSection( );

                            sections [sectionLvl].RowNumber = record;
                            //
                            // Stores the parent. If the previous level is the detail, then the parent is the
                            // whole report. If not, the parent is the previous section
                            //
                            sections [sectionLvl].Parent = sectionLvl - 1 == EvReportSection.Detail_Level ? wholeReport : sections [sectionLvl - 1];

                            sections [sectionLvl].SectionLevel        = sectionLvl;
                            sections [sectionLvl].Layout              = EvReportSection.LayoutTypes.Flat;
                            sections [sectionLvl].GroupingColumnValue = currentValue;
                            sectionHasChangedInThisRow [sectionLvl]   = true;
                            if (sections [sectionLvl].Parent == null)
                            {
                                sections [sectionLvl].Parent = new EvReportSection( );
                            }
                            sections [sectionLvl].Parent.ChildrenList.Add(sections [sectionLvl]);
                        }//END Group index has changed.

                        if (sectionHasChangedInThisRow [sectionLvl])
                        {
                            sections [sectionLvl].ColumnValuesByHeaderText.Add(currentColumn.HeaderText, currentValue);
                            sections [sectionLvl].ColumnList.Add(currentColumn);
                        }

                        //
                        // If the lower section has a level less than the current section level,
                        // then the current become the lower section.
                        //
                        if (lowerSection == null || lowerSection.SectionLevel < currentColumn.SectionLvl)
                        {
                            lowerSection = sections [sectionLvl];
                        }
                    }
                    else
                    {
                        //
                        // This is the section lvl 0 ("Detail").
                        // This assumes that the sections are coninuously enumerated.
                        //
                        if (lastIndexValue [currentColumn.SectionLvl] != ("" + record))
                        {
                            if (lowerSection == null)
                            {
                                lowerSection = wholeReport;
                            }

                            lastIndexValue [currentColumn.SectionLvl] = "" + record;

                            detail           = new EvReportSection( );
                            detail.RowNumber = record;
                            detail.Layout    = EvReportSection.LayoutTypes.Tabular;
                            detail.Parent    = lowerSection;

                            if (report.IsAggregated == true)
                            {
                                //
                                // Is the report is aggregated, then the detail is not visible.
                                //
                                detail.Visible = false;

                                detail.OnlyShowHeadersForTotalColumns = true;
                            }//End if is aggregated.

                            //
                            // Process: If the site header of the report is not empty, and the value of this site
                            // is different to the user organization, then dont show the detail.
                            //
                            else if (report.IsUserSiteFiltered == true)
                            {
                                String detailOrganizationId = detail.searchValueByHeaderText(report.SiteColumnHeaderText, true);

                                //
                                // If the user is not site staff, or site trial coordinator, or site principal investigator
                                // dont show the details.
                                //
                            }//End if it is site filtered.
                            else
                            {
                                detail.Visible = true;
                                detail.OnlyShowHeadersForTotalColumns = false;
                            }

                            lowerSection.ChildrenList.Add(detail);
                            lowerSection.DetailColumnsList = detail.ColumnList;
                        }

                        detail.ColumnValuesByHeaderText.Add(
                            currentColumn.HeaderText,
                            currentValue);

                        detail.ColumnList.Add(currentColumn);

                        if (currentColumn.GroupingType == EvReport.GroupingTypes.Total)
                        {
                            detail.addToAcumulator(currentColumn.HeaderText, currentValue);
                        }

                        //
                        // If the grouping type is count, then add 1 to the acumulator
                        // if the value is not empty.
                        //
                        if (currentColumn.GroupingType == EvReport.GroupingTypes.Count)
                        {
                            if (currentValue.Trim( ) != String.Empty)
                            {
                                detail.addToAcumulator(currentColumn.HeaderText, "1");
                            }
                        }
                    }
                }

                for (int i = 0; i < sectionHasChangedInThisRow.Length; i++)
                {
                    sectionHasChangedInThisRow [i] = false;
                }
                lowerSection = null;
            }

            return(wholeReport);
        }//End loadModel method.