/// <summary> /// handles click event for edit button in manage mode. /// allows user to change name of course. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editToolStripMenuItem_Click(object sender, EventArgs e) { //get our selected course CourseData selectedCourse = (CourseData)lvwCourses.SelectedItems[0].Tag; //prompt user for new name string courseName = ""; var result = HelperUI.InputBox("Renaming " + selectedCourse.Name, "Enter new name of course", ref courseName); //determine if user pressed okay if (result == DialogResult.OK) { //change name selectedCourse.Name = courseName; lvwCourses.SelectedItems[0].Text = courseName; //save it to database CourseController.SaveCourse(selectedCourse); } }
/// <summary> /// handles add course button click. allows user to add a new course. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addToolStripMenuItem_Click(object sender, EventArgs e) { //prompt user for name of new course string courseName = ""; var result = HelperUI.InputBox("New Course", "Enter name of course", ref courseName); //if user selected okay if (result == DialogResult.OK) { //add to database CourseData courseToAdd = new CourseData(); courseToAdd.Name = courseName; CourseController.SaveCourse(courseToAdd); CourseController.AddUser(courseToAdd, GlobalData.currentUser); //add to list ListViewItem item = lvwCourses.Items.Add(courseToAdd.Name, 0); item.Tag = courseToAdd; } }
/// <summary> /// Handles add button click event. /// Allows user to add a quiz to the current selected course /// </summary> private void addToolStripMenuItem_Click(object sender, EventArgs e) { //prompt user for name string quizName = ""; var result = HelperUI.InputBox("", "Enter name of quiz", ref quizName); //if user selected ok if (result == DialogResult.OK) { //go to edit this quiz //create new quiz with specified name QuizData quizToAdd = new QuizData(); quizToAdd.Name = quizName; //set global variable GlobalData.currentQuiz = quizToAdd; //go to quiz view to edit quiz GlobalData.currentScreen.DisplayView(new QuizView(myObjective)); this.Dispose(); } }