private void timer_countdown_Tick(object sender, EventArgs e) { if (countdownList.Count < 1) { timer_countdown.Stop(); } String now = System.DateTime.Now.ToString("HH:mm:ss"); //MessageBox.Show(now); for (int i = 0; i < countdownList.Count; i++) { String compareDate = DateTime.Parse(countdownList[i]).ToString("HH:mm:ss"); if (compareDate.CompareTo(now) == 0) { countdownList.RemoveAt(i); Utils.myRemindState = (int)Utils.remindState.NoAction; Form_Shaking fs = new Form_Shaking(); fs.ShowDialog(); //延迟一小时 if (Utils.myRemindState == (int)Utils.remindState.DelayOneHour) { //生成新的时间 延迟一小时 DataTable oriTable = Utils.dbs.GetCon(countdownID[i]); String oriDateTime = oriTable.Rows[0][1].ToString(); String[] oriDateSplit = oriDateTime.Split(' '); String[] oriTimeSplit = oriDateSplit[1].Split(':'); int newHour = int.Parse(oriTimeSplit[0]); newHour++; if (newHour < 24) { String newDateTime = oriDateSplit[0] + " " + newHour + ":" + oriTimeSplit[1] + ":" + oriTimeSplit[2]; try { if (!Utils.dbs.UpdateOneTime(countdownID[i],newDateTime)) { MessageBox.Show("更改失败"); } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } } } //延迟一天 if (Utils.myRemindState == (int)Utils.remindState.DelayOneDay) { //生成新的时间 延迟一天 DataTable oriTable = Utils.dbs.GetCon(countdownID[i]); String oriDateTime = oriTable.Rows[0][1].ToString(); String[] oriTimeSplit = oriDateTime.Split(' '); String[] oriDateSplit = oriTimeSplit[0].Split('/'); int oriDay = int.Parse(oriDateSplit[2]); oriDay++; String newDateTime = oriDateSplit[0] + "/" + oriDateSplit[1] + "/" + oriDay + " " + oriTimeSplit[1]; //此处无日期的正确性验证 try { if (!Utils.dbs.UpdateOneTime(countdownID[i], newDateTime)) { MessageBox.Show("更改失败"); } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } } FreshItem(); break; } } }
private void timer_countdown_Tick(object sender, EventArgs e) { if (countdownList.Count < 1) { timer_countdown.Stop(); } String now = System.DateTime.Now.ToString("HH:mm:ss"); //MessageBox.Show(now); for (int i = 0; i < countdownList.Count; i++) { String compareDate = DateTime.Parse(countdownList[i]).ToString("HH:mm:ss"); if (compareDate.CompareTo(now) == 0) { countdownList.RemoveAt(i); Utils.myRemindState = (int)Utils.remindState.NoAction; Form_Shaking fs = new Form_Shaking(); fs.ShowDialog(); //延迟一小时 if (Utils.myRemindState == (int)Utils.remindState.DelayOneHour) { //生成新的时间 延迟一小时 DataTable oriTable = Utils.dbs.GetCon(countdownID[i]); String oriDateTime = oriTable.Rows[0][1].ToString(); String[] oriDateSplit = oriDateTime.Split(' '); String[] oriTimeSplit = oriDateSplit[1].Split(':'); int newHour = int.Parse(oriTimeSplit[0]); newHour++; if (newHour < 24) { String newDateTime = oriDateSplit[0] + " " + newHour + ":" + oriTimeSplit[1] + ":" + oriTimeSplit[2]; try { if (!Utils.dbs.UpdateOneTime(countdownID[i], newDateTime)) { MessageBox.Show("更改失败"); } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } } } //延迟一天 if (Utils.myRemindState == (int)Utils.remindState.DelayOneDay) { //生成新的时间 延迟一天 DataTable oriTable = Utils.dbs.GetCon(countdownID[i]); String oriDateTime = oriTable.Rows[0][1].ToString(); String[] oriTimeSplit = oriDateTime.Split(' '); String[] oriDateSplit = oriTimeSplit[0].Split('/'); int oriDay = int.Parse(oriDateSplit[2]); oriDay++; String newDateTime = oriDateSplit[0] + "/" + oriDateSplit[1] + "/" + oriDay + " " + oriTimeSplit[1]; //此处无日期的正确性验证 try { if (!Utils.dbs.UpdateOneTime(countdownID[i], newDateTime)) { MessageBox.Show("更改失败"); } } catch (System.Exception ex) { MessageBox.Show(ex.ToString()); } } FreshItem(); break; } } }