/// <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; } } } }
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); }