Example #1
0
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     int id;
     if (!int.TryParse(NavigationContext.QueryString["id"], out id))
     {
         throw new Exception("No idea how you got here but something is wrong.");
     }
     _kid = App.ViewModel.GetKid(id);
 }
Example #2
0
        // Remove a kid item from the database.
        public void DeleteKid(Kids kidForDelete)
        {
            // Remove the kid from the "all" observable collection.
            AllKids.Remove(kidForDelete);

            // Remove the kid from the data context.
            KidDB.Items.DeleteOnSubmit(kidForDelete);

            // Save changes to the database.
            KidDB.SubmitChanges();
        }
Example #3
0
        public void AddKid(Kids newKid)
        {
            // Add a kid to the data context.
            KidDB.Items.InsertOnSubmit(newKid);

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

            // Add a kid to the "all" observable collection.
            AllKids.Add(newKid);
        }
Example #4
0
        private void OnClick_Add(object sender, EventArgs e)
        {
            Kids newKid = new Kids
            {
                Id = App.ViewModel.GetNewId(),
                Name = TxtBxName.Text,
                DateOfBirth = (DateTime)DatePicker.Value,
                PicturePath = ((bool)MaleRadioButton.IsChecked) ? "/Resources/boy.png" : "/Resources/girl.png"
            };

            // Add kid to the ViewModel.
            App.ViewModel.AddKid(newKid);

            // Return to the main page.
            if (NavigationService.CanGoBack)
            {
                NavigationService.GoBack();
            }
        }