Пример #1
0
        private void saveAsClick(object sender, RoutedEventArgs e)
        {
            title = clickTitle.Text;
            note  = clickNote.Text;
            Microsoft.Win32.SaveFileDialog save = new Microsoft.Win32.SaveFileDialog();
            save.FileName   = title;
            save.DefaultExt = ".txt";
            save.Filter     = "Text documents (.txt)|*.txt";

            Nullable <bool> result = save.ShowDialog();

            if (result == true)
            {
                path = save.FileName;
                System.IO.File.WriteAllText(path, note);
            }
            con.Open();
            noteworthyDataSet = new NoteworthyDataSet();
            NoteworthyDataSetTableAdapters.MyNotesTableAdapter myNotesTldAdp = new NoteworthyDataSetTableAdapters.MyNotesTableAdapter();
            myNotesTldAdp.Connection.ConnectionString = con.ConnectionString;
            myNotesTldAdp.InsertQuery(title, path, "#FFFFFFFF");

            noteworthyDataSet.AcceptChanges();
            myNotesTldAdp.Update(noteworthyDataSet.MyNotes);
            con.Close();
        }
        private void DeleteNote(object sender, RoutedEventArgs e)
        {
            Button bt = sender as Button;

            con.Open();

            NoteworthyDataSet noteworthyDataSet = new NoteworthyDataSet();

            NoteworthyDataSetTableAdapters.MyNotesTableAdapter myNotesTldAdp = new NoteworthyDataSetTableAdapters.MyNotesTableAdapter();
            myNotesTldAdp.Connection.ConnectionString = con.ConnectionString;
            string path;
            var    res = MessageBox.Show("Are you sure you want to delete this note?", "Delete", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                path = myNotesTldAdp.GetPath((noteToChange.Content as TextBlock).Text);
                File.Delete(path);
                myNotesTldAdp.DeleteQuery((noteToChange.Content as TextBlock).Text);
            }
            noteworthyDataSet.AcceptChanges();
            myNotesTldAdp.Update(noteworthyDataSet.MyNotes);


            con.Close();

            Bind();
        }
        private void NoteColorPurple(object sender, RoutedEventArgs e)
        {
            noteToChange.Background = PurpleColor.Background;

            con.Open();
            NoteworthyDataSet noteworthyDataSet = new NoteworthyDataSet();

            NoteworthyDataSetTableAdapters.MyNotesTableAdapter myNotesTldAdp = new NoteworthyDataSetTableAdapters.MyNotesTableAdapter();
            myNotesTldAdp.Connection.ConnectionString = con.ConnectionString;

            myNotesTldAdp.UpdateColor("#FFCF89EA", (noteToChange.Content as TextBlock).Text);
            noteworthyDataSet.AcceptChanges();
            myNotesTldAdp.Update(noteworthyDataSet.MyNotes);
            con.Close();
        }