private void txtFormatID_TextChanged(object sender, EventArgs e) { string movieID = (string)dtgvFormat.SelectedCells[0].OwningRow.Cells["Mã phim"].Value; Movie movieSelecting = MovieDAO.GetMovieByID(movieID); //This is the Movie that we're currently selecting in dtgv if (movieSelecting == null) { return; } //cboFormat_MovieID.SelectedItem = movieSelecting; int indexMovie = -1; int iMovie = 0; foreach (Movie item in cboFormat_MovieID.Items) { if (item.Name == movieSelecting.Name) { indexMovie = iMovie; break; } iMovie++; } cboFormat_MovieID.SelectedIndex = indexMovie; string screenName = (string)dtgvFormat.SelectedCells[0].OwningRow.Cells["Tên MH"].Value; ScreenType screenTypeSelecting = ScreenTypeDAO.GetScreenTypeByName(screenName); //This is the ScreenType that we're currently selecting in dtgv if (screenTypeSelecting == null) { return; } //cboFormat_ScreenID.SelectedItem = screenTypeSelecting; int indexScreen = -1; int iScreen = 0; foreach (ScreenType item in cboFormat_ScreenID.Items) { if (item.Name == screenTypeSelecting.Name) { indexScreen = iScreen; break; } iScreen++; } cboFormat_ScreenID.SelectedIndex = indexScreen; }
private void txtMovieID_TextChanged(object sender, EventArgs e) //Use to binding the CheckedListBox Genre of Movie and picture of Movie { picFilm.Image = null; for (int i = 0; i < clbMovieGenre.Items.Count; i++) { clbMovieGenre.SetItemChecked(i, false); //Uncheck all CheckBox first } List <Genre> listGenreOfMovie = MovieByGenreDAO.GetListGenreByMovieID(txtMovieID.Text); for (int i = 0; i < clbMovieGenre.Items.Count; i++) { Genre genre = (Genre)clbMovieGenre.Items[i]; foreach (Genre item in listGenreOfMovie) { if (genre.ID == item.ID) { clbMovieGenre.SetItemChecked(i, true); break; } } } Movie movie = MovieDAO.GetMovieByID(txtMovieID.Text); if (movie == null) { return; } if (movie.Poster != null) { picFilm.Image = MovieDAO.byteArrayToImage(movie.Poster); } }