private void btnAdd_Click(object sender, EventArgs e) { if (!(validateUI(btnAdd))) { return; } try { Genre myGenre = new Genre(); myGenre.id = txtID.Text.Trim(); myGenre.name = txtName.Text.Trim(); bool status = GenreDB.AddGenre(myGenre); if (status) //returns true { MessageBox.Show("Genre added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); //Automatically refresh the data grid this.btnBrowse_Click(null, null); } else //returns false { MessageBox.Show("Genre was not added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); //Automatically refresh the data grid this.btnBrowse_Click(null, null); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnFind_Click(object sender, EventArgs e) { //Validate the UI if (string.IsNullOrEmpty(txtGenreID.Text.Trim())) { MessageBox.Show("Please enter a genre id."); txtGenreID.Focus(); return; } Genre objGenre = GenreDB.GetGenre(Convert.ToInt32(txtGenreID.Text.Trim())); //Step 2: Validate to make sure the Customer object is not null. if (objGenre != null) { //Populate the UI with the object values txtGenreName.Text = objGenre.Name; //make Genre ID field read-only to be used for updating and deleting records demo txtGenreID.ReadOnly = true; } else { MessageBox.Show("Genre ID " + txtGenreID.Text.Trim() + " not found in database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnFind_Click(object sender, EventArgs e) { if (!(validateUI(btnFind))) { return; } try { int genreID = Convert.ToInt32(txtID.Text.Trim()); Genre objGenre = GenreDB.GetGenre(genreID); if (objGenre != null) { txtName.Text = objGenre.name; txtID.ReadOnly = true; } else { MessageBox.Show($"Genre ID(txtID.Text) not found in database.", "MeremacNetflix", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BrowseForm_Load(object sender, EventArgs e) { MovieList = MovieDB.GetMovies(); genreList = GenreDB.GetGenres(); ScrollDisplay(0); }
private void populateGenreNames() { List <Genre> genres = GenreDB.GetGenres(); cbGenre.DisplayMember = "Name"; cbGenre.ValueMember = "ID"; cbGenre.DataSource = genres; }
public MovieForm() { InitializeComponent(); cmbGenre.DataSource = GenreDB.GetGenres(); cmbGenre.DisplayMember = "name"; cmbGenre.SelectedIndex = -1; cmbGenre.Text = "--Select--"; cmbMovieRating.Text = "--Select--"; cmbRentalDuration.Text = "--Select--"; }
public static List <BookDB> GenerateBooks(int count, AuthorDB author, GenreDB genre) { return(Fixture.Build <BookDB>() .With(x => x.Author, author) .With(x => x.AuthorId, author.Id) .With(x => x.Genre, genre) .With(x => x.GenreId, genre.Id) .CreateMany(count) .ToList()); }
private void btnAdd_Click(object sender, EventArgs e) { //Validate the UI if (string.IsNullOrEmpty(txtGenreID.Text.Trim())) { try { List <Genre> genreList = new List <Genre>(); genreList = GenreDB.GetGenres(); int num = 1; foreach (Genre genre in genreList) { if (num <= genre.ID) { num = genre.ID + 1; } } txtGenreID.Text = num.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (string.IsNullOrEmpty(txtGenreName.Text.Trim())) { MessageBox.Show("Please enter a genre name."); txtGenreID.Focus(); return; } Genre objGenre = new Genre(); objGenre.ID = Convert.ToInt32(txtGenreID.Text.Trim()); objGenre.Name = txtGenreName.Text.Trim(); try { bool status = GenreDB.AddGenre(objGenre); if (status) //You can use this syntax as well..if (status ==true) { Reload_Data(); MessageBox.Show("Genre added to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Genre was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Update_Click(object sender, EventArgs e) { if (GenreDB.UpdateGenre(GetGenreObjFromUI())) { MessageBox.Show("Update Successful."); } else { MessageBox.Show("Update Failed."); } }
private void btn_Add_Click(object sender, EventArgs e) { if (GenreDB.AddGenre(GetGenreObjFromUI())) { MessageBox.Show("Add Successful."); } else { MessageBox.Show("Add Failed."); } }
private void movieForm_Load(object sender, EventArgs e) { Reload_Data(); List <Genre> GenreList = GenreDB.GetGenres(); foreach (Genre genre in GenreList) { cmbGenre.Items.Add(genre.Name); } }
private void genre_Load(object sender, EventArgs e) { try { List <Genre> genreList = new List <Genre>(); genreList = GenreDB.GetGenres(); dataGridView1.DataSource = genreList; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Reload_Data() { try { List <Genre> genreList = new List <Genre>(); genreList = GenreDB.GetGenres(); dataGridView1.DataSource = genreList; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void PopulateGenreCB() { try { List <Genre> genres = GenreDB.GetGenres(); cbGenre.DisplayMember = "Name"; cbGenre.ValueMember = "ID"; cbGenre.DataSource = genres; } catch (Exception) { throw; } }
private void btnBrowse_Click(object sender, EventArgs e) { //Call the GenreDB static class to fill the data grid try { List <Genre> genreList = new List <Genre>(); genreList = GenreDB.GetGenres(); dataGridView1.DataSource = genreList; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btn_Browse_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); foreach (Genre g in GenreDB.GetGenres()) { //put each genre object into a datagridview row object DataGridViewRow newRow = new DataGridViewRow(); //creates cells using dataGridView1 as a template newRow.CreateCells(dataGridView1); newRow.Cells[0].Value = g.id; newRow.Cells[1].Value = g.name; dataGridView1.Rows.Add(newRow); } }
private void btnBrowse_Click(object sender, EventArgs e) { if (!(validateUI(btnBrowse))) { return; } try { List <Genre> myGenreList = new List <Genre>(); myGenreList = GenreDB.GetGenres(); dataGridView1.DataSource = myGenreList; } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MovieDataForm_Load(object sender, EventArgs e) { cmb_Rating.Items.Add("Select a rating"); cmb_Rating.Items.Add("★☆☆☆☆"); cmb_Rating.Items.Add("★★☆☆☆"); cmb_Rating.Items.Add("★★★☆☆"); cmb_Rating.Items.Add("★★★★☆"); cmb_Rating.Items.Add("★★★★★"); cmb_Rating.SelectedIndex = 0; genreList = GenreDB.GetGenres(); cmb_Genre.Items.Add("Select a Genre"); foreach (Genre g in genreList) { cmb_Genre.Items.Add(g.name); } cmb_Genre.SelectedIndex = 0; }
private void btnDelete_Click(object sender, EventArgs e) { //Validate the UI if (string.IsNullOrEmpty(txtGenreID.Text.Trim())) { MessageBox.Show("Please enter a genre id."); txtGenreID.Focus(); return; } if (string.IsNullOrEmpty(txtGenreName.Text.Trim())) { MessageBox.Show("Please enter a genre name."); txtGenreID.Focus(); return; } Genre objGenre = new Genre(); objGenre.ID = Convert.ToInt32(txtGenreID.Text.Trim()); objGenre.Name = txtGenreName.Text.Trim(); try { bool status = GenreDB.DeleteGenre(objGenre); if (status) //You can use this syntax as well..if (status ==true) { Reload_Data(); MessageBox.Show("Genre was deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Genre was not deleted from the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAdd_Click(object sender, EventArgs e) { foreach (Control control in this.Controls) { if (control.GetType() != dataGridView1.GetType()) { if (string.IsNullOrEmpty(control.Text.Trim())) { MessageBox.Show("Please enter a value for " + control.Name.ToString()); control.Focus(); return; } } } List <Genre> genreList = GenreDB.GetGenres(); int genreid = 0; foreach (Genre genre in genreList) { if (genre.Name == cmbGenre.Text.Trim()) { genreid = genre.ID; } } Movie objMovie = new Movie(); objMovie.movie_number = Convert.ToInt32(txtMovieNumber.Text); objMovie.movie_title = txtTitle.Text.ToString(); objMovie.Description = txtDescription.Text.ToString(); objMovie.movie_year_made = Convert.ToInt32(txtYear.Text); objMovie.genre_id = genreid; objMovie.movie_rating = cmbRating.Text; objMovie.media_type = cmbMediaType.Text; objMovie.movie_retail_cost = returnDecimal(txtRetailCost.Text); objMovie.movie_rental_cost = returnDecimal(txtRentalCost.Text); objMovie.copies_on_hand = Convert.ToInt32(txtCopies.Text); objMovie.image = txtImage.Text; objMovie.trailer = txtTrailer.Text; //if(lblPicture.Text != string.Empty) //{ // objMember.photo = lblPicture.Text; //} try { bool status = MovieDB.AddMovie(objMovie); if (status) //You can use this syntax as well..if (status ==true) { Reload_Data(); MessageBox.Show("Movieadded to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Movie was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }