コード例 #1
0
        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;
        }
コード例 #2
0
 public void ThemDocGia(DocGia docGia)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         db.DocGias.InsertOnSubmit(docGia);
         db.SubmitChanges();
     }
 }
コード例 #3
0
 public void ThemSach(Sach sach)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         db.Saches.InsertOnSubmit(sach);
         db.SubmitChanges();
     }
 }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
 public void XoaNganhKhoa(string pid)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         NganhKhoa nkXoa = db.NganhKhoas.Single(nk => nk.pid == pid);
         nkXoa.Disable = true;
         db.SubmitChanges();
     }
 }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
 public void XoaDocGia(String maDocGia)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         DocGia docGiaXoa = db.DocGias.Single(s => s.mssv == maDocGia);
         docGiaXoa.Disable = true;
         db.SubmitChanges();
     }
 }
コード例 #9
0
 public void XoaLoaiSach(string pid)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         LoaiSach lsXoa = db.LoaiSaches.Single(ls => ls.pid == pid);
         lsXoa.Disable = true;
         db.SubmitChanges();
     }
 }
コード例 #10
0
 public void XoaSach(int id)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         Sach sachXoa = db.Saches.Single(s => s.id == id);
         sachXoa.Disable = true;
         db.SubmitChanges();
     }
 }
コード例 #11
0
 public void XoaNhaXuatBan(string pid)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         NhaXuatBan nxbXoa = db.NhaXuatBans.Single(nxb => nxb.pid == pid);
         nxbXoa.Disable = true;
         db.SubmitChanges();
     }
 }
コード例 #12
0
 public void ThemNhaXuatBan(string tenNXB)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         NhaXuatBan nxbMoi = new NhaXuatBan
         {
             Ten = tenNXB
         };
         db.NhaXuatBans.InsertOnSubmit(nxbMoi);
         db.SubmitChanges();
     }
 }
コード例 #13
0
        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();
            }
        }
コード例 #14
0
 public void ThemNganhKhoa(string ten)
 {
     using (QLThuVienDataContext db = new QLThuVienDataContext())
     {
         LoaiSach loaiSachMoi = new LoaiSach
         {
             Ten = ten
         };
         db.LoaiSaches.InsertOnSubmit(loaiSachMoi);
         db.SubmitChanges();
     }
 }
コード例 #15
0
        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();
            }
        }
コード例 #16
0
 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);
     }
 }
コード例 #17
0
        public void ThemNganhKhoa(String ten)
        {
            using (QLThuVienDataContext db = new QLThuVienDataContext())
            {
                NganhKhoa nk = new NganhKhoa
                {
                    Ten = ten
                };

                db.NganhKhoas.InsertOnSubmit(nk);

                db.SubmitChanges();
            }
        }
コード例 #18
0
 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);
     }
 }
コード例 #19
0
 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();
     }
 }
コード例 #20
0
        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();
            }
        }
コード例 #21
0
 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);
     }
 }
コード例 #22
0
 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);
         }
     }
 }