日期:2014-05-17 浏览次数:20588 次
DataTable dt = new DataTable(); dt.Columns.Add("collectdata"); dt.Columns.Add("typename"); dt.Columns.Add("collecttime"); dt.Rows.Add(new object[] { "120.00", "收缩压上", "2012/5/11 13:19:45" }); dt.Rows.Add(new object[] { "90.00", "舒张压下", "2012/5/11 13:19:46" }); dt.Rows.Add(new object[] { "34.00", "血糖餐前", "2012/5/11 13:19:47" }); dt.Rows.Add(new object[] { "36.00", "血糖餐后", "2012/5/11 13:19:48" }); dt.Rows.Add(new object[] { "37.50", "体温", "2012/5/11 13:19:49" }); dt.Rows.Add(new object[] { "150.00", "心率", "2012/5/11 13:19:50" }); dt.Rows.Add(new object[] { "180.00", "收缩压上", "2012/5/11 16:30:31" }); dt.Rows.Add(new object[] { "110.00", "舒张压下", "2012/5/11 16:30:31" }); dt.Rows.Add(new object[] { "33.00", "血糖餐前", "2012/5/11 16:30:33" }); dt.Rows.Add(new object[] { "38.00", "血糖餐后", "2012/5/11 16:30:34" }); dt.Rows.Add(new object[] { "39.00", "体温", "2012/5/11 16:30:35" }); dt.Rows.Add(new object[] { "190.00", "心率", "2012/5/11 16:30:36" }); DataTable newDt = new DataTable(); Dictionary<string, int> dicCount = new Dictionary<string, int>(); int index = 1; foreach (DataRow row in dt.Rows) { if (!dicCount.ContainsKey(row["typename"].ToString())) { dicCount.Add(row["typename"].ToString(), index++); } } Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>(); List<string> list; string key = string.Empty; foreach (DataRow row in dt.Rows) { key = Convert.ToDateTime(row["collecttime"]).ToString("yyyy