Example #1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            using SQLiteCommand cmd = GlobalFunction.OpenDbConnection();
            NoteDetails rowDetails = (NoteDetails)((FrameworkElement)sender).DataContext;

            cmd.CommandText = $"DELETE FROM notes WHERE noteId = {rowDetails.ID}";
            cmd.ExecuteNonQuery();

            noteCollection.Remove(noteCollection.Where(i => i.ID == rowDetails.ID).Single());
        }
Example #2
0
        private void NotesDetails_Load(object sender, RoutedEventArgs e)
        {
            noteDataGrid.ItemsSource = noteCollection;
            List <NoteInfo> notes = Database.Get.Note.AllFromStudentId(studentId);

            foreach (NoteInfo note in notes)
            {
                int         creationTimestamp  = note.creationDate;
                DateTime    creationDate       = DateTimeOffset.FromUnixTimeSeconds(creationTimestamp).LocalDateTime;
                string      creationDateString = creationDate.ToString("g", GlobalVariable.culture);
                NoteDetails noteDetail         = new NoteDetails()
                {
                    ID           = note.noteId,
                    CreationDate = creationDateString,
                    Content      = note.content
                };
                noteCollection.Add(noteDetail);
            }
        }