private void b_add_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(tb_name.Text)) { MessageBox.Show("Enter a name!"); return; } if (dob_date == null) { MessageBox.Show("Enter a date of birth!"); return; } if (cb_species.SelectedItem == null) { MessageBox.Show("Select a species!"); return; } if (string.IsNullOrEmpty(tb_feedingInterval.Text)) { MessageBox.Show("Enter a feeding Interval!"); return; } int f = 0; if (Int32.TryParse(tb_feedingInterval.Text, out f)) { var spider = new Spider(); spider.name = tb_name.Text; spider.species = cb_species.SelectedItem as Species; spider.dateOfBirth = (DateTime)dob_date.SelectedDate; spider.feedingInterval = f; spider.eventList = App._vm.spiderContainer.eventList; int index = App._vm.spiderList.IndexOf(App._vm.spiderContainer); App._vm.spiderList[index] = spider; SafeLoad.SaveToJson(); this.Close(); } else { MessageBox.Show("Enter a valid feeding Interval!"); return; } }
private void Application_Exit(object sender, ExitEventArgs e) { FeedingReminder.clearFeedingList(); SafeLoad.SaveToJson(); }