예제 #1
0
        public override void Undo(object p_args)
        {
            SubTotalCmdArgs args   = (SubTotalCmdArgs)p_args;
            RptMtxSubtotal  total  = args.SubTotal;
            RptItemBase     parent = args.Parent;
            RptMatrix       mtx    = null;

            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                args.BackMtxRow();
                pLevel.SubTotals.Insert(args.TotalIndex, total);
            }
            else
            {
                RptMtxSubtotal pTotal = parent as RptMtxSubtotal;
                mtx = pTotal.Level.Matrix;
                args.BackMtxRow();
                pTotal.SubTotals.Insert(args.TotalIndex, total);
            }
            mtx.Update(true);
        }
예제 #2
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs  args       = (SubTotalCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMtxSubtotal   total      = args.SubTotal;
            RptMatrix        mtx        = null;

            if (total == null)
            {
                total = new RptMtxSubtotal(parent);
                args.InitData();
                if (parent is RptMtxLevel)
                {
                    RptMtxLevel pLevel = parent as RptMtxLevel;
                    mtx = pLevel.Matrix;
                    if (pLevel.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    total.Item.Val = string.Format("subtotal{0}", mtx.GetMaxTotal());
                    int curIndex = 0;
                    if (headerType == RptMtxHeaderType.Row)
                    {
                        curIndex = pLevel.Row;
                        if (!mtx.HideRowHeader && !mtx.HideColHeader)
                        {
                            curIndex -= (mtx.Corner.Row + mtx.Corner.RowSpan);
                        }
                        args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                    }
                    else
                    {
                        curIndex = pLevel.Col - mtx.Rows[0].Col;
                        foreach (RptMtxRow row in mtx.Rows)
                        {
                            args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                        }
                    }
                    args.CurIndex = curIndex;
                }
                else
                {
                    RptMtxSubtotal pTotal = parent as RptMtxSubtotal;
                    mtx = pTotal.Level.Matrix;
                    if (pTotal.Level.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    total.Item.Val = string.Format("subtotal{0}", mtx.GetMaxTotal());
                    if (pTotal.SubTotals.Count > 0)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            curIndex = pTotal.Row + pTotal.GetCount();
                            if (!mtx.HideColHeader && !mtx.HideRowHeader)
                            {
                                curIndex -= (mtx.Corner.Row + mtx.Corner.RowSpan);
                            }
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            curIndex = pTotal.Col - mtx.Rows[0].Col + pTotal.GetCount();
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                }
            }
            else
            {
                mtx = total.Level.Matrix;
                args.BackMtxRow();
            }
            if (parent is RptMtxLevel)
            {
                (parent as RptMtxLevel).SubTotals.Add(total);
            }
            else
            {
                (parent as RptMtxSubtotal).SubTotals.Add(total);
            }
            args.SubTotal = total;
            mtx.Update(true);
            return(total);
        }