示例#1
0
        private void OnAddTaskClick(object sender, EventArgs e)
        {
            try
            {
                DlgAddTask adt = new DlgAddTask();
                if (adt.ShowDialog() == DialogResult.OK)
                {
                    BaseNode bn = (BaseNode)this.SelectedNode;
                    TaskNode tn = new TaskNode(adt.Task);
                    bn.Nodes.Add(tn);
                    if (bn.Parent != null && bn.Parent.Nodes.Count > 0)
                    {
                        bn.Parent.Expand();
                    }
                }

                if (this.SelectedNode is BaseNode)
                {
                    BaseNode bn = this.SelectedNode as BaseNode;
                    if (bn != null)
                    {
                        RootNodeEventArgs re = new RootNodeEventArgs();
                        re.Tasks = new Collection<TaskInfo>();
                        foreach (TaskNode tasknode in bn.Nodes)
                        {
                            re.Tasks.Add(tasknode.Task);
                        }
                        OnRootNodeSelected(re);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex);
            }            
        }
示例#2
0
 protected virtual void OnRootNodeSelected(RootNodeEventArgs e)
 {
     if (RootNodeSelectedEvent != null)
         RootNodeSelectedEvent(this, e);
 }
示例#3
0
        private void TaskTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (e.Node is TaskNode)
                {
                    TaskNode tn = e.Node as TaskNode;
                    TaskEventArgs te = new TaskEventArgs();
                    if (tn != null)
                    {
                        te.Task = ConfigCtrl.GetTask(tn.Task.TaskId, tn.Task.TaskName, false);

                        te.Operations = new Collection<OperationInfo>();
                        foreach (AccountInfo account in te.Task.Accounts)
                        {
                            te.Operations.Add(ConfigCtrl.GetOperation(te.Task.GroupName, account));
                        }

                        //te.Task = tn.Task;
                        //te.Operations = new Collection<OperationInfo>();
                        //foreach (OperationNode on in tn.Nodes)
                        //{
                        //    te.Operations.Add(on.Operation);
                        //}
                    }
                    else
                        te.Task = null;
                    OnTaskNodeSelected(te);
                }
                else if (this.SelectedNode is TaskNode)
                {
                    TaskNode tn = this.SelectedNode as TaskNode;
                    TaskEventArgs te = new TaskEventArgs();
                    if (tn != null)
                    {
                        te.Task = tn.Task;
                        te.Operations = new Collection<OperationInfo>();
                        foreach (OperationNode on in tn.Nodes)
                        {
                            te.Operations.Add(on.Operation);
                        }
                    }
                    else
                        te.Task = null;
                    OnTaskNodeSelected(te);
                }
                else if (this.SelectedNode is OperationNode)
                {
                    OperationNode on = this.SelectedNode as OperationNode;
                    OperationEventArgs oe = new OperationEventArgs();
                    if (on != null)
                        oe.Operation = on.Operation;
                    else
                        oe.Operation = null;
                    OnOperationNodeSelected(oe);
                }
                else if (this.SelectedNode is BaseNode)
                {
                    BaseNode bn = this.SelectedNode as BaseNode;
                    if (bn != null)
                    {
                        RootNodeEventArgs re = new RootNodeEventArgs();
                        re.Tasks = new Collection<TaskInfo>();
                        foreach (TaskNode tasknode in bn.Nodes)
                        {
                            re.Tasks.Add(tasknode.Task);
                        }
                        OnRootNodeSelected(re);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex);
            }
        }