Esempio n. 1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            //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 = dgvKhachHang.CurrentCell.RowIndex;
                    //Lấy MaPhim của record hiện hành
                    string MaKH = txtMaKH.Text;

                    //Khai báo biến
                    bool   f   = false;
                    string err = "";
                    //Gọi Strored Procedure để Update data
                    f = dbKhachHang.DeleteKhachHang(ref err, MaKH);
                    //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);
                }
            }
        }
Esempio n. 2
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (cboLoaiKhachHang.SelectedValue.ToString() == "KVL")
     {
         MessageBox.Show("Dữ liệu mặc định. Không thể xóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (bllKhachHang.KiemTraKhoaNgoaiKhachHang(txtMaKhachHang.Text))
     {
         MessageBox.Show("Khách hàng này liên quan đến hóa đơn. Không thể xóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (MessageBox.Show("Xóa khách hàng " + txtHoTen.Text + "?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         bllKhachHang.DeleteKhachHang(txtMaKhachHang.Text);
         LoadKhachHang(cboLoaiKhachHang.SelectedValue.ToString());
         btnXoa.Visible = false;
         btnSua.Visible = false;
         btnLuu.Visible = false;
         ClearText();
     }
 }