Beispiel #1
0
        /// <summary>
        /// 查询某个分组的其他字段统计方式列表
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public Dictionary <string, RptViewGridGroupTotal> GetSubTotalByGroup(RptViewGridGroup group)
        {
            Dictionary <string, RptViewGridGroupTotal> subTotal = new Dictionary <string, RptViewGridGroupTotal>();

            for (int i = 0; this.GridGroupTotals != null && i < this.GridGroupTotals.Length; i++)
            {
                if (this.GridGroupTotals[i].GroupSequence == group.GroupSequence)
                {
                    subTotal.Add(this.GridGroupTotals[i].ColumnName, this.GridGroupTotals[i]);
                }
            }
            return(subTotal);
        }
        protected override void UpdateReportDesignView()
        {
            string strGroupTotalValue = this.hidGroupTotal.Value;

            string[]           strGroupTotalList = strGroupTotalValue.Split('|');
            RptViewGridGroup[] groups            = new RptViewGridGroup[this.gridWebGrid.Rows.Count];
            ArrayList          listGroupTotal    = new ArrayList();

            for (int i = 0; i < this.gridWebGrid.Rows.Count; i++)
            {
                RptViewGridGroup grp = new RptViewGridGroup();
                grp.GroupSequence = i;
                grp.ColumnName    = this.gridWebGrid.Rows[i].Items.FindItemByKey("ColumnName").Value.ToString();
                for (int n = 0; n < strGroupTotalList.Length; n++)
                {
                    string[] strGroupOne = strGroupTotalList[n].Split('@');
                    if (strGroupOne[0] == grp.ColumnName)
                    {
                        string[] strGroupTotals = strGroupOne[1].Split(';');
                        for (int x = 0; x < strGroupTotals.Length; x++)
                        {
                            if (strGroupTotals[x] != "")
                            {
                                string[] strTmpList            = strGroupTotals[x].Split(',');
                                RptViewGridGroupTotal grpTotal = new RptViewGridGroupTotal();
                                grpTotal.GroupSequence = i;
                                grpTotal.ColumnName    = strTmpList[0];
                                grpTotal.TotalType     = strTmpList[1];
                                listGroupTotal.Add(grpTotal);
                            }
                        }
                        break;
                    }
                }
                groups[i] = grp;
            }
            this.designView.GridGroups      = groups;
            this.designView.GridGroupTotals = new RptViewGridGroupTotal[listGroupTotal.Count];
            listGroupTotal.CopyTo(this.designView.GridGroupTotals);
        }
Beispiel #3
0
        /// <summary>
        /// 构建单个TableGroup部分
        /// </summary>
        private string BuildTableGroup(ReportDesignView designView, int groupIndex, XmlDocument formatXml)
        {
            RptViewGridGroup group = designView.GridGroups[groupIndex];
            Dictionary <string, RptViewGridGroupTotal> subTotal = designView.GetSubTotalByGroup(group);

            string        strGroup     = formatXml.SelectSingleNode("//TableGroup").FirstChild.Value;
            StringBuilder sbGroupCells = new StringBuilder();
            string        strGroupCell = formatXml.SelectSingleNode("//GroupCell").FirstChild.Value;

            for (int i = 0; designView.GridColumns != null && i < designView.GridColumns.Length; i++)
            {
                string strColumnName       = designView.GridColumns[i].ColumnName;
                string strTmp              = strGroupCell.Replace("<%TextBoxName%>", "group_field_" + group.ColumnName + "_" + strColumnName);
                string strGridDataFormatId = "";
                for (int n = 0; designView.GridDataFormats != null && n < designView.GridDataFormats.Length; n++)
                {
                    if (designView.GridDataFormats[n].StyleType == ReportStyleType.SubTotal &&
                        designView.GridDataFormats[n].ColumnName == strColumnName &&
                        Convert.ToInt32(designView.GridDataFormats[n].GroupSequence) == group.GroupSequence)
                    {
                        strGridDataFormatId = designView.GridDataFormats[n].FormatID;
                        break;
                    }
                }
                RptViewDataFormat dataFormat = null;
                strTmp = this.ApplyFontStyle(strTmp, designView, strGridDataFormatId, formatXml, out dataFormat);
                SaveColumnWidth(strColumnName, dataFormat);

                if (dataFormat == null || dataFormat.TextExpress == null || dataFormat.TextExpress == "")
                {
                    if (strColumnName == group.ColumnName)
                    {
                        strTmp = strTmp.Replace("<%CellText%>", "=Fields!" + strColumnName + ".Value");
                    }
                    else
                    {
                        string strTotalType = ReportTotalType.Empty;
                        if (subTotal.ContainsKey(strColumnName) == true)
                        {
                            strTotalType = subTotal[strColumnName].TotalType;
                        }
                        if (strTotalType == ReportTotalType.Sum)
                        {
                            strTmp = strTmp.Replace("<%CellText%>", "=Sum(Fields!" + strColumnName + ".Value)");
                        }
                        else if (strTotalType == ReportTotalType.Avg)
                        {
                            strTmp = strTmp.Replace("<%CellText%>", "=Avg(Fields!" + strColumnName + ".Value)");
                        }
                        else if (strTotalType == ReportTotalType.Count)
                        {
                            strTmp = strTmp.Replace("<%CellText%>", "=Count(Fields!" + strColumnName + ".Value)");
                        }
                        else if (strTotalType == ReportTotalType.Empty)
                        {
                            strTmp = strTmp.Replace("<%CellText%>", "");
                        }
                        else if (strTotalType == ReportTotalType.Max)
                        {
                            strTmp = strTmp.Replace("<%CellText%>", "=Max(Fields!" + strColumnName + ".Value)");
                        }
                    }
                }
                else
                {
                    string strCellText = this.BuildCellTextExpression(designView, dataFormat.TextExpress);
                    strTmp = strTmp.Replace("<%CellText%>", strCellText);
                }

                sbGroupCells.Append(strTmp);
            }
            strGroup = strGroup.Replace("<%GroupCellList%>", sbGroupCells.ToString());
            strGroup = strGroup.Replace("<%GroupSortExpression%>", "=Fields!" + group.ColumnName + ".Value");
            strGroup = strGroup.Replace("<%GroupName%>", "group_" + group.ColumnName);
            strGroup = strGroup.Replace("<%GroupExpression%>", "=Fields!" + group.ColumnName + ".Value");
            if (groupIndex == 0)
            {
                strGroup = strGroup.Replace("<%Visibility%>", "");
            }
            else
            {
                string strVisible = formatXml.SelectSingleNode("//Visibility").FirstChild.Value;
                strVisible = strVisible.Replace("<%ToggleItem%>", "group_field_" + designView.GridGroups[groupIndex - 1].ColumnName + "_" + designView.GridGroups[groupIndex - 1].ColumnName);
                strGroup   = strGroup.Replace("<%Visibility%>", strVisible);
            }

            return(strGroup);
        }