private DataTable GetDataTable(int spClientId, int spClientGroupId) { DataTable dt = null; if (spClientId > 0) { dt = SPDayReportWrapper.GetTodayReportByClientID(spClientId); } else { dt = SPDayReportWrapper.GetTodayReportByClientGroupID(spClientGroupId); } DataTable table = new DataTable(); table.Columns.AddRange(new DataColumn[] { new DataColumn("CHour") { ColumnName = "CHour", DataType = typeof(string) }, new DataColumn("Count") { ColumnName = "Count", DataType = typeof(int) } }); int chour = System.DateTime.Now.Hour; for (int i = 0; i <= chour; i++) { DataRow[] drs; drs = dt.Select(string.Format(" CHour = {0} ", i)); int count = 0; if (drs.Length > 0) { foreach (DataRow dataRow in drs) { count += Convert.ToInt32(dataRow["Total"]); } } table.Rows.Add(new object[] { i.ToString("D2") + ":00", count.ToString() }); } return(table); }