protected void SaveButton_Click(object sender, EventArgs e) { if (this.ObjectID.HasValue) { Course obj = CourseLogic.GetByID(this.DataContext, this.ObjectID.Value); obj.SemesterID = int.Parse(this.SemesterField.SelectedValue); obj.TeacherID = int.Parse(this.TeacherField.SelectedValue); obj.Number = this.NumberField.Text; obj.Name = this.NameField.Text; obj.Status = (DataAccess.CourseStatus)Enum.Parse(typeof(DataAccess.CourseStatus), this.CourseStatusField.SelectedValue); this.DataContext.AcceptAllChanges(); OnSaved(obj); } else { Course obj = CourseLogic.CreateCourse(this.DataContext, int.Parse(this.SemesterField.SelectedValue), int.Parse(this.TeacherField.SelectedValue), this.NumberField.Text, this.NameField.Text, (DataAccess.CourseStatus)Enum.Parse(typeof(DataAccess.CourseStatus), this.CourseStatusField.SelectedValue)); this.DataContext.AcceptAllChanges(); OnSaved(obj); } }