private void btnDelete_Click(object sender, EventArgs e) { if (dgvBrand.SelectedRows.Count <= 0) { return; } DialogResult dr = MessageBox.Show("Are you sure ?", "Confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr != DialogResult.Yes) { return; } DAL.Brand br = new DAL.Brand(); br.Id = Convert.ToInt32(dgvBrand.SelectedRows[0].Cells["colId"].Value); if (br.Delete()) { MessageBox.Show("Deleted"); btnSearch.PerformClick(); } else { MessageBox.Show(br.Error); } }
private void buttonDelete_Click(object sender, EventArgs e) { if (proGrid1.SelectedRows.Count <= 0) { return; } DialogResult confurmDelete = MessageBox.Show("Are you sure?", "Confirmation.", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (confurmDelete != DialogResult.Yes) { return; } DAL.Brand brandDelete = new DAL.Brand(); string ids = ""; for (int i = 0; i < proGrid1.SelectedRows.Count; i++) { ids += proGrid1.SelectedRows[i].Cells["ColId"].Value.ToString() + ", "; } ids = ids.Substring(0, ids.Length - 2); if (brandDelete.Delete(ids)) { MessageBox.Show("Data deleted"); buttonSearch.PerformClick(); } else { MessageBox.Show(brandDelete.Error); } }