private void btnDelete_Click(object sender, EventArgs e) { int id; if (!Int32.TryParse(txtID.Text.Trim(), out id)) { MessageBox.Show(MsgBoxHelper.MustBe(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { if (id > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else if (id < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { Genre objGenre = new Genre(); objGenre.id = id; objGenre.name = txtName.Text.Trim(); try { bool status = Genres.DeleteGenre(objGenre); if (status) { MessageBox.Show(MsgBoxHelper.Deleted("Genre"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); frmGenre_Load(sender, e); } else { MessageBox.Show(MsgBoxHelper.Deleted("Genre not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void btnBrowse_Click(object sender, EventArgs e) { int id; if (!Int32.TryParse(txtID.Text.Trim(), out id)) { MessageBox.Show(MsgBoxHelper.MustBe(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { if (id > short.MaxValue) // 32767 { MessageBox.Show(MsgBoxHelper.LTETmax(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else if (id < short.MinValue)//-32768 { MessageBox.Show(MsgBoxHelper.GTETmin(lblID.Text), "Invalid " + lblID.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); txtID.Focus(); } else { Genre objGenre; try { objGenre = Genres.GetGenre(id); if (objGenre == null) { MessageBox.Show(MsgBoxHelper.Selected("Genre " + lblID.Text + " " + id), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { txtName.Text = objGenre.name; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void frmMovie_Load(object sender, EventArgs e) { try { movieList = Movies.GetMovies(); movieDataGridView.DataSource = movieList; List <Genre> genreList = Genres.GetGenres(); cmbGenreID.DataSource = genreList; cmbGenreID.DisplayMember = Genres.extra; cmbGenreID.ValueMember = Genres.key; cmbGenreID.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } ToolTip toolTip = new ToolTip(); toolTip.SetToolTip(btnAdd, "Add all Movie fields"); toolTip.SetToolTip(btnFind, "Browse by Movie Number"); toolTip.SetToolTip(btnUpdate, "Update all Movie fields"); toolTip.SetToolTip(btnDelete, "Delete Movie Number"); toolTip.SetToolTip(btnClear, "Clear all Movie fields"); toolTip.SetToolTip(txtMovieNumber, Movie.movie_numberTip); toolTip.SetToolTip(lblMovieNumber, Movie.movie_numberTip); toolTip.SetToolTip(txtMovieTitle, Movie.movie_titleTip); toolTip.SetToolTip(lblMovieTitle, Movie.movie_titleTip); toolTip.SetToolTip(txtDescription, Movie.DescriptionTip); toolTip.SetToolTip(lblDescription, Movie.DescriptionTip); toolTip.SetToolTip(txtMovieYearMade, Movie.movie_year_madeTip); toolTip.SetToolTip(lblMovieYearMade, Movie.movie_year_madeTip); toolTip.SetToolTip(cmbGenreID, Movie.genre_idTip); toolTip.SetToolTip(lblGenreID, Movie.genre_idTip); toolTip.SetToolTip(cmbMovieRating, Movie.movie_ratingTip); toolTip.SetToolTip(lblMovieRating, Movie.movie_ratingTip); toolTip.SetToolTip(cmbMediaType, Movie.media_typeTip); toolTip.SetToolTip(lblMediaType, Movie.media_typeTip); toolTip.SetToolTip(txtMovieRetailCost, Movie.movie_retail_costTip); toolTip.SetToolTip(lblMovieRetailCost, Movie.movie_retail_costTip); toolTip.SetToolTip(txtCopiesOnHand, Movie.copies_on_handTip); toolTip.SetToolTip(lblCopiesOnHand, Movie.copies_on_handTip); toolTip.SetToolTip(txtImage, Movie.imageTip); toolTip.SetToolTip(lblImage, Movie.imageTip); toolTip.SetToolTip(txtTrailer, Movie.trailerTip); toolTip.SetToolTip(lblTrailer, Movie.trailerTip); movieDataGridView.Width = 43 + 9 * 100 + 17; movieDataGridView.Height = 23 + 3 * 22 + 17; }