Exemplo n.º 1
0
        public static bool CapNhatKhiSuachitiet(CTPNsach ctpn, long giatam, int soluongtam)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var Phieunhap = (from p in model.PNsach
                             where p.MaPN.Equals(ctpn.MaPN)
                             select p).FirstOrDefault();
            var CTphieunhap = (from p in model.CTPNsach
                               where p.MaPN.Equals(ctpn.MaPN) && p.Masach.Equals(ctpn.Masach)
                               select p).FirstOrDefault();
            var _Sach = (from p in model.Sach
                         where p.Masach.Equals(ctpn.Masach)
                         select p).FirstOrDefault();

            try
            {
                CTphieunhap.Soluong = ctpn.Soluong;
                CTphieunhap.Gia     = ctpn.Gia;
                Phieunhap.Tongtien  = giatam + CTphieunhap.Gia;
                _Sach.SoLuong       = soluongtam + CTphieunhap.Soluong;
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public static bool CapNhatKhiXoachitiet(CTPNsach ctpn)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var Phieunhap = (from p in model.PNsach
                             where p.MaPN.Equals(ctpn.MaPN)
                             select p).FirstOrDefault();
            var CTphieunhap = (from p in model.CTPNsach
                               where p.MaPN.Equals(ctpn.MaPN) && p.Masach.Equals(ctpn.Masach)
                               select p).FirstOrDefault();
            var _Sach = (from p in model.Sach
                         where p.Masach.Equals(ctpn.Masach)
                         select p).FirstOrDefault();

            try
            {
                Phieunhap.Tongtien = Phieunhap.Tongtien - CTphieunhap.Gia;
                _Sach.SoLuong      = _Sach.SoLuong - CTphieunhap.Soluong;
                model.CTPNsach.Remove(CTphieunhap);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 public static bool CapNhatKhiSuachitiet(CTPNsach ctpn,long giatam,int soluongtam)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var Phieunhap = (from p in model.PNsach
                      where p.MaPN.Equals(ctpn.MaPN)
                      select p).FirstOrDefault();
     var CTphieunhap = (from p in model.CTPNsach
                        where p.MaPN.Equals(ctpn.MaPN) && p.Masach.Equals(ctpn.Masach)
                        select p).FirstOrDefault();
     var _Sach = (from p in model.Sach
                 where p.Masach.Equals(ctpn.Masach)
                 select p).FirstOrDefault();
     try
     {
         CTphieunhap.Soluong = ctpn.Soluong;
         CTphieunhap.Gia = ctpn.Gia;
         Phieunhap.Tongtien = giatam + CTphieunhap.Gia;
         _Sach.SoLuong = soluongtam + CTphieunhap.Soluong;
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 4
0
 public static bool CapNhatKhiXoachitiet(CTPNsach ctpn)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var Phieunhap = (from p in model.PNsach
                      where p.MaPN.Equals(ctpn.MaPN)
                      select p).FirstOrDefault();
     var CTphieunhap = (from p in model.CTPNsach
                        where p.MaPN.Equals(ctpn.MaPN) && p.Masach.Equals(ctpn.Masach)
                        select p).FirstOrDefault();
     var _Sach = (from p in model.Sach
                  where p.Masach.Equals(ctpn.Masach)
                  select p).FirstOrDefault();
     try
     {
         Phieunhap.Tongtien = Phieunhap.Tongtien - CTphieunhap.Gia;
         _Sach.SoLuong = _Sach.SoLuong - CTphieunhap.Soluong;
         model.CTPNsach.Remove(CTphieunhap);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 5
0
        public static bool xoaphieuchi(PhieuchiNXB phieuchi)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _phieuchi = (from p in model.PhieuchiNXB
                             where p.Maphieuchi.Equals(phieuchi.Maphieuchi)
                             select p).FirstOrDefault();
            var _ctphieuchi = from p in model.CTphieuchiNXB
                              where p.Maphieuchi.Equals(phieuchi.Maphieuchi)
                              select p;

            try
            {
                foreach (var row in _ctphieuchi)
                {
                    model.CTphieuchiNXB.Remove(row);
                }
                model.PhieuchiNXB.Remove(_phieuchi);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        public static bool CapNhatKhiThemCT(CTphieuchiNXB ctphieuchi)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _phieuchi = (from p in model.PhieuchiNXB
                             where p.Maphieuchi.Equals(ctphieuchi.Maphieuchi)
                             select p).FirstOrDefault();
            var _TTbansach = from p in model.TTbansachDL
                             where p.Masach.Equals(ctphieuchi.Masach)
                             select p;

            try
            {
                foreach (var row in _TTbansach)
                {
                    row.TinhTrang = "Đã trả nợ";
                }
                _phieuchi.Tongtien = _phieuchi.Tongtien + ctphieuchi.Tienchi;
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        public static bool XoaCTPNSach(CTPNsach ctpn)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _CTPN = (from p in model.CTPNsach
                         where p.MaPN.Trim().Equals(ctpn.MaPN)
                         where p.Masach.Trim().Equals(ctpn.Masach)
                         select p).FirstOrDefault();

            try { model.CTPNsach.Remove(_CTPN); model.SaveChanges(); return(true); }
            catch { return(false); }
        }
Exemplo n.º 8
0
 public static bool AddSach(Sach sach)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     try
     {
         model.Sach.Add(sach);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 9
0
 public static bool AddDaily(Daily daily)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     try
     {
         model.Daily.Add(daily);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 10
0
 public static bool AddNXB(Nhaxuatban nxb)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
        try
        {
        model.Nhaxuatban.Add(nxb);
        model.SaveChanges();
        return true;
        }
        catch
        {
        return false;
        }
 }
Exemplo n.º 11
0
        public static bool ThemPhieuNhap(PNsach pnsach)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();

            try
            {
                model.PNsach.Add(pnsach);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        public static bool AddSach(Sach sach)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();

            try
            {
                model.Sach.Add(sach);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 13
0
        public static bool AddDaily(Daily daily)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();

            try
            {
                model.Daily.Add(daily);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 14
0
        public static bool AddNXB(Nhaxuatban nxb)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();

            try
            {
                model.Nhaxuatban.Add(nxb);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        public static bool ThemPhieuChi(PhieuchiNXB phieuchi)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();

            try
            {
                model.PhieuchiNXB.Add(phieuchi);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 16
0
        public static bool ThemCTPNSach(CTPNsach ctpn)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();

            try
            {
                model.CTPNsach.Add(ctpn);
                model.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 17
0
        public static bool UpdateNoNXBKhiTra(Nhaxuatban nxb)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _nxb = (from p in model.Nhaxuatban
                        where p.MaNXB.Equals(nxb.MaNXB)
                        select p).FirstOrDefault();

            if (_nxb == null)
            {
                return(false);
            }
            else
            {
                _nxb.No = _nxb.No - nxb.No;
                model.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 18
0
        public static bool UpdateDaily(Daily daily)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _daily = (from p in model.Daily
                          where p.Madaily.Trim().Equals(daily.Madaily)
                          select p).FirstOrDefault();

            if (_daily == null)
            {
                return(false);
            }
            else
            {
                _daily.Tendaily = daily.Tendaily;
                _daily.Diachi   = daily.Diachi;
                _daily.SDT      = daily.SDT;
                model.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 19
0
        public static bool suaphieuchi(PhieuchiNXB phieuchi)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _phieuchi = (from p in model.PhieuchiNXB
                             where p.Maphieuchi.Equals(phieuchi.Maphieuchi)
                             select p).FirstOrDefault();

            if (_phieuchi == null)
            {
                return(false);
            }
            else
            {
                _phieuchi.MaNXB     = phieuchi.MaNXB;
                _phieuchi.Ngay      = phieuchi.Ngay;
                _phieuchi.TrangThai = phieuchi.TrangThai;
                model.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 20
0
        public static bool SuaPhieuNhap(PNsach pnsach)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _pnsach = (from p in model.PNsach
                           where p.MaPN.Trim().Equals(pnsach.MaPN.Trim())
                           select p).FirstOrDefault();

            if (_pnsach == null)
            {
                return(false);
            }
            else
            {
                _pnsach.MaNXB     = pnsach.MaNXB;
                _pnsach.Ngaynhap  = pnsach.Ngaynhap;
                _pnsach.Nguoigiao = pnsach.Nguoigiao;
                _pnsach.TinhTrang = pnsach.TinhTrang;
                model.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 21
0
        public static bool UpdateNXB(Nhaxuatban nxb)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _nxb = (from p in model.Nhaxuatban
                        where p.MaNXB.Trim().Equals(nxb.MaNXB)
                        select p).FirstOrDefault();

            if (_nxb == null)
            {
                return(false);
            }
            else
            {
                _nxb.TenNXB     = nxb.TenNXB;
                _nxb.Diachi     = nxb.Diachi;
                _nxb.SDT        = nxb.SDT;
                _nxb.Sotaikhoan = _nxb.Sotaikhoan;
                model.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 22
0
        public static bool XoaPhieuNhap(PNsach pnsach)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var _pnsach = (from p in model.PNsach
                           where p.MaPN.Trim().Equals(pnsach.MaPN)
                           select p).FirstOrDefault();
            var _ctpn = from p in model.CTPNsach
                        where p.MaPN.Trim().Equals(pnsach.MaPN)
                        select p;

            try
            {
                foreach (var row in _ctpn)
                {
                    model.CTPNsach.Remove(row);
                }
                model.PNsach.Remove(_pnsach);
                model.SaveChanges();
                return(true);
            }
            catch { return(false); }
        }
Exemplo n.º 23
0
        public static bool UpdateSach(Sach sach)
        {
            DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
            var SachSelected = (from p in model.Sach
                                where p.Masach.Trim().Equals(sach.Masach.Trim())
                                select p).FirstOrDefault();

            if (SachSelected == null)
            {
                return(false);
            }
            else
            {
                SachSelected.MaNXB     = sach.MaNXB;
                SachSelected.MaTheLoai = sach.MaTheLoai;
                SachSelected.Tensach   = sach.Tensach;
                SachSelected.Tacgia    = sach.Tacgia;
                SachSelected.GiaBan    = sach.GiaBan;
                SachSelected.GiaNhap   = sach.GiaNhap;
                model.SaveChanges();
                return(true);
            }
        }
Exemplo n.º 24
0
 public static bool CapNhatKhiThemCT(CTphieuchiNXB ctphieuchi)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _phieuchi = (from p in model.PhieuchiNXB
                      where p.Maphieuchi.Equals(ctphieuchi.Maphieuchi)
                      select p).FirstOrDefault();
     var _TTbansach = from p in model.TTbansachDL
                      where p.Masach.Equals(ctphieuchi.Masach)
                      select p;
     try
     {
         foreach(var row in _TTbansach)
         {
             row.TinhTrang = "Đã trả nợ";
         }
         _phieuchi.Tongtien = _phieuchi.Tongtien + ctphieuchi.Tienchi;
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 25
0
 public static bool SuaPhieuNhap(PNsach pnsach)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _pnsach = (from p in model.PNsach
                    where p.MaPN.Trim().Equals(pnsach.MaPN.Trim())
                    select p).FirstOrDefault();
     if (_pnsach == null)
         return false;
     else
     {
         _pnsach.MaNXB = pnsach.MaNXB;
         _pnsach.Ngaynhap = pnsach.Ngaynhap;
         _pnsach.Nguoigiao = pnsach.Nguoigiao;
         _pnsach.TinhTrang = pnsach.TinhTrang;
         model.SaveChanges();
         return true;
     }
 }
Exemplo n.º 26
0
 public static bool UpdateSach(Sach sach)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var SachSelected = (from p in model.Sach
                         where p.Masach.Trim().Equals(sach.Masach.Trim())
                         select p).FirstOrDefault();
     if (SachSelected == null)
         return false;
     else
     {
         SachSelected.MaNXB = sach.MaNXB;
         SachSelected.MaTheLoai = sach.MaTheLoai;
         SachSelected.Tensach = sach.Tensach;
         SachSelected.Tacgia = sach.Tacgia;
         SachSelected.GiaBan = sach.GiaBan;
         SachSelected.GiaNhap = sach.GiaNhap;
         model.SaveChanges();
         return true;
     }
 }
Exemplo n.º 27
0
 public static bool UpdateNoNXBKhiNhap(Nhaxuatban nxb)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
        var _nxb = (from p in model.Nhaxuatban
                where p.MaNXB.Equals(nxb.MaNXB)
                select p).FirstOrDefault();
        if (_nxb == null)
        return false;
        else
        {
        _nxb.No =_nxb.No+ nxb.No;
        model.SaveChanges();
        return true;
        }
 }
Exemplo n.º 28
0
 public static bool xoaphieuchi(PhieuchiNXB phieuchi)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _phieuchi = (from p in model.PhieuchiNXB
                      where p.Maphieuchi.Equals(phieuchi.Maphieuchi)
                      select p).FirstOrDefault();
     var _ctphieuchi = from p in model.CTphieuchiNXB
                       where p.Maphieuchi.Equals(phieuchi.Maphieuchi)
                       select p;
     try
     {
         foreach (var row in _ctphieuchi)
         {
             model.CTphieuchiNXB.Remove(row);
         }
         model.PhieuchiNXB.Remove(_phieuchi);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 29
0
 public static bool XoaCTPNSach(CTPNsach ctpn)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _CTPN = (from p in model.CTPNsach
                  where p.MaPN.Trim().Equals(ctpn.MaPN)
                  where p.Masach.Trim().Equals(ctpn.Masach)
                  select p).FirstOrDefault();
     try { model.CTPNsach.Remove(_CTPN); model.SaveChanges(); return true; }
     catch { return false; }
 }
Exemplo n.º 30
0
 public static bool ThemCTPNSach(CTPNsach ctpn)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     try
     {
         model.CTPNsach.Add(ctpn);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 31
0
 public static bool suaphieuchi(PhieuchiNXB phieuchi)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _phieuchi = (from p in model.PhieuchiNXB
                      where p.Maphieuchi.Equals(phieuchi.Maphieuchi)
                      select p).FirstOrDefault();
     if (_phieuchi == null)
         return false;
     else
     {
         _phieuchi.MaNXB = phieuchi.MaNXB;
         _phieuchi.Ngay = phieuchi.Ngay;
         _phieuchi.TrangThai = phieuchi.TrangThai;
         model.SaveChanges();
         return true;
     }
 }
Exemplo n.º 32
0
 public static bool ThemCTphieuchi(CTphieuchiNXB ctphieuchi)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     try
     {
         model.CTphieuchiNXB.Add(ctphieuchi);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 33
0
 public static bool UpdateDaily(Daily daily)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _daily = (from p in model.Daily
                 where p.Madaily.Trim().Equals(daily.Madaily)
                 select p).FirstOrDefault();
     if (_daily == null)
         return false;
     else
     {
         _daily.Tendaily = daily.Tendaily;
         _daily.Diachi = daily.Diachi;
         _daily.SDT = daily.SDT;
         model.SaveChanges();
         return true;
     }
 }
Exemplo n.º 34
0
 public static bool XoaPhieuNhap(PNsach pnsach)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     var _pnsach = (from p in model.PNsach
                    where p.MaPN.Trim().Equals(pnsach.MaPN)
                    select p).FirstOrDefault();
     var _ctpn = from p in model.CTPNsach
                  where p.MaPN.Trim().Equals(pnsach.MaPN)
                  select p;
     try
     {
         foreach(var row in _ctpn)
         {
             model.CTPNsach.Remove(row);
         }
         model.PNsach.Remove(_pnsach);
         model.SaveChanges();
         return true;
     }
     catch { return false; }
 }
Exemplo n.º 35
0
 public static bool UpdateNXB(Nhaxuatban nxb)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
        var _nxb = (from p in model.Nhaxuatban
                where p.MaNXB.Trim().Equals(nxb.MaNXB)
                select p).FirstOrDefault();
        if (_nxb == null)
        return false;
        else
        {
        _nxb.TenNXB = nxb.TenNXB;
        _nxb.Diachi = nxb.Diachi;
        _nxb.SDT = nxb.SDT;
        _nxb.Sotaikhoan = _nxb.Sotaikhoan;
        model.SaveChanges();
        return true;
        }
 }
Exemplo n.º 36
0
 public static bool ThemPhieuNhap(PNsach pnsach)
 {
     DBQLPhatHanhSachEntities model = new DBQLPhatHanhSachEntities();
     try
     {
         model.PNsach.Add(pnsach);
         model.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }