// Bind rented movies grid private void BindGridRentedMovies() { DataTable ds = new RentalMovieAction().GetAllRentedData(); gvRental.DataSource = ds; gvRental.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); }
// Bind comboBox Rented movie private void BindDDLRentedMovies() { DataTable dsRented = new RentalMovieAction().GetRentedMoviesDDL(); ddlRentedMovies.DisplayMember = "Title"; ddlRentedMovies.ValueMember = "MovieID"; ddlRentedMovies.DataSource = dsRented; }
// show most popular movies private void btnMostPopulrMovies_Click(object sender, EventArgs e) { if (TabControl.SelectedTab == TabControl.TabPages["RentedMovies"]) { try { DataTable dt = new RentalMovieAction().MostPopularMovies(); gvRental.DataSource = dt; gvRental.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Please select RENTED MOVIES tab first!"); } }
/// <summary> /// Bind the ddl Rented movie by customer /// </summary> private void ddlAllCust_SelectedIndexChanged(object sender, EventArgs e) { try { int customerID = int.Parse(ddlAllCust.SelectedValue.ToString()); if (customerID > 0) { ddlRentedMovies.Enabled = true; DataTable dsRented = new RentalMovieAction().GetRentedMoviesDDL(customerID); if (dsRented.Rows.Count > 0) { DataRow row = dsRented.NewRow(); row[0] = 0; row[1] = "--Please select--"; dsRented.Rows.InsertAt(row, 0); // add item at INDEX = 0; ddlRentedMovies.DisplayMember = "Title"; ddlRentedMovies.ValueMember = "MovieID"; ddlRentedMovies.DataSource = dsRented; } else { ddlRentedMovies.Enabled = false; } } else { ddlRentedMovies.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }