private void btnDelete_Click(object sender, EventArgs e) { if (dgvCategory.CurrentRow != null) { if (MyMessageBox.Question("Bạn có chắn xóa bản ghi đã chọn không?")) { int curRowIdx = dgvCategory.CurrentRow.Index; int idNeedDel = Convert.ToInt32(dgvCategory.Rows[curRowIdx].Cells["CategoryID"].Value.ToString()); DataTableHelpers.RemoveRow(dataTable, "CategoryID", idNeedDel); sqlHelper.Update(dataTable); } } }
private void btnDelete_Click(object sender, EventArgs e) { int rowIdxNeedDel = dgvProduct.CurrentRow.Index; int idNeedDel = Convert.ToInt32(dgvProduct.Rows[rowIdxNeedDel].Cells["ProductID"].Value.ToString()); if (MyMessageBox.Question("Bạn có chắn xóa bản ghi đã chọn không?")) { bool isSuccess = ProductHelpers.Delete(idNeedDel); if (isSuccess) { dataTable.Rows[rowIdxNeedDel].Delete(); } else { MyMessageBox.Error("Xoá bản ghi thất bại!"); } } }