コード例 #1
0
        //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
                };
            }
            ;
        }
コード例 #2
0
        //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();
            }
            ;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: gittccd/itse1430
        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();
            }
        }
コード例 #4
0
        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);
            };
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: jeff-re/test
        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();
            }
            ;
        }