Exemplo n.º 1
0
        private void OnMovieAdd(object sender, EventArgs e)
        {
            var button = sender as ToolStripMenuItem;

            var    form = new MovieDetailForm("Add Movie");
            string message;

            do
            {
                var result = form.ShowDialog(this);
                if (result != DialogResult.OK)
                {
                    return;
                }

                //Add the product to the database
                _database.Add(form.Movie, out message);

                if (!String.IsNullOrEmpty(message))
                {
                    MessageBox.Show(message);
                    form      = new MovieDetailForm(form.Movie);
                    form.Text = "Add Movie";
                }
            } while (!String.IsNullOrEmpty(message));

            RefreshUI();
        }
Exemplo n.º 2
0
        //Helper method to handle editing movies
        private void EditMovie(Movie movie)
        {
            string message;
            var    form = new MovieDetailForm(movie);

            do
            {
                var result = form.ShowDialog(this);
                if (result != DialogResult.OK)
                {
                    return;
                }

                //Update the product
                form.Movie.Id = movie.Id;
                _database.Update(form.Movie, out message);

                if (!String.IsNullOrEmpty(message))
                {
                    MessageBox.Show(message);
                    form = new MovieDetailForm(form.Movie);
                }
            } while (!String.IsNullOrEmpty(message));

            RefreshUI();
        }
Exemplo n.º 3
0
        private void OnMovieAdd(object sender, EventArgs e)
        {
            var button = sender as ToolStripMenuItem;
            var form   = new MovieDetailForm("Add Movie");
            var valid  = false;

            do
            {
                //Show form modally
                var result = form.ShowDialog(this);
                if (result != DialogResult.OK)
                {
                    return;
                }

                //Add to database
                //_database.Add(form.Movie);
                try
                {
                    _database.Add(form.Movie);
                    valid = true;
                } catch (NotImplementedException)
                {
                    MessageBox.Show("not implemented yet");
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    form      = new MovieDetailForm(form.Movie);
                    form.Text = "Add Movie";
                };
            } while (!valid);

            RefreshUI();
        }
Exemplo n.º 4
0
        //Helper method to handle editing movies
        private void EditMovie(Movie movie)
        {
            var form = new MovieDetailForm(movie);

            //Update the movie
            form.Movie.Id = movie.Id;
            var valid = false;

            do
            {
                //Show form modally
                var result = form.ShowDialog(this);
                if (result != DialogResult.OK)
                {
                    return;
                }

                try
                {
                    _database.Update(form.Movie);
                    valid = true;
                } catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    form = new MovieDetailForm(form.Movie);
                };
            } while (!valid);

            RefreshUI();
        }
Exemplo n.º 5
0
        private void OnMovieAdd(object sender, EventArgs e)
        {
            var form = new MovieDetailForm("Add Movie");

            //Modal form
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            _movie = form.Movie;
        }
Exemplo n.º 6
0
        private void OnMovieEdit(object sender, EventArgs e)
        {
            if (_movie == null)
            {
                MessageBox.Show(this, "There is no movie to edit.", "Edit Movie", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            var form = new MovieDetailForm(_movie);

            //Show form modally
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }

            //"Editing" the Movie
            _movie = form.Movie;
        }