private void btnxoa_Click(object sender, EventArgs e) { try { int r = dgrNN.CurrentCell.RowIndex; string strma = dgrNN.Rows[r].Cells[0].Value.ToString(); string strmasach = dgrNN.Rows[r].Cells[1].Value.ToString(); DialogResult traloi; traloi = MessageBox.Show("Chắc xóa mẫu tin này không?", "Trả lời", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (traloi == DialogResult.Yes) { dbS.Xoa(ref err, strma, strmasach); LoadData(); MessageBox.Show("Đã xóa xong!"); if (hdb.DemMa(txtMaHDban.Text) == 0) { hdb.Xoa(ref err, txtMaHDban.Text); } ; } else { MessageBox.Show("Không thực hiện việc xóa mẫu tin!"); } } catch { MessageBox.Show("Không xóa được!"); } }