private void btnAddnew_Click(object sender, RoutedEventArgs e)
        {
            //Create a photo object to pass in to the addnew form - the arguments will be supplied within that form
            Photograph newphoto = new Photograph(null, DateTime.MinValue, DateTime.MinValue, null, null, null, null);
            //Create an editing form, passing in a new photo and a bool that tells the form whether we're editing or adding a record.
            addnew frm = new addnew(newphoto, false);

            if (frm.ShowDialog() == true)
            {
                //Add newphoto to plist
                plist.Add(newphoto);
                DatabaseUtil.AddRecord(newphoto);
                CollectionViewSource.GetDefaultView(dgPhotoInfo.ItemsSource).Refresh();
            }
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            //Reuses the 'addnew' form to edit an existing record
            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(dgPhotoInfo.ItemsSource);
            //This accesses the currently selected photo object
            Photograph currentphoto = view.CurrentItem as Photograph;
            //then creates the form, passing in the currentphoto object for editing, along with the boolean true for 'isedit'
            addnew frm = new addnew(currentphoto, true);

            if (frm.ShowDialog() == true)
            {
                //Refresh the view if we've changed a record
                CollectionViewSource.GetDefaultView(dgPhotoInfo.ItemsSource).Refresh();
                DatabaseUtil.EditRecord(currentphoto);
            }
        }