private void RemoveBtn_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { MessageHelper.ShowWarning("请选择任务列表中的任一任务删除!"); return; } int iRow = dataGridView1.SelectedRows[0].Index; if (iRow >= 0) { string taskName = dataGridView1.Rows[iRow].Cells[0].Value.ToString(); string taskRunformName = dataGridView1.Rows[iRow].Cells[1].Value.ToString(); if (VisionTaskManger.RemoveTaskInfo(taskName)) { MessageHelper.ShowWarning("删除任务成功!"); } else { MessageHelper.ShowWarning("删除任务失败!"); } } TaskNameTxt.Clear(); TaskDescriptionTxt.Clear(); }
private void ModifyBtn_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { MessageHelper.ShowWarning("请选择任务列表中的任务再修改!"); return; } int iRow = dataGridView1.SelectedRows[0].Index; if (iRow >= 0) { if (dataGridView1.Rows[iRow].Cells[0].Value == null || dataGridView1.Rows[iRow].Cells[1].Value == null) { return; } string taskName = dataGridView1.Rows[iRow].Cells[0].Value.ToString(); string taskRunformName = dataGridView1.Rows[iRow].Cells[1].Value.ToString(); string taskDescription = string.Empty; if (dataGridView1.Rows[iRow].Cells[2].Value != null) { taskDescription = dataGridView1.Rows[iRow].Cells[2].Value.ToString(); } VisionTaskManger.RemoveTaskInfo(taskName); if (!string.IsNullOrEmpty(TaskNameTxt.Text) && TaskRunFormCombox.SelectedItem != null) { VisionTaskInfo info = new VisionTaskInfo() { TaskName = TaskNameTxt.Text.Trim(), TaskRunFormName = TaskRunFormCombox.SelectedItem.ToString() }; if (!string.IsNullOrEmpty(TaskDescriptionTxt.Text)) { info.TaskDescription = TaskDescriptionTxt.Text; } if (VisionTaskManger.AddTaskInfo(info)) { dataGridView1.Rows[iRow].Cells[0].Value = TaskNameTxt.Text; dataGridView1.Rows[iRow].Cells[1].Value = TaskRunFormCombox.Text; dataGridView1.Rows[iRow].Cells[1].Value = TaskDescriptionTxt.Text; TaskNameTxt.Clear(); TaskDescriptionTxt.Clear(); MessageHelper.ShowTips("修改任务成功!"); return; } } VisionTaskManger.AddTaskInfo(new VisionTaskInfo() { TaskName = taskName, TaskRunFormName = taskRunformName, TaskDescription = taskDescription }); MessageHelper.ShowWarning("修改任务失败!"); } TaskNameTxt.Clear(); TaskDescriptionTxt.Clear(); }