Exemplo n.º 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab == taskTabPage)
            {
                //get task name
                Add input = new Add();
                input.ShowDialog();
                string task;
                if (input.s != null)
                {
                    task = isSameName(input.s);

                    //AddTask();
                    UserOperation.GetInstance().Add("ADD_TASK", task);
                    if (UserOperation.GetInstance().count() == 1)
                    {
                        long id = IDGenerator.generateID();
                        if (MainFormController.AddTask(task, id))
                        {
                            UserOperation.GetInstance().Remove();
                            TreeNode node = new TreeNode();
                            node.Text = task;
                            node.Tag  = id;
                            taskTreeView.Nodes.Add(node);
                        }
                    }
                }
            }
            if (tabControl1.SelectedTab == ePlanTabPage)
            {
                //get plan name
                Add input = new Add();
                input.ShowDialog();

                //AddPlan();
                string plan;
                if (input.s != null)
                {
                    plan = isSameName(input.s);

                    UserOperation.GetInstance().Add("ADD_EPLAN", plan);
                    if (UserOperation.GetInstance().count() == 1)
                    {
                        long id = IDGenerator.generateID();
                        if (MainFormController.AddPlan(plan, id))
                        {
                            UserOperation.GetInstance().Remove();
                            TreeNode node = new TreeNode();
                            node.Text = plan;
                            node.Tag  = id;
                            planTreeView.Nodes.Add(node);
                        }
                    }
                }
            }
        }