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 void ThemDocGia(DocGia docGia) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { db.DocGias.InsertOnSubmit(docGia); db.SubmitChanges(); } }
public void ThemSach(Sach sach) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { db.Saches.InsertOnSubmit(sach); db.SubmitChanges(); } }
public void SuaNhaXuatBan(NhaXuatBan nhaXuatBan) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { NhaXuatBan nxbSua = db.NhaXuatBans.Single(nxb => nxb.pid == nhaXuatBan.pid); nxbSua.Ten = nhaXuatBan.Ten; db.SubmitChanges(); } }
public void XoaNganhKhoa(string pid) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { NganhKhoa nkXoa = db.NganhKhoas.Single(nk => nk.pid == pid); nkXoa.Disable = true; db.SubmitChanges(); } }
public void SuaNganhKhoa(NganhKhoa nganhKhoa) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { NganhKhoa nkMoi = db.NganhKhoas.Single(nk => nk.pid == nganhKhoa.pid); nkMoi.Ten = nganhKhoa.Ten; db.SubmitChanges(); } }
public void SuaLoaiSach(LoaiSach loaiSach) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { LoaiSach lsMoi = db.LoaiSaches.Single(ls => ls.pid == loaiSach.pid); lsMoi.Ten = loaiSach.Ten; db.SubmitChanges(); } }
public void XoaDocGia(String maDocGia) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { DocGia docGiaXoa = db.DocGias.Single(s => s.mssv == maDocGia); docGiaXoa.Disable = true; db.SubmitChanges(); } }
public void XoaLoaiSach(string pid) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { LoaiSach lsXoa = db.LoaiSaches.Single(ls => ls.pid == pid); lsXoa.Disable = true; db.SubmitChanges(); } }
public void XoaSach(int id) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { Sach sachXoa = db.Saches.Single(s => s.id == id); sachXoa.Disable = true; db.SubmitChanges(); } }
public void XoaNhaXuatBan(string pid) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { NhaXuatBan nxbXoa = db.NhaXuatBans.Single(nxb => nxb.pid == pid); nxbXoa.Disable = true; db.SubmitChanges(); } }
public void ThemNhaXuatBan(string tenNXB) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { NhaXuatBan nxbMoi = new NhaXuatBan { Ten = tenNXB }; db.NhaXuatBans.InsertOnSubmit(nxbMoi); db.SubmitChanges(); } }
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 void ThemNganhKhoa(string ten) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { LoaiSach loaiSachMoi = new LoaiSach { Ten = ten }; db.LoaiSaches.InsertOnSubmit(loaiSachMoi); db.SubmitChanges(); } }
public void SuaDocGia(DocGia docGia) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { DocGia docGiaSua = db.DocGias.Single(dg => dg.mssv == docGia.mssv); docGiaSua.HoTen = docGia.HoTen; docGiaSua.GioiTinh = docGia.GioiTinh; docGiaSua.NgaySinh = docGia.NgaySinh; db.SubmitChanges(); } }
public bool ThemNV(DTO_NhanVien nv) { //string sql = string.Format("Insert into NHANVIEN (HoTenNhanVien,NgaySinh,DiaChi,DienThoai,MaBangCap)" // + " values (N'{0}','{1}','{2}','{3}','{4}')", ten, date, dc, dt, mbc); //conClass.ExecuteNonquery(sql); try { NhanVien em = new NhanVien(); em.HoTenNhanVien = nv.UI_TenNhanVien; em.NgaySinh = nv.UI_NgaySinh; em.DiaChi = nv.UI_DiaChi; em.DienThoai = nv.UI_DienThoai; em.MaBangCap = nv.UI_MaBangCap; tvD.NhanViens.InsertOnSubmit(em); tvD.SubmitChanges(); return(true); } catch { return(false); } }
public void ThemNganhKhoa(String ten) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { NganhKhoa nk = new NganhKhoa { Ten = ten }; db.NganhKhoas.InsertOnSubmit(nk); db.SubmitChanges(); } }
public bool CapNhapTraSach(DTO_ChiTietMuonTra sach) { try { ChiTietPhieuMuon pm = tvD.ChiTietPhieuMuons.FirstOrDefault(p => p.MaCTPM == sach.MaCTPM); pm.IsTra = sach.istra; pm.NgayTra = sach.ngaytra; tvD.SubmitChanges(); return(true); } catch (Exception) { return(false); } }
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(); } }
public void SuaSach(Sach sach) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { Sach sachSua = db.Saches.Single(s => s.id == sach.id); sachSua.Ten = sach.Ten; sachSua.LoaiSach = sach.LoaiSach; sachSua.NganhKhoa = sach.NganhKhoa; sachSua.TacGia = sach.TacGia; sachSua.NhaXB = sach.NhaXB; sachSua.NamXB = sach.NamXB; sachSua.SoLuongHienCo = sach.SoLuongHienCo; sachSua.SoLuongDaMuon = sach.SoLuongDaMuon; sachSua.MoTa = sach.MoTa; sachSua.DuongDanAnh = sach.DuongDanAnh; db.SubmitChanges(); } }
public bool TraSach(int idPhieuMuon) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { try { PhieuMuonSach pms = db.PhieuMuonSaches.Single(p => p.id == idPhieuMuon && p.Disable == false); pms.TinhTrang = TinhTrangPhieuMuon.DA_TRA; foreach (ChiTietPhieuMuon ctpm in pms.ChiTietPhieuMuons) { ctpm.Sach.SoLuongHienCo += ctpm.SoLuong; ctpm.Sach.SoLuongDaMuon -= ctpm.SoLuong; } db.SubmitChanges(); } catch { return(false); } return(true); } }
public bool XoaPhieuMuon(int id) { using (QLThuVienDataContext db = new QLThuVienDataContext()) { try { PhieuMuonSach pms = db.PhieuMuonSaches.Single(p => p.id == id); pms.Disable = true; foreach (ChiTietPhieuMuon ctpm in pms.ChiTietPhieuMuons) { ctpm.Sach.SoLuongDaMuon -= ctpm.SoLuong; ctpm.Sach.SoLuongHienCo += ctpm.SoLuong; } db.SubmitChanges(); return(true); } catch { return(false); } } }