private void LoadDB() { try { DGVCustomer.DataSource = MyDatabase.FillDataGridViews("Customer"); DGVCustomer.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); DGVMovies.DataSource = MyDatabase.FillDataGridViews("Movies"); DGVMovies.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); DGVRentedMovies.DataSource = MyDatabase.FillDataGridViews("RentedMovies"); DGVRentedMovies.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); DGVMostPopular.DataSource = MyDatabase.FillPopularDGV("MoviesRented"); DGVMostPopular.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); DGVCustomerRank.DataSource = MyDatabase.FillPopularDGV("CustomersRentedMovies"); DGVCustomerRank.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } catch (System.Exception ex) { MessageBox.Show(" Error Something went wrong... " + ex.Message); } }
//load the customer into dgv private void DisplayDGVcustomer() { //clear all the old data DGVCustomer.DataSource = null; try { DGVCustomer.DataSource = myDatabase.FillDGVcustomers(); //pass the dataTable data to the DGV DGVCustomer.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void popularCustomer_Click_1(object sender, EventArgs e) { //clear all the old data DGVCustomer.DataSource = null; try { DGVCustomer.DataSource = myDatabase.DGVPopularCustumers(); //pass the dataTable data to the DGV DGVCustomer.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); popularCustomer.Hide(); btnAllCustomer.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }