//Get Data From databases, post to Data Grid View public void binding() { DataSet data = new GamesDao().ShowGames(); dgv_games.DataSource = data; dgv_games.DataMember = "games"; DataGridViewColumn column0 = dgv_games.Columns[0]; column0.Width = 35; column0.HeaderText = "No"; DataGridViewColumn column1 = dgv_games.Columns[1]; column1.Width = 100; column1.HeaderText = "Games ID"; DataGridViewColumn column2 = dgv_games.Columns[2]; column2.Width = 190; column2.HeaderText = "Games Category"; DataGridViewColumn column3 = dgv_games.Columns[3]; column3.Width = 100; column3.HeaderText = "Price"; }
private void btn_cari_Click(object sender, EventArgs e) { if (txt_cari.Text == "") { MessageBox.Show("Please Input Keywords ! ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } Games g = new Games(); if (cmb_cari.Text == "Games Category") { try { g.nama_games = txt_cari.Text; DataSet ds = new GamesDao().FindByName(g); dgv_games.DataSource = ds; dgv_games.DataMember = "games"; eventclickgrid(); } catch (DataException) { MessageBox.Show("Games Category Not Found !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (cmb_cari.Text == "Games ID") { try { g.id_games = txt_cari.Text; DataSet ds = new GamesDao().FindById(g); dgv_games.DataSource = ds; dgv_games.DataMember = "games"; eventclickgrid(); } catch (DataException) { MessageBox.Show("Games ID Not Found !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void Frm_rpt_games_Load(object sender, EventArgs e) { DataSet data = new GamesDao().ShowGames(); DataTable dt = new DataTable(); dt = data.Tables[0]; Cr_games obj_rpt = new Cr_games(); obj_rpt.SetDataSource(dt); Crv_games.ReportSource = obj_rpt; Crv_games.Refresh(); }