Exemplo n.º 1
0
        private void EditMovie(Movie movie)
        {
            var form   = new MovieDetailForm(movie);
            var result = form.ShowDialog(this);

            if (result != DialogResult.OK)
            {
                return;
            }
            do
            {
                //update movie
                form.Movie.Id = movie.Id;

                var temp = form.Movie;

                try
                {
                    _database.Update(form.Movie);
                    break;
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    form   = new MovieDetailForm(temp);
                    result = form.ShowDialog(this);
                    if (result != DialogResult.OK)
                    {
                        return;
                    }
                }
            } while (true);

            RefreshUI();
        }
Exemplo n.º 2
0
        private void OnMoviesEdit(object sender, EventArgs e)
        {
            //check for movie in system
            if (_movie == null)
            {
                MessageBox.Show("No movie in system", "Error");
                return;
            }

            //instatiate MovieDetailForm with movie being edited
            var form = new MovieDetailForm(_movie);

            //load movie into form
            form.Movie = _movie;

            var result = form.ShowDialog(this);

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

            //edit movie(assign edited form to movie)
            _movie = form.Movie;
            MessageBox.Show("Edit Saved");
        }
Exemplo n.º 3
0
        private void OnMoviesAdd(object sender, EventArgs e)
        {
            //instatiate MovieDetailForm with Add Product in titlebar
            var form = new MovieDetailForm("Add Product");

            //show MovieDetailForm
            var result = form.ShowDialog(this);

            //return if OK(Save) not selected
            if (result != DialogResult.OK)
            {
                return;
            }

            //add movie
            _movie = form.Movie;
            MessageBox.Show("Movie Added");
        }
Exemplo n.º 4
0
        private void EditMovie(Movie movie)
        {
            var form   = new MovieDetailForm(movie);
            var result = form.ShowDialog(this);

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

            //update movie
            form.Movie.Id = movie.Id;
            _database.Update(form.Movie, out var message);
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }

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

            //show MovieDetailForm
            var result = form.ShowDialog(this);

            //return if OK(Save) not selected
            if (result != DialogResult.OK)
            {
                return;
            }

            //temporarily store form data incase save fails
            var temp = form.Movie;

            //basically do while no exceptions
            //(break will only execute if there is no exception thrown)
            do
            {
                //add to database
                try
                {
                    _database.Add(form.Movie);
                    break;
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    form   = new MovieDetailForm(temp, "Add Movie");
                    result = form.ShowDialog(this);
                    if (result != DialogResult.OK)
                    {
                        return;
                    }
                }
            } while (true);

            RefreshUI();
        }
Exemplo n.º 6
0
        private void OnMovieAdd(object sender, EventArgs e)
        {
            //instatiate MovieDetailForm with Add Product in titlebar
            var form = new MovieDetailForm("Add Product");

            //show MovieDetailForm
            var result = form.ShowDialog(this);

            //return if OK(Save) not selected
            if (result != DialogResult.OK)
            {
                return;
            }

            //add to database
            _database.Add(form.Movie, out var message);
            if (!String.IsNullOrEmpty(message))
            {
                MessageBox.Show(message);
            }

            RefreshUI();
        }