private void btnXoaBM_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa bộ môn này?", "Verify!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int cur = dataBomon.CurrentRow.Index; DataRow row = cn.LoadTable(sql).Rows[cur]; DAL_BOMON bm = new DAL_BOMON(row); DAO_BOMON daoBM = new DAO_BOMON(); int check = daoBM.Delete_BM(bm); int index = cur == dataBomon.RowCount - 1 ? dataBomon.RowCount - 2 : cur; if (check != 0) { dataBomon.DataSource = cn.LoadTable(sql); if (dataBomon.RowCount > 1) { dataBomon.CurrentCell = dataBomon.Rows[index].Cells[0]; } } else { MessageBox.Show("Không xóa được học phần này!", "Thông báo!"); } hienthiBomon(); } }