Exemplo n.º 1
0
        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)
            {
                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 new exception
                };
            }
            ;
        }