private void openToolStripMenuItem_Click(object sender, EventArgs e) { using (var form = new SelectFileForm()) { if (form.ShowDialog() == DialogResult.OK) { var currentNote = form.SelectedNote; _note = currentNote; textBox1.Text = currentNote.NoteText; } } }
private void buttonLoad_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { MessageBox.Show("Nothing selected", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var name = listView1.SelectedItems[0].Text; _selectedNote = GetData(name); DialogResult = DialogResult.OK; }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { textBox1.Text = ""; _note = null; }
public IList<Notes> GetData(string connectionString) { IList<Notes> listNotes = new List<Notes>(); using (var connection = new OleDbConnection()) { connection.ConnectionString = connectionString; connection.Open(); var command = new OleDbCommand("SELECT * from Notes", connection); var dataReader = command.ExecuteReader(); while (dataReader != null && dataReader.Read()) { var note = new Notes { Id = int.Parse(dataReader["Id"].ToString()), NoteName = dataReader["NoteName"].ToString(), NoteText = Decompress(dataReader["NoteText"].ToString()), DateCreated = Convert.ToDateTime(dataReader["DateCreated"].ToString()), DateModified = Convert.ToDateTime(dataReader["DateModified"].ToString()) }; listNotes.Add(note); } } return listNotes; }