Example #1
0
        public static LOAIPHONG truyVanLoaiPhong(string maPhong)
        {
            LOAIPHONG res = new LOAIPHONG();

            res = DataProvider.ISCreated.DB.Database.SqlQuery <LOAIPHONG>("SELECT LP.* FROM PHONG P JOIN LOAIPHONG LP ON P.LoaiPhongID=LP.LoaiPhongID  WHERE P.PhongID = @id and P.TinhTrangTonTai=0", new SqlParameter("@id", maPhong)).FirstOrDefault();
            return(res);
        }
        public static LOAIPHONG themMoiLoaiPhong(LOAIPHONG nv)
        {
            nv.NgayTao = DateTime.Now;
            LOAIPHONG res = new LOAIPHONG();

            res = DataProvider.ISCreated.DB.LOAIPHONGs.Add(nv);
            DataProvider.ISCreated.DB.SaveChanges();
            return(res);
        }
        // CAPNHAT
        public static void capNhatLoaiPhong(LOAIPHONG nv)
        {
            LOAIPHONG old = DataProvider.ISCreated.DB.LOAIPHONGs.Where(x => x.LoaiPhongID == nv.LoaiPhongID).SingleOrDefault();

            old.TenLoai     = nv.TenLoai;
            old.TinhTrang   = nv.TinhTrang;
            old.LoaiPhongID = nv.LoaiPhongID;
            capNhatCSDL();
        }
        public static void updateInsertLoaiPhong(LOAIPHONG lp)
        {
            List <PHONG> listPhong = DataProvider.ISCreated.DB.PHONGs.Where(x => (x.LoaiPhongID == lp.LoaiPhongID && x.TinhTrangTonTai == false)).ToList();

            foreach (PHONG item in listPhong)
            {
                item.TinhTrangTonTai = true;
            }
            capNhatCSDL();
        }
        public static void xoaLoaiPhong(LOAIPHONG nv)
        {
            LOAIPHONG old = DataProvider.ISCreated.DB.LOAIPHONGs.Where(x => x.LoaiPhongID == nv.LoaiPhongID).SingleOrDefault();

            old.TinhTrang = true;
            capNhatCSDL();

            List <PHONG> listPhong = DataProvider.ISCreated.DB.PHONGs.Where(x => (x.LoaiPhongID == old.LoaiPhongID && x.TinhTrangTonTai == false && x.TinhTrangThue == false)).ToList();

            foreach (PHONG item in listPhong)
            {
                item.TinhTrangTonTai = true;
            }

            capNhatCSDL();
        }