private void OnMovieAdd(object sender, EventArgs e) { var button = sender as ToolStripMenuItem; var form = new MovieDetailForm("Add Movie"); //Show form modally var result = form.ShowDialog(this); if (result != DialogResult.OK) { return; } //Add to database _database.Add(form.Movie, out var message); if (!String.IsNullOrEmpty(message)) { MessageBox.Show(message); } RefreshUI(); /* * var form = new MovieDetailForm(); * form.Text = "Add Movie"; * * var result = form.ShowDialog(); * if (result != DialogResult.OK) * return; * * _movie = form.Movie; */ }
//Helper method to handle editing movies private void EditMovie(Movie movie) { var form = new MovieDetailForm(movie); var result = form.ShowDialog(this); if (result != DialogResult.OK) { return; } //Update the movie form.Movie.Id = movie.Id; //_database.Update(form.Movie, out var message); //if (!String.IsNullOrEmpty(message)) // MessageBox.Show(message); try { _database.Update(form.Movie); } catch (Exception e) { MessageBox.Show(e.Message); }; RefreshUI(); }
private void OnMovieAdd(object sender, EventArgs e) { var button = sender as ToolStripMenuItem; var form = new MovieDetailForm("Add Movie"); //Show form modally var result = form.ShowDialog(this); if (result != DialogResult.OK) { return; } //Add to database //_database.Add(form.Movie); //if (!String.IsNullOrEmpty(message)) // MessageBox.Show(message); try { _database.Add(form.Movie); } catch (NotImplementedException) { MessageBox.Show("Not implemented"); } catch (Exception ex) { MessageBox.Show(ex.Message); }; RefreshUI(); /* * var form = new MovieDetailForm(); * form.Text = "Add Movie"; * * var result = form.ShowDialog(); * if (result != DialogResult.OK) * return; * * _movie = form.Movie; */ }