Inheritance: System.Windows.Forms.UserControl
コード例 #1
0
        private int DeleteTimedEvent(TimedEvent te)
        {
            int result = 0;
            try
            {
                result = _data.DeleteTimedEvent(te.Id);
                if (result == 0)
                {
                    MessageBox.Show("删除定时事件失败");
                    return result;
                }

                if (list_TimedEvent.Contains(te))
                {
                    list_TimedEvent.Remove(te);
                }
                panelTimedList.Controls.Clear();
                if (list_TimedEvent.Count > 0)
                {
                    foreach (TimedEvent item in list_TimedEvent)
                    {
                        iTimer itimer = new iTimer(item);
                        itimer.Dock = DockStyle.Top;
                        itimer.iTimerhandler += new iTimer.iTimerHandler(DeleteTimedEvent);
                        panelTimedList.Controls.Add(itimer);
                    }
                }
            }
            catch (Exception ex)
            {
                log.WriteLog(ex.ToString());
            }
            return result;
        }
コード例 #2
0
        private void LoadTimedEvents()
        {
            try
            {
                ResetTimedEventCondition();
                _data.DeleteTimedEvent(-1);//删除仅执行一次的过期定时事件
                table_TimedEvents = new DataTable();
                table_TimedEvents = _data.GetTimedEvents();
                panelTimedList.Controls.Clear();
                list_TimedEvent.Clear();
                if (table_TimedEvents != null && table_TimedEvents.Rows.Count > 0)
                {
                    foreach (DataRow dr in table_TimedEvents.Rows)
                    {
                        TimedEvent te = new TimedEvent();
                        te.Id = int.Parse(dr["Id"].ToString());
                        te.Frequency = dr["Frequency"].ToString();
                        te.Time = DateTime.Parse(dr["Time"].ToString());;
                        te.ExecEvents = dr["ExecEvents"].ToString();
                        te.FilePath = dr["FilePath"].ToString();

                        iTimer itimer = new iTimer(te);
                        itimer.Dock = DockStyle.Top;
                        itimer.iTimerhandler += new iTimer.iTimerHandler(DeleteTimedEvent);
                        panelTimedList.Controls.Add(itimer);
                        if (!list_TimedEvent.Contains(te)) list_TimedEvent.Add(te);
                    }
                }
            }
            catch (Exception ex)
            {
                log.WriteLog(ex.ToString());
            }
        }