Пример #1
0
        private void OnProductEdit(object sender, EventArgs e)
        {
            RefreshUI();

            //Get selected movie
            var movie = GetSelectedMovie();

            if (movie == null)
            {
                return;
            }

            var form = new MovieDetailForm(movie);

            //var message2 = "temp";  //using as a flag for while loop below

            //Show form modally
            //until message2 is null or empty we restore the window
            //it was hacked like this to preserve the form contents,
            //i.e. dont dump the description info if they had something entered
            //while (!String.IsNullOrEmpty(message2))
            //{
            var result = form.ShowDialog(this);

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

            //"update" the movie
            //_movie = form.Movie;
            form.Movie.Id = movie.Id;
            try
            {
                _movie.Update(form.Movie);
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //_movie.Update(form.Movie, out var message);
            //message2 = message;
            //if (!String.IsNullOrEmpty(message))
            //{
            //    MessageBox.Show(message);
            //}
            // }

            RefreshUI();
        }
Пример #2
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            var button = sender as ToolStripMenuItem;

            var form = new MovieDetailForm("Add Movie");
            //form.Text = "Add Product";

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

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

            //"add" the movie
            _movie = form.Movie;
        }
Пример #3
0
        private void OnProductAdd(object sender, EventArgs e)
        {
            RefreshUI();

            var button = sender as ToolStripMenuItem;

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

            //var message2 = "temp";  //using as a flag for while loop below

            //Show form modally
            //until message2 is null or empty we restore the window
            //it was hacked like this to preserve the form contents,
            //i.e. dont dump the description info if they had something entered
            // while (!String.IsNullOrEmpty(message2))
            //{
            var result = form.ShowDialog(this);

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

            try
            {
                _movie.Add(form.Movie);
            } catch (NotImplementedException)
            {
                MessageBox.Show("Not implemented yet");
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //"add" the movie
            //_movie.Add(form.Movie, out var message);
            //message2 = message;
            //if (!String.IsNullOrEmpty(message))
            //{
            //    MessageBox.Show(message);
            //    //OnProductAdd(sender, e); this was the first or second bad idea to try and redisplay the form on error
            //}
            // }
            RefreshUI();
        }
Пример #4
0
        private void OnProductEdit(object sender, EventArgs e)
        {
            // check for null condition first, if so then display an error accordingly
            if (_movie == null)
            {
                MessageBox.Show(this, "No movie to edit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
                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;
        }