Exemple #1
0
        public static LOAIDV truyVanLoaiDichVu(string maDichVu)
        {
            LOAIDV res = new LOAIDV();

            res = DataProvider.ISCreated.DB.Database.SqlQuery <LOAIDV>("SELECT LP.* FROM DICHVU P JOIN LOAIDV LP ON P.LoaiDVID=LP.LoaiDVID  WHERE P.DichVuID = @id and P.TinhTrangTonTai=0", new SqlParameter("@id", maDichVu)).FirstOrDefault();
            return(res);
        }
        public static void capNhatLoaiDV(LOAIDV nv)
        {
            LOAIDV old = DataProvider.ISCreated.DB.LOAIDVs.Where(x => x.LoaiDVID == nv.LoaiDVID).SingleOrDefault();

            old.TinhTrang = nv.TinhTrang;
            old.TenLoai   = nv.TenLoai;
            capNhatCSDL();
        }
        public static LOAIDV themMoiLoaiDV(LOAIDV nv)
        {
            nv.NgayTao = DateTime.Now;
            LOAIDV res = new LOAIDV();

            res = DataProvider.ISCreated.DB.LOAIDVs.Add(nv);
            DataProvider.ISCreated.DB.SaveChanges();
            return(res);
        }
        public static void updateInsertLoaiDV(LOAIDV lp)
        {
            List <DICHVU> listPhong = DataProvider.ISCreated.DB.DICHVUs.Where(x => (x.LoaiDVID == lp.LoaiDVID && x.TinhTrangTonTai == false)).ToList();

            foreach (DICHVU item in listPhong)
            {
                item.TinhTrangTonTai = true;
            }
            capNhatCSDL();
        }
        public static void xoaLoaiDV(LOAIDV nv)
        {
            LOAIDV old = DataProvider.ISCreated.DB.LOAIDVs.Where(x => x.LoaiDVID == nv.LoaiDVID).SingleOrDefault();

            old.TinhTrang = true;

            List <DICHVU> listDV = DataProvider.ISCreated.DB.DICHVUs.Where(x => (x.LoaiDVID == old.LoaiDVID && x.TinhTrangTonTai == false)).ToList();

            foreach (DICHVU item in listDV)
            {
                item.TinhTrangTonTai = true;
            }
            capNhatCSDL();
        }