Ejemplo n.º 1
0
        private void btXoaTruong_Click(object sender, EventArgs e)
        {
            var confirmResult = MessageBox.Show("Bạn chắc chắn muốn xóa ?",
                                                "Confirm Delete",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (confirmResult == DialogResult.Yes)
            {
                try
                {
                    string id = dgvTruong.SelectedRows[0].Cells[1].Value.ToString();
                    bll.DeleTSTruong_BLL(id);
                    dgvTruong.DataSource = null;
                    dgvTruong.DataSource = bll.GetInfoNhapTruong_BLL();
                    stt(dgvTruong);
                    MessageBox.Show("Thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception)
                {
                    MessageBox.Show("Không được phép xóa vì có ràng buộc với bảng CHỨNG TỪ GIẢM!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Không thực hiện xóa !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }