//Button Add click handler private void btnAdd_Click(object sender, EventArgs e) { if (CheckUpCount() == true) { try { //show Editor dialog frmEditor EditorForm = new frmEditor(); EditorForm.ShowDialog(); //add new data to data-collection if (EditorForm.IsCanceled == false) { Note NewNote = new Note(EditorForm.TextName, EditorForm.TextArray); EncryptedData.AddNote(NewNote); } } catch (OutOfMemoryException Exc) { MessageBox.Show(Exc.ToString()); } catch (ArgumentException Exc) { MessageBox.Show(Exc.ToString()); } //add new record to grid UpdateGrid(); } }
//Button Edit click handler private void btnEdit_Click(object sender, EventArgs e) { if (listView.SelectedIndices.Count > 0) { int SelectedCell = listView.SelectedIndices[0]; if (SelectedCell >= 0 && SelectedCell < EncryptedData.GetNoteCount()) { try { //show Editor dialog frmEditor EditorForm = new frmEditor(); EditorForm.TextArray = EncryptedData.GetNoteText(SelectedCell); EditorForm.TextName = EncryptedData.GetNoteName(SelectedCell); EditorForm.ShowDialog(); //update data EncryptedData.SetNoteAccessDate(SelectedCell, DateTime.Now); if (EditorForm.IsCanceled == false) { if (EditorForm.IsUpdated == true) { EncryptedData.SetNoteUpdateDate(SelectedCell, DateTime.Now); } EncryptedData.SetNoteText(SelectedCell, EditorForm.TextArray); EncryptedData.SetNoteName(SelectedCell, EditorForm.TextName); } } catch (OutOfMemoryException Exc) { MessageBox.Show(Exc.ToString()); } catch (ArgumentException Exc) { MessageBox.Show(Exc.ToString()); } //add new record to grid UpdateGrid(); } } }
//Button Edit click handler private void btnEdit_Click(object sender, EventArgs e) { if (listView.SelectedIndices.Count > 0) { int SelectedCell = listView.SelectedIndices[0]; if (SelectedCell >= 0 && SelectedCell < EncryptedData.GetNoteCount()) { try { //show Editor dialog frmEditor EditorForm = new frmEditor(); EditorForm.TextArray = EncryptedData.GetNoteText(SelectedCell); EditorForm.TextName = EncryptedData.GetNoteName(SelectedCell); EditorForm.ShowDialog(); //update data EncryptedData.SetNoteAccessDate(SelectedCell, DateTime.Now); if (EditorForm.IsCanceled == false) { if (EditorForm.IsUpdated == true) EncryptedData.SetNoteUpdateDate(SelectedCell, DateTime.Now); EncryptedData.SetNoteText(SelectedCell, EditorForm.TextArray); EncryptedData.SetNoteName(SelectedCell, EditorForm.TextName); } } catch (OutOfMemoryException Exc) { MessageBox.Show(Exc.ToString()); } catch (ArgumentException Exc) { MessageBox.Show(Exc.ToString()); } //add new record to grid UpdateGrid(); } } }