Ejemplo n.º 1
0
 /// <summary>
 /// Gets the columns.
 /// </summary>
 /// <param name="parentNode">The parent node.</param>
 /// <returns></returns>
 /// <Remarks>
 /// Created Time: 2008-7-17 15:56
 /// Created By: jack_que
 /// Last Modified Time:  
 /// Last Modified By: 
 /// </Remarks>
 private List<HtmlColumn> GetColumns(XmlNode parentNode)
 {
     List<HtmlColumn> columns = new List<HtmlColumn>();
     XmlNode columnsNode = parentNode.SelectSingleNode("Columns");
     if (columnsNode != null)
     {
         XmlNodeList columnNodes = columnsNode.SelectNodes("Column");
         if (columnNodes != null)
         {
             for (int i = 0; i < columnNodes.Count; i++)
             {
                 XmlNode columnNode = columnNodes[i];
                 HtmlColumn htmlColumn = new HtmlColumn();
                 htmlColumn.Header = this.GetHeader(columnNode);
                 XmlNode dataTypeNode = columnNode.SelectSingleNode("DataType");
                 if (dataTypeNode != null)
                 {
                     htmlColumn.DataType = dataTypeNode.InnerText;
                 }
                 XmlNode rowSpanNode = columnNode.SelectSingleNode("RowSpan");
                 int rowSpan = 1;
                 if (rowSpanNode != null)
                 {
                     short result = 0;
                     if (Int16.TryParse(rowSpanNode.InnerText, out result))
                     {
                         rowSpan = result;
                     }
                 }
                 htmlColumn.RowSpan = rowSpan;
                 List<HtmlColumn> list = new List<HtmlColumn>();
                 htmlColumn.ChildColumns = list;
                 GetChildColumns(columnNode, ref list);
                 htmlColumn.IsLeaf = list.Count == 0;
                 columns.Add(htmlColumn);
             }
         }
     }
     return columns;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the col when deep.
        /// </summary>
        /// <param name="_column">The _column.</param>
        /// <param name="deep">The deep.</param>
        /// <param name="builder">The builder.</param>
        /// <Remarks>
        /// Created Time: 2008-7-20 9:59
        /// Created By: jack_que
        /// Last Modified Time:  
        /// Last Modified By: 
        /// </Remarks>
        private void CreateColWhenDeep(HtmlColumn _column, int deep, StringBuilder builder)
        {
            if (deep == 1)
            {
                for (int i = 0; i < _column.ChildColumns.Count; i++)
                {
                    HtmlColumn column = _column.ChildColumns[i];
                    int rowSpan = column.RowSpan;
                    int colSpan = column.GetTotalColSpan();
                    builder.Append("<td rowspan='").Append(rowSpan).Append("' ")
                           .Append("colspan='").Append(colSpan).Append("' ")
                           .Append("align='").Append(column.Header.Style.Align).Append("' ")
                           .Append("style='font-size:").Append(column.Header.Style.FontSize).Append("px;")
                           .Append("color:").Append(column.Header.Style.Color).Append(";'>")
                           .Append(column.Header.HeaderText).Append("</td>");
                }
                return;
            }

            for (int i = 0; i < _column.ChildColumns.Count; i++)
            {
                CreateColWhenDeep(_column.ChildColumns[i], deep - 1, builder);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Totals the col span.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="totalColSpan">The total col span.</param>
 /// <Remarks>
 /// Created Time: 2008-7-20 12:47
 /// Created By: jack_que
 /// Last Modified Time:  
 /// Last Modified By: 
 /// </Remarks>
 private void TotalColSpan(HtmlColumn column, ref int totalColSpan)
 {
     if (column.IsLeaf)
     {
         totalColSpan++;
         return;
     }
     for (int i = 0; i < column.ChildColumns.Count; i++)
     {
         TotalColSpan(column.ChildColumns[i], ref totalColSpan);
     }
 }
Ejemplo n.º 4
0
        private void TotalRowSpan(HtmlColumn column, ref int totalRowSpan)
        {
            if (column.ChildColumns.Count > 0)
                totalRowSpan++;
            else
                return;

            for (int i = 0; i < column.ChildColumns.Count; i++)
            {
                TotalRowSpan(column.ChildColumns[i], ref totalRowSpan);
                i = column.ChildColumns.Count;
            }
        }
Ejemplo n.º 5
0
        public void BuildCustomColumns(ref HtmlReportGenerator _generator,ref ReportDataSetConvertor _convert)
        {
            try
            {
                HtmlReport reportStruct = _generator.ParseXml();
                //get data to build htmlreport
                for (int i = 0; i < _convert.DynamicColumns.Count; i++)
                {
                    HtmlColumn parentColumn = new HtmlColumn();
                    parentColumn.Header.HeaderText = _convert.DynamicColumns[i].ColumnText;
                    parentColumn.Header.HeaderValue = _convert.DynamicColumns[i].ColumnValue;
                    parentColumn.ChildColumns = new List<HtmlColumn>();

                    for (int j = 0; j < _convert.DynamicColumnsPatterns.Count; j++)
                    {
                        ColumnPattern pat = _convert.DynamicColumnsPatterns[j];

                        if (pat.IncludeCondition == "*")
                        {
                            //该模式针对所有列都有效
                            string[] arrCondition = pat.ExcludeCondition.Split(',');
                            if (!arrCondition.Contains(_convert.DynamicColumns[i].ColumnText))
                            {
                                HtmlColumn childColumn = new HtmlColumn();
                                childColumn.Header.HeaderText = pat.ColumnText;
                                childColumn.Header.HeaderValue = pat.ColumnText;
                                childColumn.IsLeaf = true;
                                childColumn.RowSpan = 1;
                                parentColumn.ChildColumns.Add(childColumn);
                            }
                        }
                        else
                        {
                            //该模式针对部分列都有效,不判断排它列表
                            string[] arrCondition = pat.IncludeCondition.Split(',');
                            if (arrCondition.Contains(_convert.DynamicColumns[i].ColumnText))
                            {
                                HtmlColumn childColumn = new HtmlColumn();
                                childColumn.Header.HeaderText = pat.ColumnText;
                                childColumn.Header.HeaderValue = pat.ColumnText;
                                childColumn.IsLeaf = true;
                                childColumn.RowSpan = 1;
                                parentColumn.ChildColumns.Add(childColumn);
                            }
                        }
                    }

                    if (parentColumn.ChildColumns.Count > 0)
                        parentColumn.IsLeaf = false;
                    else
                    {
                        parentColumn.IsLeaf = true;
                    }

                    //判断是否有上层节点
                    HtmlColumn pcolumn = FindColumn(reportStruct.Columns, _convert.DynamicColumns[i].ParentValue);

                    if (pcolumn == null)
                    {
                        reportStruct.Columns.Add(parentColumn);
                    }
                    else
                    {
                        pcolumn.ChildColumns.Add(parentColumn);
                        pcolumn.IsLeaf = false;
                    }
                }

                //Sort
                SortReportStruct(ref reportStruct, ref _convert);

                //Add Fixed rows
                AddFixedRows(ref reportStruct,ref  _convert);

                _generator.report = reportStruct;

                //DataSet ds = localDal.GetCustomColumns(_year, _period, Costing_Reporting_SearchType.FE.ToString());
                //HtmlReport reportStruct = _generator.ParseXml();

                //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    HtmlColumn column = new HtmlColumn();
                //    column.Header.HeaderText = ds.Tables[0].Rows[i]["wcid"].ToString();
                //    column.ChildColumns = new List<HtmlColumn>();

                //    HtmlColumn childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Std";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Var";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    reportStruct.Columns.Add(column);
                //}

                //return reportStruct;
                ////get data to build htmlreport
                //DataSet ds = localDal.GetCustomColumns(_year, _period,Costing_Reporting_SearchType.FE.ToString());
                //HtmlReport reportStruct = _generator.ParseXml();

                //for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    HtmlColumn column = new HtmlColumn();
                //    column.Header.HeaderText = ds.Tables[0].Rows[i]["wcid"].ToString();
                //    column.ChildColumns = new List<HtmlColumn>();

                //    HtmlColumn childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Std";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    childColumn = new HtmlColumn();
                //    childColumn.Header.HeaderText = "Var";
                //    childColumn.IsLeaf = true;
                //    column.ChildColumns.Add(childColumn);

                //    reportStruct.Columns.Add(column);
                //}

                //return reportStruct;
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }