예제 #1
0
 private void DeleteReminder(Reminder dReminder)
 {
     try
     {
         _data.DeleteReminderById(dReminder.ReminderId);
         if (dic_Reminder.ContainsKey(dReminder.ReminderTime))
         {
             dic_Reminder.Remove(dReminder.ReminderTime);
         }
         if (dic_Reminder.Count > 0)
         {
             panelReminderList.Controls.Clear();
             foreach (Reminder item in dic_Reminder.Values)
             {
                 iReminder ireminder = new iReminder(item);
                 ireminder.Dock = DockStyle.Top;
                 ireminder.Reminderhandler += new iReminder.ReminderHandler(DeleteReminder);
                 panelReminderList.Controls.Add(ireminder);
             }
         }
         else
         {
             panelReminderList.Controls.Clear();
         }
     }
     catch (Exception ex)
     {
         log.WriteLog(ex.ToString());
     }
 }
예제 #2
0
        private void LoadReminder()
        {
            try
            {
                DateTime now = DateTime.Now;
                dateTimeBeginTime.Value = now.AddMinutes(5);
                txtInfo.Text = "";

                _data.DeleteReminderExpired(now);//删除过期提醒
                table_Reminder = _data.GetReminders(now);
                if (table_Reminder != null && table_Reminder.Rows.Count > 0)
                {
                    panelReminderList.Controls.Clear();
                    foreach (DataRow dr in table_Reminder.Rows)
                    {
                        Reminder rem = new Reminder();
                        rem.ReminderId = int.Parse(dr["Id"].ToString());
                        rem.ReminderTime = DateTime.Parse(dr["Time"].ToString());;
                        rem.ReminderInfo = dr["Info"].ToString();
                        iReminder ireminder = new iReminder(rem);
                        ireminder.Dock = DockStyle.Top;
                        ireminder.Reminderhandler += new iReminder.ReminderHandler(DeleteReminder);
                        panelReminderList.Controls.Add(ireminder);
                        if (!dic_Reminder.ContainsKey(rem.ReminderTime))
                        {
                            dic_Reminder.Add(rem.ReminderTime, rem);
                        }

                    }
                }
                else
                {
                    panelReminderList.Controls.Clear();
                }
            }
            catch (Exception ex)
            {
                log.WriteLog(ex.ToString());
            }
        }