Ejemplo n.º 1
0
        public bool xoaCTPT(CT_PHIEUTRA ct)
        {
            CT_PHIEUTRA _ct = qltv.CT_PHIEUTRAs.Where(c => c.MaChiTietPhieuTra == ct.MaChiTietPhieuTra).FirstOrDefault();

            if (_ct != null)
            {
                PHIEUTRA _pt = qltv.PHIEUTRAs.Where(t => t.MaPhieuTra == _ct.MaPhieuTra).FirstOrDefault();
                try
                {
                    _pt.SoLuongSachTra = _pt.SoLuongSachTra - 1;
                    qltv.CT_PHIEUTRAs.DeleteOnSubmit(_ct);
                    qltv.SubmitChanges();

                    PHIEUMUON _pm = qltv.PHIEUMUONs.Where(m => m.MaPhieuMuon == _ct.MaPhieuMuon).FirstOrDefault();
                    if (_pm != null)
                    {
                        CT_PHIEUMUON _ctpm = qltv.CT_PHIEUMUONs.Where(t => t.MaVach == _ct.MaVach && t.MaPhieuMuon == _pm.MaPhieuMuon).FirstOrDefault();
                        _ctpm.TinhTrangTraCT = false;
                        _pm.TinhTrangTra     = false;
                        qltv.SubmitChanges();
                    }

                    return(true);
                }
                catch (Exception ex) { return(false); }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public bool layTTtra(int mactpm)
        {
            CT_PHIEUMUON _ct = qltv.CT_PHIEUMUONs.Where(t => t.MaChiTietPhieuMuon == mactpm && t.TinhTrangTraCT == true).FirstOrDefault();

            if (_ct != null)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 public bool suaCT_PhieuMuon(string mact, bool tinhtrangtra)
 {
     CT_PHIEUMUON ct = db.CT_PHIEUMUONs.Where(a => a.MaChiTietPhieuMuon == int.Parse(mact)).FirstOrDefault();
     if(ct != null)
     {
         ct.TinhTrangTraCT = tinhtrangtra;
         db.SubmitChanges();
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public bool xoaCT_PhieuMuon(string mact)
 {
     
     CT_PHIEUMUON ct = db.CT_PHIEUMUONs.Where(a => a.MaChiTietPhieuMuon == int.Parse(mact)).FirstOrDefault();
     if(ct != null)
     {
         ct.TinhTrangXoa = true;
         db.SubmitChanges();
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 5
0
        public bool luuPhieuTra(int mapm, int manv, DateTime ngaytra, int sltra, bool tiencoc, string tiencocdg, List <CT_PHIEUTRA> lstCTPT)
        {
            PHIEUTRA pt = new PHIEUTRA();

            try
            {
                //pt.MaPhieuMuon = mapm;
                pt.MaNhanVien     = manv;
                pt.NgayLap        = ngaytra;
                pt.SoLuongSachTra = sltra;
                pt.TinhTrangXoa   = false;
                qltv.PHIEUTRAs.InsertOnSubmit(pt);
                qltv.SubmitChanges();
                PHIEUTRA mapt = qltv.PHIEUTRAs.Where(n => n.TinhTrangXoa == false).OrderByDescending(x => x.MaPhieuTra).First();
                foreach (CT_PHIEUTRA ctpt in lstCTPT)
                {
                    CT_PHIEUTRA _ctpt = new CT_PHIEUTRA();
                    _ctpt.MaPhieuTra   = mapt.MaPhieuTra;
                    _ctpt.MaPhieuMuon  = ctpt.MaPhieuMuon;
                    _ctpt.MaVach       = ctpt.MaVach;
                    _ctpt.TinhTrangXoa = false;

                    CT_PHIEUMUON _ctpm = qltv.CT_PHIEUMUONs.Where(m => m.MaPhieuMuon == ctpt.MaPhieuMuon && m.MaVach == ctpt.MaVach).FirstOrDefault();
                    if (_ctpm.TinhTrangTraCT == false)
                    {
                        _ctpm.TinhTrangTraCT = true;
                    }
                    if (updateTinhTrangPM(ctpt.MaPhieuMuon.ToString()))
                    {
                        if (tiencoc == true)
                        {
                            PHIEUMUON _pm = qltv.PHIEUMUONs.Where(m => m.MaPhieuMuon == ctpt.MaPhieuMuon).FirstOrDefault();
                            _pm.PhiCoc = 0;
                            tiencocdg  = _pm.PhiCoc.ToString();
                        }
                    }
                    qltv.CT_PHIEUTRAs.InsertOnSubmit(_ctpt);
                    qltv.SubmitChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        public DOCGIA layMaDG(DOCGIA dg, string mavach, ref string pmc)
        {
            DOCGIA       dgs  = new DOCGIA();
            CT_PHIEUMUON ctpm = qltv.CT_PHIEUMUONs.Where(m => m.MaVach == mavach && m.TinhTrangTraCT == false).FirstOrDefault(); //mv

            if (ctpm != null)
            {
                PHIEUMUON pm = qltv.PHIEUMUONs.Where(p => p.MaPhieuMuon == ctpm.MaPhieuMuon && p.TinhTrangTra == false).FirstOrDefault();
                if (pm != null)
                {
                    dgs = qltv.DOCGIAs.Where(d => d.MaTheThuVien == pm.MaTheThuVien).FirstOrDefault();
                    dg  = dgs;
                    pmc = pm.PhiCoc.ToString();
                }
            }
            return(dg);
        }
Ejemplo n.º 7
0
        public bool muonTaiLieu(List <TAILIEU> dsTaiLieuMuon, string mathethuvien, string phicoc, string manhanvien)
        {
            string    maphieumuon = "";
            PHIEUMUON newPM       = new PHIEUMUON();

            newPM.MaTheThuVien = mathethuvien;
            newPM.NgayLap      = DateTime.Now;
            DateTime thoihanmuon = DateTime.Now.AddMonths(1);

            newPM.ThoiHanMuon  = thoihanmuon;
            newPM.SoSachMuon   = dsTaiLieuMuon.Count();
            newPM.TinhTrangTra = false;
            newPM.PhiCoc       = double.Parse(phicoc);
            newPM.MaNhanVien   = int.Parse(manhanvien);
            newPM.TinhTrangXoa = false;
            try
            {
                db.PHIEUMUONs.InsertOnSubmit(newPM);
                db.SubmitChanges();
                PHIEUMUON pm = db.PHIEUMUONs.OrderByDescending(a => a.MaPhieuMuon).First();
                maphieumuon = pm.MaPhieuMuon.ToString();
            }
            catch (Exception ex)
            {
                return(false);
            }
            foreach (TAILIEU item in dsTaiLieuMuon)
            {
                CT_PHIEUMUON newCTPM = new CT_PHIEUMUON();
                //newCTPM.MaPhieuMuon = newPM.MaPhieuMuon;
                newCTPM.MaPhieuMuon    = int.Parse(maphieumuon);
                newCTPM.MaVach         = item.MaVach;
                newCTPM.TinhTrangTraCT = false;
                newCTPM.TinhTrangXoa   = false;
                try
                {
                    db.CT_PHIEUMUONs.InsertOnSubmit(newCTPM);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
            return(true);
        }