Exemplo n.º 1
0
        private void btnReadDelete_Click(object sender, EventArgs e)
        {
            if (NavigationContext.QueryString["id"] != null)
            {
                int.TryParse(NavigationContext.QueryString["id"].ToString(), out id);
                db = new StoryContext("isostore:/Story.sdf");

                _story = (from item in db.diary where item.idStory == id select item).FirstOrDefault();

                db.diary.DeleteOnSubmit(_story);
                db.SubmitChanges();

                NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
            }
        }
Exemplo n.º 2
0
        private void menuDelete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Would you like to delete this story?", "Delete Story", MessageBoxButton.OKCancel);

            if (result == MessageBoxResult.OK)
            {
                // delete data
                int id = ((sender as MenuItem).DataContext as Story).idStory;
                db = new StoryContext("isostore:/Story.sdf");
                Story _story = (from item in db.diary where item.idStory == id select item).FirstOrDefault();
                db.diary.DeleteOnSubmit(_story);
                db.SubmitChanges();
                MainListBox.ItemsSource = db.diary;
            }
        }