Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (Owner != null)
            {
                Left = Owner.Left + 20;
                Top  = Owner.Top + 20;
                if (Left < 0)
                {
                    Left = 0;
                }
                if (Top < 0)
                {
                    Top = 0;
                }
            }

            // 初始化现有的参数值
            switch (m_type)
            {
            case RunType.PerDay:
                colDay.Visible = false;
                lstDays.Items.Add("每天");
                lstDays.Enabled = false;
                break;

            case RunType.PerWeek:
                colDay.HeaderText = "周几运行(0为周日)";
                lstDays.Items.AddRange(new object[] { "每周日", "每周一", "每周二", "每周三", "每周四", "每周五", "每周六" });
                break;

            case RunType.PerMonth:
                colDay.HeaderText = "每月几号运行";
                for (var i = 1; i < 32; i++)
                {
                    lstDays.Items.Add("每月" + i + "号");
                }
                break;

            default:
                return;
            }
            lstDays.SelectedIndex = 0;
            txtTm.Text            = DateTime.Now.ToString("HH:mm");

            string oldVal = Convert.ToString(m_cell.Value).Trim();

            txtResult.Text = oldVal;

            List <TimePara> paras = TaskItem.GetPara(m_type, oldVal);
            DataGridView    dgv   = dataGridView1;

            // 把所有任务绑定到DataGridView
            foreach (TimePara item in paras)
            {
                object[] colValues = new object[COL_NUM];
                colValues[COL_DAY]     = item.WeekOrDay;
                colValues[COL_TIME]    = item.StartHour.ToString("00") + ":" + item.StartMin.ToString("00");
                colValues[COL_RUNMIN]  = item.RunMinute.ToString();
                colValues[COL_ENDTIME] = CountEndTime(item.StartHour, item.StartMin, item.RunMinute);
                colValues[COL_DEL]     = "删除";
                int             i   = dgv.Rows.Add(colValues);
                DataGridViewRow row = dgv.Rows[i];

                // 设置隔行背景色
                SetBackColor(row, false);
            }
        }