예제 #1
0
        /// <summary>
        /// 撤消操作时回退数据
        /// </summary>
        public void BackMtxRow()
        {
            RptMtxHeader header = SubTitle.Level.Parent as RptMtxHeader;
            RptMatrix    mat    = header.Parent as RptMatrix;

            if (header is RptMtxRowHeader)
            {
                if (OpsRows.Count == 0)
                {
                    return;
                }
                mat.Rows.InsertRange(CurIndex, OpsRows);
            }
            else
            {
                if (OpsCells.Count == 0)
                {
                    return;
                }
                foreach (RptMtxRow row in mat.Rows)
                {
                    row.Cells.InsertRange(CurIndex, OpsCells[row]);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 删除对应数据行
        /// </summary>
        public void DelMtxRows()
        {
            RptMtxHeader header = SubTitle.Level.Parent as RptMtxHeader;
            RptMatrix    mat    = header.Parent as RptMatrix;

            if (header is RptMtxRowHeader)
            {
                if (OpsRows.Count == 0)
                {
                    return;
                }
                mat.Rows.RemoveRange(CurIndex, OpsRows.Count);
            }
            else
            {
                if (OpsCells.Count == 0)
                {
                    return;
                }
                foreach (RptMtxRow row in OpsCells.Keys)
                {
                    row.Cells.RemoveRange(CurIndex, OpsCells[row].Count());
                }
            }
        }
예제 #3
0
 public RptMtxLevel(RptMtxHeader p_header)
 {
     _header   = p_header;
     Item      = new RptText(this);
     SubTotals = new List <RptMtxSubtotal>();
     SubTitles = new List <RptMtxSubtitle>();
     // 对应字段名
     _data.AddCell <string>("field");
 }
예제 #4
0
파일: RptMatrix.cs 프로젝트: Daoting/dt
 /// <summary>
 /// 创建小计
 /// </summary>
 /// <param name="totals"></param>
 /// <param name="p_header"></param>
 /// <param name="p_matInst"></param>
 /// <param name="p_curRow"></param>
 /// <param name="p_data"></param>
 /// <param name="p_loc"></param>
 void CreateTotalInst(List <RptMtxSubtotal> totals, RptMtxHeader p_header, RptMatrixInst p_matInst, Row p_curRow, RptData p_data, TotalLocation p_loc)
 {
     foreach (RptMtxSubtotal total in totals)
     {
         if (total.TotalLoc == p_loc)
         {
             if (total.SubTotals.Count > 0)
             {
                 CreateTotalInst(total.SubTotals, p_header, p_matInst, p_curRow, p_data, p_loc);
             }
             else
             {
                 RptMtxHeaderInst totalInst = new RptMtxHeaderInst(p_header);
                 for (int j = 0; j < p_header.Levels.IndexOf(total.Level); j++)
                 {
                     RptMtxLevel nLevel = p_header.Levels[j];
                     nLevel.Item.ColSpan = 1;
                     nLevel.Item.RowSpan = 1;
                     RptTextInst txtlevel = new RptTextInst(nLevel.Item);
                     totalInst.TxtInsts.Add(txtlevel);
                     totalInst.Filter.Add(nLevel.Field, p_curRow.Str(nLevel.Field));
                 }
                 RptItemBase parent = total.Parent;
                 while (parent is RptMtxSubtotal)
                 {
                     RptTextInst parTotal = new RptTextInst((parent as RptMtxSubtotal).Item);
                     totalInst.TxtInsts.Add(parTotal);
                     parent = parent.Parent;
                 }
                 RptTextInst txtTotal = new RptTextInst(total.Item);
                 totalInst.TxtInsts.Add(txtTotal);
                 totalInst.RptData         = p_data;
                 totalInst.RptData.Current = p_curRow.Index;
                 totalInst.Index           = p_curRow.Index;
                 if (p_header is RptMtxColHeader)
                 {
                     totalInst.MtxRowsCol = total.Col;
                     p_matInst.AddColHeader(totalInst);
                 }
                 else
                 {
                     totalInst.MtxRowsRow = total.Row;
                     p_matInst.AddRowHeader(totalInst);
                 }
             }
         }
     }
 }
예제 #5
0
        /// <summary>
        /// 克隆层
        /// </summary>
        /// <param name="p_header"></param>
        /// <returns></returns>
        public RptMtxLevel Clone(RptMtxHeader p_header)
        {
            RptMtxLevel level = new RptMtxLevel(p_header);

            level.Data.Copy(this.Data);
            level.Item.Data.Copy(Item.Data);
            foreach (RptMtxSubtotal total in SubTotals)
            {
                level.SubTotals.Add(total.Clone(level));
            }
            foreach (RptMtxSubtitle title in SubTitles)
            {
                level.SubTitles.Add(title.Clone(level));
            }
            return(level);
        }
예제 #6
0
파일: RptMatrix.cs 프로젝트: Daoting/dt
 /// <summary>
 /// 创建标题
 /// </summary>
 /// <param name="p_titles"></param>
 /// <param name="p_header"></param>
 /// <param name="p_matInst"></param>
 /// <param name="p_curRow"></param>
 /// <param name="p_data"></param>
 void CreateSubTiltelInst(List <RptMtxSubtitle> p_titles, RptMtxHeader p_header, RptMatrixInst p_matInst, Row p_curRow, RptData p_data)
 {
     foreach (RptMtxSubtitle title in p_titles)
     {
         if (title.SubTitles.Count > 0)
         {
             CreateSubTiltelInst(title.SubTitles, p_header, p_matInst, p_curRow, p_data);
         }
         else
         {
             RptMtxHeaderInst titleInst = new RptMtxHeaderInst(p_header);
             for (int j = 0; j <= p_header.Levels.IndexOf(title.Level); j++)
             {
                 RptMtxLevel nLevel = p_header.Levels[j];
                 nLevel.Item.ColSpan = 1;
                 nLevel.Item.RowSpan = 1;
                 RptTextInst txtlevel = new RptTextInst(nLevel.Item);
                 titleInst.TxtInsts.Add(txtlevel);
                 titleInst.Filter.Add(nLevel.Field, p_curRow.Str(nLevel.Field));
             }
             RptItemBase parent = title.Parent;
             while (parent is RptMtxSubtotal)
             {
                 RptTextInst parTotal = new RptTextInst((parent as RptMtxSubtotal).Item);
                 titleInst.TxtInsts.Add(parTotal);
                 parent = parent.Parent;
             }
             RptTextInst txtTotal = new RptTextInst(title.Item);
             titleInst.TxtInsts.Add(txtTotal);
             titleInst.RptData         = p_data;
             titleInst.RptData.Current = p_curRow.Index;
             titleInst.Index           = p_curRow.Index;
             if (p_header is RptMtxColHeader)
             {
                 titleInst.MtxRowsCol = title.Col;
                 p_matInst.AddColHeader(titleInst);
             }
             else
             {
                 titleInst.MtxRowsRow = title.Row;
                 p_matInst.AddRowHeader(titleInst);
             }
         }
     }
 }
예제 #7
0
        public override object Execute(object p_args)
        {
            SubTitleCmdArgs  args       = (SubTitleCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMtxSubtitle   title      = args.SubTitle;
            RptMatrix        mtx        = null;

            if (title == null)
            {
                title = new RptMtxSubtitle(parent);
                args.InitData();
                if (parent is RptMtxLevel)
                {
                    RptMtxLevel pLevel = parent as RptMtxLevel;
                    mtx = pLevel.Matrix;
                    if (pLevel.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle());

                    RptMtxHeader header = pLevel.Parent as RptMtxHeader;
                    if (pLevel.SubTitles.Count > 0 || header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            int subLevelSpan = 0;
                            if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                            {
                                subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].RowSpan;
                            }

                            curIndex = pLevel.Row - mtx.ColHeader.Row - mtx.ColHeader.RowSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles);
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            int subLevelSpan = 0;
                            if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                            {
                                subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].ColSpan;
                            }

                            curIndex = pLevel.Col - mtx.RowHeader.Col - mtx.RowHeader.ColSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles);
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                    pLevel.SubTitles.Add(title);
                }
                else
                {
                    RptMtxSubtitle pTitle = parent as RptMtxSubtitle;
                    mtx = pTitle.Level.Matrix;
                    if (pTitle.Level.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle());
                    if (pTitle.SubTitles.Count > 0)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            curIndex = pTitle.Row + pTitle.RowSpan - mtx.ColHeader.Row - mtx.ColHeader.RowSpan;
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            curIndex = pTitle.Col + pTitle.ColSpan - mtx.RowHeader.Col - mtx.RowHeader.ColSpan;
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                    pTitle.SubTitles.Add(title);
                }
                args.SubTitle = title;
            }
            else
            {
                mtx = title.Level.Matrix;
                if (parent is RptMtxLevel)
                {
                    args.BackMtxRow();
                    (parent as RptMtxLevel).SubTitles.Add(title);
                }
                else
                {
                    (parent as RptMtxSubtitle).SubTitles.Add(title);
                }
            }
            mtx.Update(true);
            return(title);
        }
예제 #8
0
파일: RptMatrix.cs 프로젝트: Daoting/dt
        /// <summary>
        /// 构造行头或列头
        /// </summary>
        /// <param name="p_rptData"></param>
        /// <param name="p_header"></param>
        /// <param name="p_matInst"></param>
        void BuildHeader(RptData p_rptData, RptMtxHeader p_header, RptMatrixInst p_matInst)
        {
            List <string> colNames      = p_header.GetFieldNames();
            List <Row>    allHeaderData = SelectDistinctDataRows(p_rptData.Data, colNames);
            Row           preRow        = null;

            for (int i = 0; i < allHeaderData.Count; i++)
            {
                Row curRow = allHeaderData[i];
                if (preRow == null || !string.IsNullOrEmpty(CompareTwoRows(preRow, curRow, colNames)))
                {
                    //前面小计
                    foreach (RptMtxLevel level in p_header.Levels)
                    {
                        if (level.SubTotals.Count <= 0)
                        {
                            continue;
                        }
                        RptMtxLevel beforLevel = null;
                        if (p_header.Levels.IndexOf(level) - 1 >= 0)
                        {
                            beforLevel = p_header.Levels[p_header.Levels.IndexOf(level) - 1];
                        }
                        //第一行(列) 或者 前一行(列)层值与当前行层值不同 创建小计
                        if (preRow == null || (beforLevel != null && preRow.Str(beforLevel.Field) != curRow.Str(beforLevel.Field)))
                        {
                            CreateTotalInst(level.SubTotals, p_header, p_matInst, curRow, p_rptData, TotalLocation.Before);
                        }
                    }

                    //数据
                    RptMtxHeaderInst headerInst = new RptMtxHeaderInst(p_header);
                    foreach (RptMtxLevel level in p_header.Levels)
                    {
                        if (level.SubTitles.Count > 0)
                        {
                            CreateSubTiltelInst(level.SubTitles, p_header, p_matInst, curRow, p_rptData);
                        }
                        else
                        {
                            //手动置1,因为输出头的时候按一行或一列输出,不需要控件合并
                            level.Item.ColSpan = 1;
                            level.Item.RowSpan = 1;
                            RptTextInst txtlevel = new RptTextInst(level.Item);
                            headerInst.TxtInsts.Add(txtlevel);
                        }
                    }
                    if (headerInst.TxtInsts.Count > 0)
                    {
                        headerInst.RptData = p_rptData;
                        headerInst.Index   = curRow.Index;
                        if (p_header is RptMtxColHeader)
                        {
                            headerInst.MtxRowsCol = p_header.Levels[p_header.Levels.Count - 1].Col;
                            p_matInst.AddColHeader(headerInst);
                        }
                        else
                        {
                            headerInst.MtxRowsRow = p_header.Levels[p_header.Levels.Count - 1].Row;
                            p_matInst.AddRowHeader(headerInst);
                        }
                        //生成条件
                        foreach (string name in colNames)
                        {
                            headerInst.Filter.Add(name, curRow.Str(name));
                        }
                    }

                    //后面小计
                    for (int k = p_header.Levels.Count - 1; k >= 0; k--)
                    {
                        RptMtxLevel level = p_header.Levels[k];
                        if (level.SubTotals.Count <= 0)
                        {
                            continue;
                        }
                        RptMtxLevel beforLevel = null;
                        if (p_header.Levels.IndexOf(level) - 1 >= 0)
                        {
                            beforLevel = p_header.Levels[p_header.Levels.IndexOf(level) - 1];
                        }
                        Row nextRow = null;
                        if (i < allHeaderData.Count - 1)
                        {
                            nextRow = allHeaderData[i + 1];
                        }
                        //最后一行(列) 或者 下一行(列)层值与当前行层值不同 创建小计
                        if (nextRow == null || (beforLevel != null && curRow.Str(beforLevel.Field) != nextRow.Str(beforLevel.Field)))
                        {
                            foreach (RptMtxSubtotal total in level.SubTotals)
                            {
                                CreateTotalInst(level.SubTotals, p_header, p_matInst, curRow, p_rptData, TotalLocation.After);
                            }
                        }
                    }
                }
                preRow = curRow;
            }
        }