/* * NAME * * Conference_Form::Edit_Note_Click - event that triggers when the user clicks the Edit Note button. * * SYNOPSIS * * void Edit_Note_Click(object sender, EventArgs e); * * sender --> the object sending the event. * e --> the event arguments. * * DESCRIPTION * * This function triggers when the user clicks the Edit Note button. * First, it verifies that the user has selected a note from the view. * It creates a note object and sends it to a form to edit the note. */ private void Edit_Note_Click(object sender, EventArgs e) { //If nothing selected, pop-up message if (notes.SelectedItems.Count == 0) { MessageBox.Show("Please select a note to edit"); return; } Note edit_note = new Note(); ListViewItem item = notes.SelectedItems[0]; edit_note.id = Convert.ToInt32(item.SubItems[0].Text); edit_note.student_id = Convert.ToInt32(item.SubItems[1].Text); edit_note.date = item.SubItems[2].Text; edit_note.note = item.SubItems[3].Text; edit_note.category = item.SubItems[4].Text; using (New_Note_Form edit = new New_Note_Form()) { edit.Note = edit_note.note; if (edit.ShowDialog() == DialogResult.OK) { Database_Interface.Update_Note(edit_note.id, edit.Note, new Conference_Types(edit.Category).Type); } } Refresh_Notes(); }
/* * NAME * * Conference_Form::Add_Note_Click - event that triggers when the user clicks the Add Note button. * * SYNOPSIS * * void Add_Note_Click(object sender, EventArgs e); * * sender --> the object sending the event. * e --> the event arguments. * * DESCRIPTION * * This function triggers when the user clicks the Add Note button. * The function first verifies that a student has been selected. * Then, the function creates a new note and sends it to the database. */ private void Add_Note_Click(object sender, EventArgs e) { if (!(Student_Select.SelectedIndex > -1)) { MessageBox.Show("Please select a student.", "Error"); return; } using (New_Note_Form new_note = new New_Note_Form()) { if (new_note.ShowDialog() == DialogResult.OK) { string category = new Conference_Types(new_note.Category).Type; Database_Interface.Add_Note(current_student_id, new_note.Note, category); } } Refresh_Notes(); }