Exemplo n.º 1
0
        public override void Undo(object p_args)
        {
            SubTotalCmdArgs args   = (SubTotalCmdArgs)p_args;
            RptMtxLevel     pLevel = args.Parent as RptMtxLevel;
            RptMtxSubtotal  total  = args.SubTotal;
            RptMatrix       mtx    = pLevel.Matrix;

            total.TotalLoc = total.TotalLoc == TotalLocation.After ? TotalLocation.Before : TotalLocation.After;
            if (pLevel != null)
            {
                if (pLevel.Parent is RptMtxRowHeader)
                {
                    mtx.Rows.RemoveRange(args.CurIndex, args.OpsRows.Count);
                    mtx.Rows.InsertRange(args.BefIndex, args.OpsRows);
                }
                else
                {
                    foreach (RptMtxRow row in args.OpsCells.Keys)
                    {
                        row.Cells.RemoveRange(args.CurIndex, args.OpsCells[row].Count);
                        row.Cells.InsertRange(args.BefIndex, args.OpsCells[row]);
                    }
                }
            }
            mtx.Update(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 删除对应数据
 /// </summary>
 /// <param name="p_args"></param>
 /// <param name="p_headerType"></param>
 /// <param name="p_mat"></param>
 /// <param name="p_total"></param>
 void DelRows(SubTotalCmdArgs p_args, RptMtxHeaderType p_headerType, RptMatrix p_mat, RptMtxSubtotal p_total)
 {
     if (p_total.Parent is RptMtxLevel || (p_total.Parent as RptMtxSubtotal).SubTotals.Count > 1)
     {
         if (p_headerType == RptMtxHeaderType.Row)
         {
             int index = -1;
             List <RptMtxRow> opsRows = p_total.GetRptRows(out index);
             if (opsRows != null)
             {
                 p_args.OpsRows  = opsRows;
                 p_args.CurIndex = index;
                 p_mat.Rows.RemoveRange(index, p_total.RowSpan);
             }
         }
         else
         {
             int index = -1;
             Dictionary <RptMtxRow, List <RptText> > opsCells = p_total.GetRptCells(out index);
             if (opsCells != null)
             {
                 foreach (RptMtxRow row in opsCells.Keys)
                 {
                     row.Cells.RemoveRange(index, p_total.ColSpan);
                 }
                 p_args.CurIndex = index;
                 p_args.OpsCells = opsCells;
             }
         }
     }
 }
Exemplo n.º 3
0
        public override void Undo(object p_args)
        {
            SubTotalCmdArgs args  = (SubTotalCmdArgs)p_args;
            RptMtxSubtotal  total = args.SubTotal;
            RptMatrix       mtx   = total.Level.Matrix;

            total.Span = args.OldSpan;
            mtx.Update(true);
        }
Exemplo n.º 4
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs args  = (SubTotalCmdArgs)p_args;
            RptMtxSubtotal  total = args.SubTotal;
            RptMatrix       mtx   = total.Level.Matrix;

            args.OldSpan = total.Span;
            total.Span   = args.NewSpan;
            mtx.Update(true);
            return(null);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs  args       = (SubTotalCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxSubtotal   total      = args.SubTotal;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMatrix        mtx        = null;

            args.InitData();
            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                if (pLevel.Parent is RptMtxRowHeader)
                {
                    headerType = RptMtxHeaderType.Row;
                }
                DelRows(args, headerType, mtx, total);
                args.TotalIndex = pLevel.SubTotals.IndexOf(total);
                pLevel.SubTotals.Remove(total);
            }
            else
            {
                RptMtxSubtotal pTotal = parent as RptMtxSubtotal;
                mtx = pTotal.Level.Matrix;
                if (pTotal.Level.Parent is RptMtxRowHeader)
                {
                    headerType = RptMtxHeaderType.Row;
                }
                DelRows(args, headerType, mtx, total);
                args.TotalIndex = pTotal.SubTotals.IndexOf(total);
                pTotal.SubTotals.Remove(total);
            }
            mtx.Update(true);
            return(total);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        public override object Execute(object p_args)
        {
            SubTotalCmdArgs args   = (SubTotalCmdArgs)p_args;
            RptMtxLevel     pLevel = args.Parent as RptMtxLevel;
            RptMtxSubtotal  total  = args.SubTotal;
            RptMatrix       mtx    = pLevel.Matrix;

            if (pLevel != null)
            {
                int count    = 0;
                int newIndex = 0;
                int index    = 0;
                if (pLevel.Parent is RptMtxRowHeader)
                {
                    args.OpsRows = total.GetRptRows(out index);
                    mtx.Rows.RemoveRange(index, args.OpsRows.Count);
                    if (total.TotalLoc == TotalLocation.Before)
                    {
                        count = (from c in pLevel.SubTotals
                                 where c.TotalLoc == total.TotalLoc &&
                                 pLevel.SubTotals.IndexOf(c) >= pLevel.SubTotals.IndexOf(total)
                                 select c).Count();
                        newIndex = pLevel.Row - count - (mtx.Row + mtx.ColHeader.RowSpan);
                    }
                    else
                    {
                        count = (from c in pLevel.SubTotals
                                 where c.TotalLoc == total.TotalLoc &&
                                 pLevel.SubTotals.IndexOf(c) < pLevel.SubTotals.IndexOf(total)
                                 select c).Count();
                        newIndex = pLevel.Row + pLevel.RowSpan + count - (mtx.Row + mtx.ColHeader.RowSpan);
                    }
                    mtx.Rows.InsertRange(newIndex, args.OpsRows);
                }
                else
                {
                    args.OpsCells = total.GetRptCells(out index);
                    foreach (RptMtxRow row in args.OpsCells.Keys)
                    {
                        row.Cells.RemoveRange(index, args.OpsCells[row].Count);
                        if (total.TotalLoc == TotalLocation.Before)
                        {
                            count = (from c in pLevel.SubTotals
                                     where c.TotalLoc == total.TotalLoc &&
                                     pLevel.SubTotals.IndexOf(c) >= pLevel.SubTotals.IndexOf(total)
                                     select c).Count();
                            newIndex = pLevel.Col - count - (mtx.Col + mtx.RowHeader.ColSpan);
                        }
                        else
                        {
                            count = (from c in pLevel.SubTotals
                                     where c.TotalLoc == total.TotalLoc &&
                                     pLevel.SubTotals.IndexOf(c) < pLevel.SubTotals.IndexOf(total)
                                     select c).Count();
                            newIndex = pLevel.Col + pLevel.ColSpan + count - (mtx.Col + mtx.RowHeader.ColSpan);
                        }
                        row.Cells.InsertRange(newIndex, args.OpsCells[row]);
                    }
                }
                args.BefIndex = index;
                args.CurIndex = newIndex;
            }
            mtx.Update(true);
            return(null);
        }