示例#1
0
        void AddCourseToSection_Click(object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;
            NodeData nodeData = item.Tag as NodeData;

            EditCourse editCourse = new EditCourse();
            editCourse.CourseName = "";
            editCourse.ShortName = "";
            editCourse.Identifier = "";
            editCourse.Instructor = "";
            editCourse.Description = "";

            if (editCourse.ShowDialog(this) == DialogResult.OK)
            {
                Course course = new Course();
                course.Name = editCourse.CourseName;
                course.ShortName = editCourse.ShortName;
                course.Identifier = editCourse.Identifier;
                course.Instructor = editCourse.Instructor;
                course.Description = editCourse.Description;

                string newHandle = _iTunes.AddCourse(nodeData.Handle, course);

                // create new tree node
                TreeNode courseNode = new TreeNode();
                courseNode.Text = course.Name;
                courseNode.Tag = new NodeData("Course", newHandle, courseNode);

                nodeData.TreeNode.Nodes.Add(courseNode);
                nodeData.TreeNode.Expand();
            }

            editCourse.Dispose();
        }
示例#2
0
        void EditCourse_Click(object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;
            NodeData nodeData = item.Tag as NodeData;

            Course course = _iTunes.GetCourse(nodeData.Handle);

            EditCourse editCourse = new EditCourse();
            editCourse.CourseName = course.Name;
            editCourse.ShortName = course.ShortName;
            editCourse.Identifier = course.Identifier;
            editCourse.Instructor = course.Instructor;
            editCourse.Description = course.Description;

            if (editCourse.ShowDialog(this) == DialogResult.OK)
            {
                course.Name = editCourse.CourseName;
                course.ShortName = editCourse.ShortName;
                course.Identifier = editCourse.Identifier;
                course.Instructor = editCourse.Instructor;
                course.Description = editCourse.Description;

                _iTunes.MergeCourse(nodeData.Handle, course);

                nodeData.TreeNode.Text = course.Name;
                nodeData.TreeNode.Expand();
            }

            editCourse.Dispose();
        }