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); } }
public string createRentDetail(ChiTietMuon e) { ChiTietMuon obj = db.ChiTietMuons.SingleOrDefault(x => x.MaPhieuMuon == e.MaPhieuMuon && x.MaSach == e.MaSach); PhieuMuon rentcard = db.PhieuMuons.SingleOrDefault(x => x.MaPhieuMuon == e.MaPhieuMuon); DocGia reader = db.DocGias.SingleOrDefault(x => x.MaDocGia == rentcard.MaDocGia); LoaiTheThuVien cardtype = db.LoaiTheThuViens.SingleOrDefault(x => x.MaLoaiThe == reader.MaLoaiThe); if (obj == null) { if (countQuantityBookBorrowed(rentcard.MaPhieuMuon) + e.SoLuong <= cardtype.SoSachToiDa) { db.ChiTietMuons.Add(e); db.SaveChanges(); return("Thêm mới thành công!"); } else { return("Thẻ của bạn không thể mượn quá số lượng!"); } } else { if (e.SoLuong <= cardtype.SoSachToiDa) { obj.SoLuong = e.SoLuong; db.SaveChanges(); return("Bản ghi đã tồn tại. Chỉ có thể thay đổi số lượng!"); } else { return("Thẻ của bạn không thể mượn quá số lượng!"); } } }
public void deleteRentCard(int id) { PhieuMuon e = db.PhieuMuons.SingleOrDefault(x => x.MaPhieuMuon == id); db.PhieuMuons.Remove(e); db.SaveChanges(); }
public void editRentCard(PhieuMuon e) { PhieuMuon obj = db.PhieuMuons.SingleOrDefault(x => x.MaPhieuMuon == e.MaPhieuMuon); obj.NgayMuon = e.NgayMuon; obj.HanTra = e.HanTra; obj.NgayTra = e.NgayTra; obj.TinhTrangTra = e.TinhTrangTra; db.SaveChanges(); }
public void createRentCard(PhieuMuon e) { db.PhieuMuons.Add(e); db.SaveChanges(); }