예제 #1
0
        private void appBarOkButton_Click(object sender, EventArgs e)
        {
            // Confirm there is some text in the text box.
            if (newTaskNameTextBox.Text.Length > 0)
            {
                // Create a new to-do item.
                ToDoItem newToDoItem = new ToDoItem
                {
                    ItemName = newTaskNameTextBox.Text
                };

                // Add the item to the ViewModel.
                App.ViewModel.AddToDoItem(newToDoItem);

                MessageBoxResult msgBoxresult = MessageBox.Show("Add Finished", "Information", MessageBoxButton.OK);
                if (msgBoxresult == MessageBoxResult.OK)
                {
                    // Return to the main page.
                    if (NavigationService.CanGoBack)
                    {
                        NavigationService.GoBack();
                    }
                }
                //NavigationService.Navigate(new Uri(@"/MainPage.xaml", UriKind.Relative));
            }
        }
예제 #2
0
        // Add a to-do item to the database and collections.
        public void AddToDoItem(ToDoItem newToDoItem)
        {
            // Add a to-do item to the data context.
            Context.AllItems.InsertOnSubmit(newToDoItem);

            // Save changes to the database.
            Context.SubmitChanges();

            // Add a to-do item to the appropriate filtered collection.
            AllToDoItems.Add(newToDoItem);
            switch (newToDoItem.ItemName.Substring(0,2))
            {
                case "BB":
                    HomeToDoItems.Add(newToDoItem);
                    break;
                case "CC":
                    WorkToDoItems.Add(newToDoItem);
                    break;
                case "DD":
                    HobbiesToDoItems.Add(newToDoItem);
                    break;
                default:
                    break;
            }
        }
예제 #3
0
        // Remove a to-do task item from the database and collections.
        public void DeleteToDoItem(ToDoItem toDoForDelete)
        {
            // Remove the to-do item from the data context.
            Context.AllItems.DeleteOnSubmit(toDoForDelete);

            // Save changes to the database.
            Context.SubmitChanges();

            AllToDoItems.Remove(toDoForDelete);
            switch (toDoForDelete.ItemName.Substring(0, 2))
            {
                case "BB":
                    HomeToDoItems.Remove(toDoForDelete);
                    break;
                case "CC":
                    WorkToDoItems.Remove(toDoForDelete);
                    break;
                case "DD":
                    HobbiesToDoItems.Remove(toDoForDelete);
                    break;
                default:
                    break;
            }
        }