private void deleteNoteButton_Click(object sender, EventArgs e) { if (noteBox.SelectedItem == null || noteBox.SelectedItem.ToString().Contains("(TIMER)")) { return; } noteType type; Note noteToDelete = currentCalendar.findNote(parseNoteContent(noteBox.SelectedItem.ToString(), out type), type); if (Calendar.CanEditOrDelete(noteToDelete) == false) { MessageBox.Show(this, "This note cannot be deleted", "Cannot delete note", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (MessageBox.Show(this, "Are you sure you wish to delete this note?", "Delete note", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { if (noteToDelete.Campaign == null) { currentCalendar.deleteNote(noteToDelete); } else { noteToDelete.Campaign.deleteNote(noteToDelete); } } UpdateCalendar(); }
private void deleteNoteButton_Click(object sender, EventArgs e) { if (campaignTree.SelectedNode.Level != 2 || campaignTree.SelectedNode == null) { MessageBox.Show("Please select the note you wish to delete", "Delete Note", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } noteType type; if (campaignTree.SelectedNode.Parent.Parent.Text == "General Notes") { type = noteType.generalNote; } else { type = noteType.note; } Note noteToDelete = currentCalendar.findNote(campaignTree.SelectedNode.Text, type); if (Calendar.CanEditOrDelete(noteToDelete)) { if (MessageBox.Show("Are you sure you want to delete this note?", "Delete Note", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { currentCalendar.deleteNote(noteToDelete); } } else { MessageBox.Show(this, "This note cannot be deleted.", "Cannot delete note", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } UpdateTree(); }
private void okButton_Click(object sender, EventArgs e) { Campaign notesCampaign; if (alertAll.Checked == false && AlertCampaign.Checked == false && noAlert.Checked == false) { MessageBox.Show("Choose a visibilty level.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (month.Text == "" || day.Text == "" || year.Text == "") { MessageBox.Show("Please enter a valid date.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (editNoteBox.Text == "") { MessageBox.Show("The note must have some content.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (campaignSelector.SelectedItem == null && generalBox.Checked) { notesCampaign = null; } else if (campaignSelector.SelectedItem == null && generalBox.Checked == false) { MessageBox.Show("Please select an associated campaign.\nIf it is a general note, check the general box.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { notesCampaign = currentCalendar.CampaignList.Find(x => x.Tag == campaignSelector.SelectedItem.ToString()); } if (editNote.Campaign == null) { currentCalendar.deleteNote(editNote); } else { editNote.Campaign.deleteNote(editNote); } AlertScope importance = AlertScope.dontAlert; if (alertAll.Checked) { importance = AlertScope.global; } else if (AlertCampaign.Checked) { importance = AlertScope.campaign; } else if (noAlert.Checked) { importance = AlertScope.dontAlert; } currentCalendar.AddNote(new Note(textBoxToDate(), importance, editNoteBox.Text, notesCampaign)); this.Close(); }