예제 #1
0
        //Save activity
        private void btnSavePjan_Click(object sender, EventArgs e)
        {
            Activity newActivity = null;

            if (cbxProjectsPjan.SelectedIndex >= 0)
            {
                //get the selected project
                Project selectedProject = null;
                foreach (Project project in MyApplicationContext.Projects)
                {
                    if (project.name == cbxProjectsPjan.SelectedItem.ToString())
                    {
                        selectedProject = project;
                        break;
                    }
                }

                if (cbxCategoryPjan.SelectedIndex >= 0)
                {
                    //get the selected category
                    ProjectCategory selectedCategory = null;
                    foreach (ProjectCategory category in selectedProject.Categories)
                    {
                        if (category.name == cbxCategoryPjan.SelectedItem.ToString())
                        {
                            selectedCategory = category;
                            break;
                        }
                    }

                    newActivity = new Activity(tbxActivityPjan.Text, rtbDetailsPjan.Text, selectedProject.index, selectedCategory.index);
                }
                else
                {
                    newActivity = new Activity(tbxActivityPjan.Text, rtbDetailsPjan.Text, selectedProject.index);
                }
            }
            else
            {
                newActivity = new Activity(tbxActivityPjan.Text, rtbDetailsPjan.Text);
            }

            MyApplicationContext.Activities.Add(newActivity);
            Log.Write("Logged a new Activity: '" + newActivity.name + "'");
            this.DialogResult = DialogResult.OK;
        }
예제 #2
0
        //Add Category
        private void btnAddPjan_Click(object sender, EventArgs e)
        {
            foreach (ProjectCategory category in project.Categories)
            {
                if (category.name == tbxNamePjan.Text)
                {
                    MessageBox.Show("That Category name already exists");
                    return;
                }
            }
            if (tbxNamePjan.Text == "")
            {
                MessageBox.Show("A Category name may not be blank");
                return;
            }
            ProjectCategory newCategory = new ProjectCategory(tbxNamePjan.Text, project);

            project.Categories.Add(newCategory);
            Log.Write("Category added: '" + tbxNamePjan.Text + "'");
            UpdateList();
        }