예제 #1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            bool flag = this.dgvTaiKhoan.SelectedRows != null && this.dgvTaiKhoan.SelectedRows.Count > 0;

            if (flag)
            {
                DataRow row   = ((DataRowView)this.dgvTaiKhoan.SelectedRows[0].DataBoundItem).Row;
                bool    flag2 = (int)row["NguoiDungId"] == GlobalVariable.NguoiDungId;
                if (flag2)
                {
                    MessageBox.Show("Không thể xoá tài khoản " + row["TenDangNhap"].ToString() + Environment.NewLine + "Tài khoản cần xoá là của chính bạn!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    bool flag3 = MessageBox.Show("Bạn có chắc chắn muốn xoá tài khoản " + row["TenDangNhap"].ToString(), "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK;
                    if (flag3)
                    {
                        bool flag4 = ManageBase.DeleteNguoiDung((int)row["NguoiDungId"]);
                        if (flag4)
                        {
                            this._bindingTaiKhoan.RemoveAt(this.dgvTaiKhoan.SelectedRows[0].Index);
                            MessageBox.Show("Đã xoá tài khoản thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            this.btnCapNhat.Tag = 0;
                            this.dgvTaiKhoan_SelectionChanged(null, null);
                        }
                        else
                        {
                            MessageBox.Show("Xoá tài khoản không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Không có tài khoản được chọn!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }