//Called when Movie\Add selected private void OnMovieAdd(object sender, EventArgs e) { var form = new MovieForm(); //Show the new movie form modally if (form.ShowDialog(this) == DialogResult.OK) { try { _movies.Add(form.Movie); UpdateUI(); } catch (ArgumentException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ValidationException ex) { MessageBox.Show(ex.Message, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Save failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); //throw; //rethrow existing exception //throw ex; //throwing a new exception }; } ; }
//Called when Movie\Add selected private void OnMovieAdd(object sender, EventArgs e) { var form = new MovieForm(); //Modeless - does not block main window //form.Show(); //Show the new movie form modally if (form.ShowDialog(this) == DialogResult.OK) { _movies.Add(form.Movie); UpdateUI(); } ; }
private void OnMovieEdit(object sender, EventArgs e) { var movie = GetSelectedMovie(); if (movie == null) { return; } var form = new MovieForm(); form.Movie = movie; if (form.ShowDialog(this) == DialogResult.OK) { _movies.Update(movie.Id, form.Movie); UpdateUI(); } }
private void OnMovieEdit(object sender, EventArgs e) { //Get selected movie var movie = GetSelectedMovie(); if (movie == null) { return; } var form = new MovieForm(); form.Movie = movie; if (form.ShowDialog(this) != DialogResult.OK) { return; } try { _movies.Update(movie.Id, form.Movie); UpdateUI(); } catch (ArgumentException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (ValidationException ex) { MessageBox.Show(ex.Message, "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Save failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }; }
private void OnMovieEdit(object sender, EventArgs e) { //Get selected movie var movie = GetSelectedMovie(); if (movie == null) { return; } var form = new MovieForm(); form.Movie = movie; if (form.ShowDialog(this) == DialogResult.OK) { //TODO: Change to update RemoveMovie(movie); AddMovie(form.Movie); UpdateUI(); } ; }