Beispiel #1
0
 //delete
 private void pictureBox2_Click(object sender, EventArgs e)
 {
     page_DatPhong.SetPage(0);
     if (kt_DatPhong == true)
     {
         return;
     }
     else
     {
         DTO_CTHD obj_cthd = new DTO_CTHD();
         obj_cthd.Macthd = get_MaCTHD;
         if (bus_cthd.Delete(obj_cthd) != "0")
         {
             MessageBox.Show("Lỗi");
         }
         //delete cthd
         DTO_KhachHang obj_kh = new DTO_KhachHang();
         obj_kh.Makh = txb_MaKH.Text;
         if (bus_kh.Delete(obj_kh) != "0")
         {
             MessageBox.Show("Lỗi");
         }
         //    delete kh
         //update phong
         objp.Status = "EMPTY";
         bus_p.Update(objp);
     }
 }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (txtMaKhachHang.Text.Trim() != "")
            {
                try
                {
                    if (busKhachHang.Delete(txtMaKhachHang.Text))
                    {
                        MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Xóa không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                catch (Exception a)
                {
                    MessageBox.Show("Xóa không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    TaoLai();
                }
            }
            else
            {
                MessageBox.Show("Vui lòng chọn một hàng trong danh sách!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #3
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            int i = -1; string s = "";

            if (radioBtnKH.Checked)
            {
                try
                {
                    KhachHang ob = new KhachHang(txtMa.Text, txtTen.Text, txtDC.Text, txtDT.Text, txtEmail.Text);
                    i = kh.Delete(ob);
                }
                catch { s = "Dữ liệu đã nhập không phù hợp!\n Mời nhập lại!!"; }
            }
            else if (radioBtnNCC.Checked)
            {
                try
                {
                    NhaCC ob = new NhaCC(txtMa.Text, txtTen.Text, txtDC.Text, txtDT.Text, txtEmail.Text);
                    i = ncc.Delete(ob);
                }
                catch { s = "Dữ liệu đã nhập không phù hợp!\n Mời nhập lại!!"; }
            }
            switch (i)
            {
            case -2:
                s = "Lỗi kết nối!!";
                break;

            case 1:
                s = "Xóa thành công!!";
                btnLoad_Click(sender, e);
                break;

            case 2:
                s = "Không thể xóa dữ liệu!!\n Mã đối tác này không tồn tại!!";
                break;

            case 3:
                s = "Không thể xóa!!\n Đối tác này tồn tại trong bảng giao dịch!";
                break;

            case 0:
                s = "Lỗi!! Không thể xóa dữ liệu!!";
                break;
            }
            MessageBox.Show(s, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }