/// <summary>
/// 把table表里的某行数据提取出来放到别一个表中,并在原表中删除这行数据
/// </summary>
/// <param name="startDatatable">源表</param>
/// <param name="indexKey">提取行号</param>
/// <returns>返加datatable数组。第一个数组是源表,第二个数组是目标组</returns>
public static DataTable[] CheckDatatable(DataTable startDatatable, int indexKey)
{
DataTable dbdbTongmadeplayfulelementHead = startDatatable.Clone();
int intRowCount = startDatatable.Rows.Count;
if ((intRowCount > 0) && (intRowCount > indexKey))
{
DataRow dr = dbdbTongmadeplayfulelementHead.NewRow();
dr.ItemArray = startDatatable.Rows[indexKey].ItemArray;
dbdbTongmadeplayfulelementHead.Rows.Add(dr);
DataRow tempdatarow = startDatatable.Rows[indexKey];
startDatatable.Rows.Remove(tempdatarow);
startDatatable.AcceptChanges();
return new DataTable[] { startDatatable, dbdbTongmadeplayfulelementHead };
}
else
{
return null;
}
}
/// <summary>
/// 把table表里的某行数据提取出来放到别一个表中,并在原表中删除这些数据
/// </summary>
/// <param name="startDatatable">源表</param>
/// <param name="StartindexKey">起适行号</param>
/// <param name="EndindexKey">结束行号</param>
/// <returns>返加datatable数组。第一个数组是源表,第二个数组是目标组</returns>
public static DataTable[] CheckDatatable(DataTable startDatatable, int StartindexKey, int EndindexKey)
{
DataTable dbdbTongmadeplayfulelementHead = startDatatable.Clone();
int intRowCount = startDatatable.Rows.Count;
if ((intRowCount > 0) && (intRowCount >= StartindexKey) && (intRowCount >= EndindexKey))
{
for (int i = StartindexKey; i <= EndindexKey; i++)
{
DataRow dr = dbdbTongmadeplayfulelementHead.NewRow();
dr.ItemArray = startDatatable.Rows[i].ItemArray;
dbdbTongmadeplayfulelementHead.Rows.Add(dr);
}
int j = 0;
do
{
DataRow tempdatarow = startDatatable.Rows[StartindexKey - j];
startDatatable.Rows.Remove(tempdatarow);
j++;
StartindexKey++;
} while (StartindexKey <= EndindexKey);
startDatatable.AcceptChanges();
return new DataTable[] { startDatatable, dbdbTongmadeplayfulelementHead };
}
else
{
return null;
}
}