protected void btnTaoPhieu_Click(object sender, EventArgs e) { //regex 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; } //if (txtTenNhanVien.Text == "" || txtTenDocGia.Text == "") //{ // alertz("Hãy nhập đầy đủ thông tin"); // return; //} //them phieu try { PhieuMuonSachBUS obj_phieu = new PhieuMuonSachBUS(); DateTime ngayMuon = DateTime.Parse(txtNgayMuon.Text); PhieuMuon pm = new PhieuMuon(txtMaPhieu.Text, drDocGia.SelectedValue, drNhanVien.SelectedValue, ngayMuon); obj_phieu.themPhieu(pm); alertz("Tạo phiếu thành công, nhập tài liệu mượn"); //cho phép nhập và hiển thị thông tin chi tiết tài liệu mượn của Phiếu vừa tạo ra: loadDgv(); } catch { alertz("Đã tồn tại mã phiếu: " + txtMaPhieu.Text); } }
//lưu private void button1_Click(object sender, EventArgs e) { //regex 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; } if (txtTenNhanVien.Text == "" || txtTenDocGia.Text == "") { MessageBox.Show("Hãy nhập đầy đủ thông tin"); return; } //them phieu try { DateTime ngayMuon = dtpNgayMuon.Value; PhieuMuon pm = new PhieuMuon(txtMaPhieu.Text, txtMaDocGia.Text, txtMaNhanVien.Text, ngayMuon); obj_phieu.themPhieu(pm); MessageBox.Show("Tạo phiếu thành công, nhập tài liệu mượn"); //cho phép nhập và hiển thị thông tin chi tiết tài liệu mượn của Phiếu vừa tạo ra: loadDgv(); } catch { MessageBox.Show("Đã tồn tại mã phiếu: " + txtMaPhieu.Text); } }