예제 #1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(maTaiKhoanXoa))
     {
         if (bd.DeleteTaiKhoan(ref err, ref rows, maTaiKhoanXoa))
         {
             HienThiDanhSachTaiKhoan();
             maTaiKhoanXoa  = string.Empty;
             btnSua.Enabled = false;
             btnXoa.Enabled = false;
         }
     }
 }
예제 #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (txtTenDangNhap.Text == "admin")
            {
                MessageBox.Show("Không thể xóa tài khoản admin");
            }
            else
            {
                //Hiện hộp thoại hỏi
                DialogResult result3;
                result3 = MessageBox.Show("Bạn có chắc muốn xóa ?", "Thông báo",
                                          MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                //Kiểm tra có chọn Yes or No
                if (result3 == DialogResult.Yes)
                {
                    try
                    {
                        //Lấy thứ tự của record hiện hành
                        int r = dgvTaiKhoan.CurrentCell.RowIndex;
                        //Lấy MaPhim của record hiện hành
                        string TenTK = txtTenDangNhap.Text;

                        //Khai báo biến
                        bool   f   = false;
                        string err = "";
                        //Gọi Strored Procedure để Update data
                        f = dbTaiKhoan.DeleteTaiKhoan(ref err, TenTK);
                        //Kiểm tra để thông báo
                        if (f == true)
                        {
                            //Sau khi Delete xong Load lại data
                            LoadData();
                            //Xóa trống các đối tượng trên panel
                            //
                            MessageBox.Show("Delete Thành công!!!");
                        }
                        else
                        {
                            MessageBox.Show("Error:" + err);
                        }
                    }
                    catch (SqlException)
                    {
                        MessageBox.Show("Delete lỗi!!!", "Thông báo",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }