Beispiel #1
0
        private void OnMoviesAdd(object sender, EventArgs e)
        {
            var form = new MovieDetailForm("Add Product");

            var result = form.ShowDialog(this);

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

            _movie = form.Movie;
        }
Beispiel #2
0
        private void OnMoviesEdit(object sender, EventArgs e)
        {
            if (_movie == null)
            {
                MessageBox.Show(this, "No movie to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var form = new MovieDetailForm(_movie);

            var result = form.ShowDialog(this);

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

            _movie = form.Movie;
        }
Beispiel #3
0
        //Helper method to handle editing products
        private void EditMovie( Movie movie )
        {
            var form = new MovieDetailForm(movie);
            //if an error occurs, show MovieDetailForm again with same info
            while (true)
            {
                var result = form.ShowDialog(this);
                if (result != DialogResult.OK)
                    return;

                //Update product
                form.Movie.Id = movie.Id;
                _database.Update(form.Movie, out var message);
                if (!String.IsNullOrEmpty(message))
                    MessageBox.Show(message);
                else
                    break;
            //}
            RefreshUI();
        }
Beispiel #4
0
        private void OnMoviesAdd( object sender, EventArgs e )
        {
            var form = new MovieDetailForm("Add Product");
            //if any errors occur, show MovieDetailForm again with same info          
            while (true)
            {
                //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);
                else
                    break;
            }

            RefreshUI();
        }
Beispiel #5
0
        private void OnMoviesAdd(object sender, EventArgs e)
        {
            var form = new MovieDetailForm("Add Movie");

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

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

            //Add to database
            try
            {
                _database.Add(form.Movie);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            RefreshUI();
        }
Beispiel #6
0
        //Helper method to handle editing products
        private void EditMovie(Movie movie)
        {
            var form = new MovieDetailForm(movie);
            //if an error occurs, show MovieDetailForm again with same info
            var result = form.ShowDialog(this);

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

            //Update product
            form.Movie.Id = movie.Id;
            try
            {
                _database.Update(form.Movie);
            } catch (Exception e)
            {
                MessageBox.Show(e.Message);
            };

            RefreshUI();
        }