public void OpenNoteBook() { string path = @"F:\file.json"; using (StreamReader streamReader = new StreamReader(path)) { string line = string.Empty; while ((line = streamReader.ReadLine()) != null) { Note note = Note.JsonStringToNote(line); currentNoteBook.GetNoteList().Add(note); } } }
public void SaveNoteBook() { using (SqlConnection connection = new SqlConnection(connectionString)) { string commandString = "INSERT INTO Note(Note_Title,DateAndTime,[Content],Note_Author,Id_NoteBook) VALUES(@param1,@param2,@param3,@param4,@param5)"; foreach (var item in currentNoteBook.GetNoteList()) { SqlCommand commandSQL = new SqlCommand(commandString, connection); connection.Open(); commandSQL.Parameters.AddWithValue("@param1", item.Title); commandSQL.Parameters.AddWithValue("@param2", item.Date); commandSQL.Parameters.AddWithValue("@param3", item.Content); commandSQL.Parameters.AddWithValue("@param4", item.Author); commandSQL.Parameters.AddWithValue("@param5", currentNoteBook.Id); commandSQL.ExecuteNonQuery(); connection.Close(); } } }
public NoteBookConsoleView(NoteBook noteBook) { this.noteBook = noteBook; this.noteList = noteBook.GetNoteList(); }