public PhieuMuonSach LayPhieuMuonSach(int id) { QLThuVienDataContext db = new QLThuVienDataContext(); PhieuMuonSach phieu = db.PhieuMuonSaches.Single(p => p.id == id && p.Disable == false); return(phieu); }
public bool TraPhieuMuon(DataGridViewRow row) { PhieuMuonSach item = LayPhieuMuonDGV(row); item.HanTraSach = DateTime.Now.Date; phieuMuonDAL.CapNhatPhieuMuon(item); return(true); }
public bool ThemPhieuMuon(PhieuMuonSach phieuMuon) { using (QLThuVienEntities ThuVienDS = new QLThuVienEntities()) { ThuVienDS.PhieuMuonSaches.Add(phieuMuon); ThuVienDS.SaveChanges(); } return(true); }
public async Task <ActionResult> DeleteConfirmed(int id) { PhieuMuonSach phieuMuonSach = await db.PhieuMuonSaches.FindAsync(id); db.PhieuMuonSaches.Remove(phieuMuonSach); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public bool CapNhatPhieuMuon(PhieuMuonSach phieuMuon) { using (QLThuVienEntities ThuVienDS = new QLThuVienEntities()) { var pMuon = ThuVienDS.PhieuMuonSaches.Find(phieuMuon.MaPhieuMuon); pMuon = phieuMuon; ThuVienDS.SaveChanges(); } return(true); }
public int ThemPhieuMuon(DTO_MuonTraSach MuonTraSach) { PhieuMuonSach pm = new PhieuMuonSach(); pm.NgayMuon = MuonTraSach.ngaymuon; pm.MaDocGia = MuonTraSach.madocgia; tvD.PhieuMuonSaches.InsertOnSubmit(pm); tvD.SubmitChanges(); return pm.MaPhieuMuon; }
public PhieuMuonSach ThemPhieuMuonSach(string maDocGia) { PhieuMuonSach p = new PhieuMuonSach(); p.MaDocGia = Int32.Parse(maDocGia); p.NgayMuon = DateTime.Now; qltvDB.PhieuMuonSaches.InsertOnSubmit(p); qltvDB.SubmitChanges(); return(p); }
public void TKPhieuMuon(TextBox txtMaPhieuMuon, TextBox txtMaNguoiMuon, DateTimePicker dpNgayMuon, DateTime ngayTra, DateTimePicker dpHanTra, DataGridView dgvListPhieuMuon) { PhieuMuonSach phieuMuon = new PhieuMuonSach(); phieuMuon.MaPhieuMuon = txtMaPhieuMuon.Text; phieuMuon.MaNguoiMuon = txtMaNguoiMuon.Text; phieuMuon.NgayMuonSach = dpNgayMuon.Value.Date; phieuMuon.NgayTraSach = ngayTra; phieuMuon.HanTraSach = dpHanTra.Value.Date; dgvListPhieuMuon.DataSource = phieuMuonDAL.TimKiemPhieuMuon(phieuMuon); }
public async Task <ActionResult> Edit([Bind(Include = "MaPhieuMuon,MaDG,NgayMuon")] PhieuMuonSach phieuMuonSach) { if (ModelState.IsValid) { db.Entry(phieuMuonSach).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.MaDG = new SelectList(db.DOCGIAs, "MaDG", "TenDG", phieuMuonSach.MaDG); return(View(phieuMuonSach)); }
public void SuaPhieuMuon(PhieuMuonSach phieuMuonSach, List <ChiTietPhieuMuon> dsChiTietPhieuMuonFinal) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { PhieuMuonSach pmsSua = db.PhieuMuonSaches.Single(pms => pms.id == phieuMuonSach.id); pmsSua.NgayMuon = phieuMuonSach.NgayMuon; pmsSua.HanTra = phieuMuonSach.HanTra; pmsSua.NguoiLapPhieu = phieuMuonSach.NguoiLapPhieu; pmsSua.NguoiMuon = phieuMuonSach.NguoiMuon; foreach (var ctpmUpdate in dsChiTietPhieuMuonFinal) { bool timDuoc = false; foreach (var ctpmCurrent in pmsSua.ChiTietPhieuMuons) { if (ctpmUpdate.MaSach == ctpmCurrent.MaSach && ctpmUpdate.MaPhieuMuon == ctpmCurrent.MaPhieuMuon) { ctpmCurrent.Sach.SoLuongHienCo += (ctpmCurrent.SoLuong - ctpmUpdate.SoLuong); ctpmCurrent.Sach.SoLuongDaMuon -= (ctpmCurrent.SoLuong - ctpmUpdate.SoLuong); ctpmCurrent.SoLuong = ctpmUpdate.SoLuong; timDuoc = true; break; } } if (!timDuoc) { db.ChiTietPhieuMuons.InsertOnSubmit(ctpmUpdate); } } foreach (var ctpmCurrent in pmsSua.ChiTietPhieuMuons) { bool timDuoc = false; foreach (var ctpmUpdate in dsChiTietPhieuMuonFinal) { if (ctpmUpdate.MaSach == ctpmCurrent.MaSach && ctpmUpdate.MaPhieuMuon == ctpmCurrent.MaPhieuMuon) { timDuoc = true; break; } } if (!timDuoc) { ctpmCurrent.Sach.SoLuongHienCo += ctpmCurrent.SoLuong; ctpmCurrent.Sach.SoLuongDaMuon -= ctpmCurrent.SoLuong; db.ChiTietPhieuMuons.DeleteOnSubmit(ctpmCurrent); } } db.SubmitChanges(); } }
public int Sua(PhieuMuonSach pDocGia, string idx) { var result = _context.PhieuMuonSach.Find(idx); if (result != null) { result = pDocGia; _context.PhieuMuonSach.Update(result); return(_context.SaveChanges()); } return(0); }
public ActionResult XoaPhieumuon(int id) { PhieuMuonSach pms = data.PhieuMuonSaches.SingleOrDefault(n => n.MaPhieuMuon == id); ViewBag.MaPhieuMuon = pms.MaPhieuMuon; if (pms == null) { Response.StatusCode = 404; return(null); } return(View(pms)); }
private void ChapThuanPhieuChoMuon() { PhieuMuonSach pms = new PhieuMuonSach(); pms.MaPhieuMuon = int.Parse(txtCMMaP.Text); PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool chapthuanchomuon = pmsbll.ChapThuanPhieuChoMuon(pms); if (chapthuanchomuon) { MessageBox.Show("Đã lưu thông tin mượn sách của đọc giả", "Thông báo"); } }
// GET: PhieuMuonSaches/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuMuonSach phieuMuonSach = await db.PhieuMuonSaches.FindAsync(id); if (phieuMuonSach == null) { return(HttpNotFound()); } return(View(phieuMuonSach)); }
public WindowSuaPhieuMuon(PhieuMuonSach thePhieu) { this.phieuMuonSach = PhieuMuonSachBUS.Instance.LayPhieuMuonSach(thePhieu.id); dsChiTietPhieuMuon = new ObservableCollection <ChiTietPhieuMuon>(this.phieuMuonSach.ChiTietPhieuMuons); dsChiTietPhieuMuon.CollectionChanged += DsChiTietPhieuMuon_CollectionChanged; foreach (var s in dsChiTietPhieuMuon) { s.PropertyChanged += SuaPhieuMuon_PropertyChanged; //s.PropertyChanging += SuaPhieuMuon_PropertyChanging; s.Sach.PropertyChanged += Sach_PropertyChanged; s.Sach.PropertyChanging += Sach_PropertyChanging; } InitializeComponent(); }
private void ChapThuanDuyet() { PhieuMuonSach pms = new PhieuMuonSach(); pms.MaPhieuMuon = int.Parse(txtCDMaP.Text); PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool chapthuan = pmsbll.ChapThuanPhieuDuyet(pms); if (chapthuan) { MessageBox.Show("Bạn Đã Chấp Thuận Phiếu \n Đợi Đọc Giả Đến Nhận Nhé", "Thông Báo"); } }
public ActionResult XacnhanxoaPhieumuon(int id) { PhieuMuonSach pms = data.PhieuMuonSaches.SingleOrDefault(n => n.MaPhieuMuon == id); ViewBag.MaPhieuMuon = pms.MaPhieuMuon; if (pms == null) { Response.StatusCode = 404; return(null); } data.PhieuMuonSaches.Remove(pms); data.SaveChanges(); return(RedirectToAction("PhieuMuon")); }
// GET: PhieuMuonSaches/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuMuonSach phieuMuonSach = await db.PhieuMuonSaches.FindAsync(id); if (phieuMuonSach == null) { return(HttpNotFound()); } ViewBag.MaDG = new SelectList(db.DOCGIAs, "MaDG", "TenDG", phieuMuonSach.MaDG); return(View(phieuMuonSach)); }
public void ThemPhieuMuon(PhieuMuonSach phieuMuonsach) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { phieuMuonsach.TinhTrang = TinhTrangPhieuMuon.CHUA_TRA; db.PhieuMuonSaches.InsertOnSubmit(phieuMuonsach); foreach (ChiTietPhieuMuon ctpm in phieuMuonsach.ChiTietPhieuMuons) { Sach sach = db.Saches.Single(s => s.id == ctpm.MaSach); sach.SoLuongHienCo -= ctpm.SoLuong; sach.SoLuongDaMuon += ctpm.SoLuong; } db.SubmitChanges(); } }
private void pbSearch_Click(object sender, EventArgs e) { lvSach.Items.Clear(); if (checkNhapMaDocGia() == 1) { MessageBox.Show("Mã độc giả không đúng. Vui lòng nhập lại"); txtTimKiem.Text = ""; } else { DocGia p = r.timKiemDocGiaTheoMa(Int32.Parse(txtTimKiem.Text)); lbMa.Text = p.MaDocGia.ToString(); lbTen.Text = p.HoTenDocGia; lbNgaySinh.Text = p.NgaySinh.ToString(); lbDiaChi.Text = p.DiaChi; lbEmail.Text = p.Email; lbNgayDK.Text = p.NgayLapThe.ToString(); lbNgayHetHan.Text = p.NgayHetHan.ToString(); PhieuMuonSach phieu = b.TimPhieuMuonSachCuaDocGia(p.MaDocGia); lbMaPhieu.Text = phieu.MaPhieuMuon.ToString(); //MessageBox.Show(phieu.MaPhieuMuon.ToString()); List <int> list = b1.dsMaSachDocGiaMuon(phieu.MaPhieuMuon); if (list.Count == 0) { MessageBox.Show("Độc giả hiện đang không mượn cuốn sách nào!!!"); lbMaPhieu.Text = ""; } else { foreach (int i in list) { Sach sach = book.timSachTheoMa(i); ListViewItem lvi = new ListViewItem(sach.MaSach.ToString()); lvi.SubItems.Add(sach.TenSach); lvi.SubItems.Add(phieu.NgayMuon.ToString()); lvSach.Items.Add(lvi); } } } }
private void btnSuaPhieuMuonClick(object sender, RoutedEventArgs e) { PhieuMuonSach pmsDangChon = pageDSPhieuMuon.LayPhieuMuonSachDangChon(); if (pmsDangChon == null) { return; } WindowSuaPhieuMuon wd = new WindowSuaPhieuMuon(pmsDangChon); if (wd.ShowDialog() == true) { pageDSPhieuMuon.RefreshDanhSach(); } }
public PhieuMuonSach LayPhieuMuonDGV(DataGridViewRow row) { PhieuMuonSach item = new PhieuMuonSach(); if (row.Cells[1].Value != null) { item.MaNguoiMuon = row.Cells[0].Value.ToString(); } else { return(item); } item.MaNguoiMuon = "none"; item.NgayMuonSach = Convert.ToDateTime(01 / 01 / 01); item.HanTraSach = Convert.ToDateTime(01 / 01 / 01); return(phieuMuonDAL.TimKiemPhieuMuon(item)[0]); }
private void ChoMuonSachTaiCho() { PhieuMuonSach pms = new PhieuMuonSach(); pms.NguoiMuonSachId = this.madg; pms.SachId = this.masach; pms.NgayMuon = dtCMTCNgayMuon.Value; pms.NgayDuKienTra = dtCMTCDuKienTra.Value; PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool phieumoi = pmsbll.ThemPhieuMuon(pms); if (phieumoi) { MessageBox.Show("Đã Lưu thông tin mượn sách của đọc giả", "Thông Báo"); } }
public void ThemPhieuMuon(string nguoiMuon, int nguoiLapPhieu, DateTime ngayMuon, DateTime ngayTra, List <ChiTietPhieuMuon> dsChiTietPhieuMuon) { PhieuMuonSach phieuMuonSach = new PhieuMuonSach() { NguoiMuon = nguoiMuon, NguoiLapPhieu = nguoiLapPhieu, NgayMuon = ngayMuon, HanTra = ngayTra }; foreach (ChiTietPhieuMuon ctpm in dsChiTietPhieuMuon) { ctpm.PhieuMuonSach = phieuMuonSach; phieuMuonSach.ChiTietPhieuMuons.Add(ctpm); } PhieuMuonSachDAO.Instance.ThemPhieuMuon(phieuMuonSach); }
private void TuChoiPhieuChoMuon() { PhieuMuonSach pms = new PhieuMuonSach(); pms.MaPhieuMuon = int.Parse(txtCMMaP.Text); PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool tuchoichomuon = pmsbll.TuChoiPhieuChoMuon(pms); Sach sac = new Sach(); sac.TenSach = txtCMS.Text; SachBLL sacbll = new SachBLL(); bool dgkhongden = sacbll.CapNhatDocGiaKhongDen(sac); if (dgkhongden && tuchoichomuon) { MessageBox.Show("Đã cập nhật thông tin", "Thông báo"); } }
private void TaoPhieuMoi() { PhieuMuonSach pms = new PhieuMuonSach(); pms.NguoiMuonSachId = int.Parse(txtConfirmMaDocGia.Text); pms.SachId = int.Parse(txtConfirmMaSach.Text); pms.NgayMuon = datetimeConfirmNgayMuon.Value; pms.NgayDuKienTra = datetimeConfirmNgayDuKienTra.Value; PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool phieumoi = pmsbll.ThemPhieuMuon(pms); if (phieumoi) { MessageBox.Show("Nhấn nút cập nhật nhé!!!", "Thông Báo"); this.Close(); } }
private void UserTaoPhieu() { PhieuMuonSach pms = new PhieuMuonSach(); pms.NguoiMuonSachId = int.Parse(iddg); pms.SachId = int.Parse(txtMaSach.Text); pms.NgayMuon = dateNgayMuon.Value; pms.NgayDuKienTra = dateDuKienTra.Value; PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool phieumoi = pmsbll.DocGiaTaoPhieu(pms); if (phieumoi) { MessageBox.Show("Mượn thành công, vui lòng chờ duyệt và đến thư viện nhận sách nhé." + "\n Bạn có thể kiểm tra trạng thái ở tab Sách Mượn Của Tôi", "Thông Báo"); } }
private void KhongTraSach() { PhieuMuonSach pms = new PhieuMuonSach(); pms.MaPhieuMuon = int.Parse(txtTSMaP.Text); PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool tuchoi = pmsbll.TuChoiPhieuDuyet(pms); Sach sac = new Sach(); sac.TenSach = txtTSS.Text; SachBLL sacbll = new SachBLL(); bool capnhat = sacbll.CapNhatTrangThaiLoi(sac); if (capnhat && tuchoi) { MessageBox.Show("Đã lưu thông tin", "Thông Báo"); LoadLDS(); } }
private void SachBiLoi() { PhieuMuonSach pms = new PhieuMuonSach(); pms.MaPhieuMuon = int.Parse(txtCDMaP.Text); PhieuMuonSachBLL pmsbll = new PhieuMuonSachBLL(); bool tuchoi = pmsbll.TuChoiPhieuDuyet(pms); Sach sac = new Sach(); sac.TenSach = txtCDS.Text; SachBLL sacbll = new SachBLL(); bool capnhat = sacbll.CapNhatTrangThaiLoi(sac); if (capnhat && tuchoi) { MessageBox.Show("Bạn Đã Từ Chối Phiếu Duyệt \n Xử lý sách bị lỗi nhé", "Thông Báo"); LoadLDS(); } }
private void btnMuon_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtMaDG.Text)) { MessageBox.Show("Vui lòng chọn thông tin độc giả "); } else { if (lvSach.SelectedItems.Count > 0) { PhieuMuonSach p = br.ThemPhieuMuonSach(txtMaDG.Text); brDt.ThemChiTietPhieuMuonSach(lvSach.SelectedItems[0].SubItems[0].Text, p.MaPhieuMuon); MessageBox.Show("Mượn thành công sách " + lvSach.SelectedItems[0].SubItems[1].Text); } else { MessageBox.Show("Vui lòng chọn sách cần mượn"); } } }