示例#1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult dialog = new DialogResult();

            dialog = XtraMessageBox.Show("Bạn có muốn xóa công trình này không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dialog == DialogResult.Yes)
            {
                bool kq = ctBLL.xoaCongTrinh(dataGridView1.CurrentRow.Cells[0].Value.ToString());

                if (kq)
                {
                    XtraMessageBox.Show("Xóa công trình thành công");
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = ctBLL.getAllCongTrinh();
                    loadDataCellCongTrinh();
                }
                else
                {
                    XtraMessageBox.Show("Xóa công trình thất bại !!");
                    dataGridView1.DataSource = null;
                    dataGridView1.DataSource = ctBLL.getAllCongTrinh();
                    loadDataCellCongTrinh();
                }
            }
            else
            {
                dialog = DialogResult.Cancel;
            }
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            DialogResult dg = new DialogResult();

            dg = XtraMessageBox.Show("Bạn có muốn xoá công trình không !", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dg == DialogResult.Yes)
            {
                // var nv = db.NhanViens.Single(a => a.maNhanVien == tbMaNV.Text);
                // var tk = db.TaiKhoans.Single(a => a.maNhanVien == tbMaNV.Text);
                // db.NhanViens.DeleteOnSubmit(nv);
                // db.TaiKhoans.DeleteOnSubmit(tk);
                // db.SubmitChanges();
                try
                {
                    _maCongTrinh = tbMaCongTrinh.Text;
                    _trangThai   = ctbll.layTrangThai(_maCongTrinh);
                    if (ctbll.xoaCongTrinh(_maCongTrinh))
                    {
                        XtraMessageBox.Show("Xoá thành công !");
                        if (_trangThai.CompareTo("DXD") == 0)
                        {
                            xoaAllTB();
                            loadDataThiCong();
                            btnSua.Enabled = false;
                            btnXoa.Enabled = false;
                        }
                        else
                        {
                            xoaAllTB();
                            loadDataHoanThanh();
                            btnXoa.Enabled = false;
                            btnSua.Enabled = false;
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Bị trùng mã nhân viên, vui lòng nhập mã khác !");
                    }
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show("Lỗi: " + ex);
                }
            }
            else
            {
                dg = DialogResult.Cancel;
            }
        }