Exemplo n.º 1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                int r = gvSinhVien.FocusedRowHandle;

                string       strSinhVien = gvSinhVien.GetRowCellValue(r, "MaSV").ToString();
                DialogResult traloi;
                traloi = XtraMessageBox.Show("Chắc xóa mẫu tin này không?", "Trả lời", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (traloi == DialogResult.OK)
                {
                    dbSV.XoaSinhVien(strSinhVien, ref err);

                    LoadData();

                    XtraMessageBox.Show("Đã xóa xong!");
                }
                else
                {
                    XtraMessageBox.Show("Không thực hiện việc xóa mẫu tin!");
                }
            }
            catch
            {
                XtraMessageBox.Show("Không xóa được. Lỗi rồi!");
            }
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            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)
            {
                if (dbSinhVien.KiemTraSinhVienTonTaiKhac(this.txtMaSV.Text, ref err))
                {
                    MessageBox.Show("Bạn phải xóa Mẫu SinhVien " + this.txtMaSV.Text + " từ bảng KẾT QUẢ HỌC TẬP.", "Thông báo!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (dbSinhVien.XoaSinhVien(this.txtMaSV.Text, ref err))
                    {
                        LoadData();
                        MessageBox.Show("Đã xóa xong!");
                    }
                    else
                    {
                        MessageBox.Show("Không xóa được. Lỗi rồi!!! " + err);
                    }
                }
            }
            else
            {
                MessageBox.Show("Không thực hiện việc xóa mẫu tin!");
            }
        }