private void btnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (MessageBox.Show("Bạn có chắc muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //DocGia_BUS.xoaSV(gvDocGia.GetFocusedRowCellValue(colMaSV).ToString()); DocGia_BUS.xoaDG(gvDocGia.GetFocusedRowCellValue(colMaDG).ToString()); DGbindingSource.RemoveAt(gvDocGia.FocusedRowHandle); MessageBox.Show("Xóa thành công!"); } }
private void btnHuy_Click(object sender, EventArgs e) { if (!them && gvDocGia.FocusedRowHandle == gvDocGia.RowCount - 1) { them = true; DGbindingSource.RemoveAt(gvDocGia.RowCount - 1); } //hủy khi sửa else { tbMaDG.Text = gvDocGia.GetFocusedRowCellValue(colMaDG).ToString(); tbTenDG.Text = gvDocGia.GetFocusedRowCellValue(colTenDG).ToString(); //ToUpper để convert sang chữ in hoa if (gvDocGia.GetFocusedRowCellValue(colGioiTinh).ToString().ToUpper() == "NAM") { cboGioiTinh.SelectedIndex = 0; } else { cboGioiTinh.SelectedIndex = 1; } if (gvDocGia.GetFocusedRowCellValue(colNgaySinh).ToString() != "") { dtpNgaySinh.Value = DateTime.Parse(gvDocGia.GetFocusedRowCellValue(colNgaySinh).ToString()); } if (gvDocGia.GetFocusedRowCellValue(colNgayCapThe).ToString() != "") { dtpNgayCapThe.Value = DateTime.Parse(gvDocGia.GetFocusedRowCellValue(colNgayCapThe).ToString()); } if (gvDocGia.GetFocusedRowCellValue(colNgayHetHan).ToString() != "") { dtpNgayHetHan.Value = DateTime.Parse(gvDocGia.GetFocusedRowCellValue(colNgayHetHan).ToString()); } tbSDT.Text = gvDocGia.GetFocusedRowCellValue(colSDT).ToString(); tbDiaChi.Text = gvDocGia.GetFocusedRowCellValue(colDiaChi).ToString(); tbDonVi.Text = gvDocGia.GetFocusedRowCellValue(colDonVi).ToString(); } }