Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmCourseEditor editor = new frmCourseEditor();

            if (editor.ShowDialog() == DialogResult.OK)
            {
                Repository.Default.ListCourses.Add(editor.Course);
                this.ViewAllCourses();
            }
        }
Exemplo n.º 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            Course selCourse = this.GetFirstSelectedCourse();

            if (selCourse != null)
            {
                frmCourseEditor editor = new frmCourseEditor(selCourse);
                int             oldId  = selCourse.Id;
                if (editor.ShowDialog() == DialogResult.OK)
                {
                    Course course = Repository.Default.ListCourses.First(x => x.Id == oldId);
                    course.Name      = selCourse.Name;
                    course.StartDate = selCourse.StartDate;
                    course.Duration  = selCourse.Duration;
                    this.ViewAllCourses();
                }
            }
        }