You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB
C#

using POSV.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace POSV.Component
{
public class MakeMerge
{
public static List<Tuple<ProductMakeType, ProductMakeDetail>> Merge(int rows, int cols, List<Tuple<ProductMakeType, ProductMakeDetail>> dataSource)
{
//移除可能存在的分页标识
dataSource.RemoveAll(x => Constant.PREV_PAGER.Equals(x.Item2.Memo) || Constant.NEXT_PAGER.Equals(x.Item2.Memo));
int pageSize = rows * cols;
int totalCount = dataSource.Count;
//启用分页
int pageCount = ((totalCount - 1) + (pageSize - 2) - 1) / (pageSize - 2);
int offset = 0;
for (int i = 1; i < pageCount; i++)
{
offset += (pageSize - 1);
ProductMakeDetail entity = new ProductMakeDetail();
entity.Memo = Constant.NEXT_PAGER;
entity.Ext3 = (i + 1).ToString();
dataSource.Insert(offset, new Tuple<ProductMakeType, ProductMakeDetail>(null, entity));
offset++;
entity = new ProductMakeDetail();
entity.Memo = Constant.PREV_PAGER;
entity.Ext3 = i.ToString();
dataSource.Insert(offset, new Tuple<ProductMakeType, ProductMakeDetail>(null, entity));
}
return dataSource;
}
}
}