private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string colname = dataGridView1.Columns[e.ColumnIndex].Name; if (colname == "Edit") { BrandModule brand = new BrandModule(this); brand.lblID.Text = dataGridView1[1, e.RowIndex].Value.ToString(); brand.txt_brand.Text = dataGridView1[2, e.RowIndex].Value.ToString(); brand.ShowDialog(); } else if (colname == "Delete") { if (MessageBox.Show("Are you sure you want to Delete this brand?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { conn.Open(); cmd = new SqlCommand("delete from tblBrand where id like'" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", conn); cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("Brand Delete Successfully", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information); Loadrecords(); } } }
private void button1_Click(object sender, EventArgs e) { BrandModule module = new BrandModule(this); module.ShowDialog(); }