예제 #1
0
        private void mnu_GroupTasks_Click(object sender, EventArgs e)
        {
            frmAddTask fat = new frmAddTask();
            fat.Default();
            if (fat.ShowDialog() == DialogResult.OK)
            {
                string datetime = string.Empty;
                switch (fat.cb_TaskType.SelectedIndex)
                {
                    case 0:
                        datetime = "每日;" + fat.mtxt_Time.Text;
                        break;
                    case 1:
                        datetime = fat.dt_Date.Value.Date.ToShortDateString() + ";" + fat.mtxt_Time.Text;
                        break;

                    //default:
                    //    datetime="每日;"+fat.mtxt_Time.Text;
                    //    break;
                }
                foreach (DevListViewItem mlvi in lv_Items.Items)
                {
                    DBTasks.DBTasksInsert(mlvi.Tag.ToString(), fat.cb_TaskType.Text, datetime, fat.cb_Action.Text);
                }
                LoadTasks();
            }
        }
예제 #2
0
        /// <summary>
        /// 任务修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mnu_modifyTask_Click(object sender, EventArgs e)
        {
            if (lv_TaskMgr.SelectedItems.Count > 0)
            {

                frmAddTask fat = new frmAddTask();
                string[] dt = lv_TaskMgr.SelectedItems[0].SubItems[1].Text.Split(';');
                if (dt[0] != "每日")
                {
                    fat.dt_Date.Value = Convert.ToDateTime(dt[0]);
                }

                fat.mtxt_Time.Text = dt[1];
                if (lv_TaskMgr.SelectedItems[0].SubItems[2].Text == "每日执行")
                {
                    fat.cb_TaskType.SelectedIndex = 0;
                }
                else
                {
                    fat.cb_TaskType.SelectedIndex = 1;
                }
                int index = 0;
                switch (lv_TaskMgr.SelectedItems[0].SubItems[3].Text)
                {
                    case "启动":
                        index = 0;
                        break;
                    case "关闭":
                        index = 1;
                        break;
                    case "状态翻转":
                        index = 2;
                        break;
                }
                fat.cb_Action.SelectedIndex = index;

                if (fat.ShowDialog() == DialogResult.OK)
                {
                    string datetime = string.Empty;
                    switch (fat.cb_TaskType.SelectedIndex)
                    {
                        case 0:
                            datetime = "每日;" + fat.mtxt_Time.Text;
                            break;
                        case 1:
                            datetime = fat.dt_Date.Value.Date.ToShortDateString() + ";" + fat.mtxt_Time.Text;
                            break;
                        default:
                            datetime = "每日;" + fat.mtxt_Time.Text;
                            break;
                    }
                    DBTasks.DBTasksUPdate(fat.cb_TaskType.Text, datetime, fat.cb_Action.Text, lv_TaskMgr.SelectedItems[0].Tag.ToString());
                    LoadTasks();
                }
            }
            else
            {
                MessageBox.Show("请选择你要修改的任务!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }