/// <summary>
/// 将DataSet个数补全至count个(日期或时间类型)
/// </summary>
/// <param name="ds">数据源</param>
/// <param name="count">要求补全的个数</param>
/// <param name="field">判断字段</param>
/// <param name="startValue">起始值</param>
/// <param name="jTimeType">时间类型(yyyy/MM/dd/hh/mm/ss)</param>
/// <returns></returns>
public static DataSet FullDataSet(DataSet ds, int count, string field, string startValue, string jTimeType)
{
if (ds.Tables.Count <= 0)
return null;
DataSet dsTemp = null;
DateTime time = Convert.ToDateTime(startValue+" 00:00:00");
dsTemp = ds.Clone();
for (int i = 0; i <= count; i++)
{
DateTime endTime = Convert.ToDateTime("2012-12-25 00:00:00");
if (jTimeType == "hh")
{
endTime = time.AddHours(1);
}
if (jTimeType == "dd")
{
endTime = time.AddDays(1);
}
if (jTimeType == "mm")
{
endTime = time.AddMinutes(15);
}
DataRow[] rows = ds.Tables[0].Select(field + ">='" + time + "' and " + field + "<'" + endTime + "'", field);
if (rows.Length > 0)
{
dsTemp.Tables[0].Rows.Add(rows[0].ItemArray);
}
else
{
DataRow drow = dsTemp.Tables[0].NewRow();
drow[field] = time;
dsTemp.Tables[0].Rows.Add(drow);
}
time = endTime;
}
return dsTemp;
}