private void btnDelete_Click(object sender, EventArgs e) { //Validate the UI if (string.IsNullOrEmpty(txtMovieNumber.Text.Trim())) { MessageBox.Show("Please enter a movie id."); txtMovieNumber.Focus(); return; } if (string.IsNullOrEmpty(txtMovieTitle.Text.Trim())) { MessageBox.Show("Please enter a movie name."); txtMovieNumber.Focus(); return; } Movie objMovie = new Movie(); objMovie.movie_number = txtMovieNumber.Text.Trim(); objMovie.movie_title = txtMovieTitle.Text.Trim(); objMovie.description = txtDescription.Text.Trim(); objMovie.movie_year_made = txtMovieYearMade.Text.Trim(); objMovie.genre_id = ((Genre)cbGenre.SelectedItem).ID.ToString(); objMovie.movie_rating = cbRating.Text.Trim(); objMovie.media_type = cbMediaType.Text.Trim(); objMovie.movie_retail_cost = Convert.ToDecimal(txtRetailCost.Text.Trim()); objMovie.copies_on_hand = txtCopiesOnHand.Text.Trim(); objMovie.image = txtImageFilename.Text.Trim(); objMovie.trailer = txtTrailerLink.Text.Trim(); try { bool status = MovieDB.DeleteMovie(objMovie); if (status) //You can use this syntax as well..if (status ==true) { MessageBox.Show("Movie was deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Movie was not deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Delete_Click(object sender, EventArgs e) { try { Movie m = new Movie(); m.id = txt_Movienum.Text.Trim(); if (m != null) { if (MovieDB.DeleteMovie(m)) { MessageBox.Show("Delete Successful."); } else { MessageBox.Show("Delete Failed. Make sure all information has been entered."); } } } catch (Exception ex) { MessageBox.Show("There was a technical error during the operation.\n\nMessage:\n" + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace); } }
private void btnDelete_Click(object sender, EventArgs e) { if (!(validateUI(btnDelete))) { return; } try { Movie myMovie = new Movie(); myMovie.movie_number = Convert.ToInt32(txtMovieNumber.Text.Trim()); myMovie.movie_title = txtMovieTitle.Text.Trim(); myMovie.description = rtbDescription.Text.Trim(); myMovie.movie_year_made = Convert.ToInt32(txtMovieYearMade.Text.Trim()); myMovie.genre_id = cmbGenre.SelectedIndex; myMovie.movie_rating = cmbMovieRating.Text.Trim(); myMovie.image = txtImage.Text.Trim(); myMovie.rental_duration = cmbRentalDuration.SelectedIndex; myMovie.trailer = txtTrailer.Text.Trim(); bool status = MovieDB.DeleteMovie(myMovie); if (status) //returns true { MessageBox.Show("Movie ID has been deleted from the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); //Automatically refresh the data grid this.btnBrowse_Click(null, null); } else //returns false { MessageBox.Show("Movie ID was not deleted from the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void DeleteMovie(int?id) { mDb.DeleteMovie(id); }