private void GetDeadLineData() { //得到数据库中的数据 Utils.dbs = new DBServer(); // dbs = dt = Utils.dbs.GetAllData(TABLENAME); //int cols = dt.Columns.Count; int rows = dt.Rows.Count; pannelList.RowCount = rows; string textTime = ""; string textContent = ""; int userID; var img = new Bitmap(Utils.getClock_blue()); //获取系统时间 DateTime systemNow = DateTime.Now.Date; //DateTime systemNow = DateTime.Now; countdownList.Clear(); countdownID.Clear(); for (int ri = 0; ri < rows; ri++) { userID = int.Parse(dt.Rows[ri][0].ToString()); textTime = dt.Rows[ri][1].ToString(); textContent = dt.Rows[ri][2].ToString(); //根据时间设置图片 DateTime dtFormat = Convert.ToDateTime(textTime.Substring(0, textTime.IndexOf(" ")+1) + "0:00:00"); //DateTime dtFormat = Convert.ToDateTime(textTime); if (DateTime.Compare(dtFormat, systemNow) > 0) { img = new Bitmap(Utils.getClock_blue()); } else if (DateTime.Compare(dtFormat, systemNow) < 0) { img = new Bitmap(Utils.getClock_red()); } else { img = new Bitmap(Utils.getClock_yellow()); remindSign = true; String nowTime = System.DateTime.Now.ToString("HH:mm:ss"); String compareTime = DateTime.Parse(textTime.Substring(10)).ToString("HH:mm:ss"); if (compareTime.CompareTo(nowTime) > 0) { countdownList.Add(textTime.Substring(10)); countdownID.Add(userID); if (!timer_countdown.Enabled) { timer_countdown.Start(); } } else { img = new Bitmap(Utils.getClock_red()); } } uItem = new UserItem(this) { Image = img, UserID = userID, TextTime = textTime, TextContent = textContent }; userList.Add(uItem); pannelList.Controls.Add(uItem); } }