protected void btnXoa_Click(object sender, EventArgs e) { Regex reg = new Regex(@"^[P]\d{2,5}$"); if (!reg.IsMatch(txtMaPhieu.Text)) { alertz("Sai định dạng mã phiếu, ví dụ: P01"); return; } try { //xoa PhieuMuonSachBUS obj_phieu = new PhieuMuonSachBUS(); obj_phieu.XoaPhieu(txtMaPhieu.Text); txtMaPhieu.Text = ""; //txtMaDocGia.Text = ""; //txtMaNhanVien.Text = ""; drNhanVien.Enabled = false; drDocGia.Enabled = false; alertz("Đã xóa"); } catch { alertz("Lỗi Xóa - Phiếu mượn đang tồn tại các thông tin tài liệu mượn"); } }
//Xóa private void button2_Click(object sender, EventArgs e) { Regex reg = new Regex(@"^[P]\d{2,5}$"); if (!reg.IsMatch(txtMaPhieu.Text)) { MessageBox.Show("Sai định dạng mã phiếu, ví dụ: P01"); return; } DialogResult tb = MessageBox.Show("Bạn có muốn xóa mã phiếu: " + txtMaPhieu.Text, "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (tb == DialogResult.Yes) { try { //xoa obj_phieu.XoaPhieu(txtMaPhieu.Text); txtMaPhieu.Text = ""; txtMaDocGia.Text = ""; txtMaNhanVien.Text = ""; MessageBox.Show("Đã xóa"); } catch { MessageBox.Show("Lỗi Xóa - Phiếu mượn đang tồn tại các thông tin tài liệu mượn"); } } else { return; } }