예제 #1
0
        // Hàm use username lấy id của khách.
        public int GetIDByUsername(string userName)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            Customer cus = db.Customers.SingleOrDefault(x => x.username == userName);

            return(cus.idCus);
        }
예제 #2
0
        public int getUserIDOffer(int IDRoom)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            BookingRoom             bk = db.BookingRooms.SingleOrDefault(x => x.idRoom == IDRoom && x.Status == 4);

            return(bk.idCus);
        }
예제 #3
0
        public string getInfoByID(int IDCus)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            Customer cus = db.Customers.SingleOrDefault(x => x.idCus == IDCus);

            return(cus.name + "-" + cus.address + "-" + cus.phone + "-" + cus.gender);
        }
예제 #4
0
        public TaiKhoan selectTaiKhoan(string userName)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            TaiKhoan tk = db.TaiKhoans.SingleOrDefault(x => x.username == userName);

            return(tk);
        }
예제 #5
0
        // Hàm Cập Nhật Người Dùng
        public void AddList(string userName)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            Customer cus = db.Customers.SingleOrDefault(x => x.username == userName);

            db.Customers.Add(cus);
            db.SaveChanges();
        }
예제 #6
0
        // Hàm xem lịch sử đặt phòng.
        public List <XemLichSuDatPhong> GetListHistoryRoom(int IDCus)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();

            return(db.BookingRooms.Where(x => x.idCus == IDCus).Select(x => new XemLichSuDatPhong {
                ID = x.idRoom, diaChi = x.Room.address, tenPhong = x.Room.nameroom, trangThai = x.Status
            }).ToList());
        }
예제 #7
0
        public void UpdateStatusDeclineCustomer(int CusID, int RoomID)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            BookingRoom             br = db.BookingRooms.SingleOrDefault(x => x.idCus == CusID && x.idRoom == RoomID);

            br.Status = 3;
            db.SaveChanges();
        }
예제 #8
0
        public void UpdateStatus(int IDRoom, int IDStatusIn, int IDStatusOut)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            BookingRoom             bk = db.BookingRooms.SingleOrDefault(x => x.idRoom == IDRoom && x.Status == IDStatusIn);

            bk.Status = IDStatusOut;
            db.SaveChanges();
        }
예제 #9
0
        // Hàm cập nhật Password
        public void UpdatePassword(string username, string newpassword)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            TaiKhoan tk = db.TaiKhoans.SingleOrDefault(x => x.username == username);

            tk.password = newpassword;
            db.SaveChanges();
        }
예제 #10
0
        public void UpdateStatusRoom(int RoomID, string Status)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            Room r = db.Rooms.SingleOrDefault(x => x.idRoom == RoomID);

            r.status = Status;
            db.SaveChanges();
        }
예제 #11
0
        // Hàm insertDB
        public void InsertDBCustomer(string userName)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            TaiKhoan tk = new TaiKhoan();

            tk.username = userName;
            db.TaiKhoans.Add(tk);
            db.SaveChanges();
        }
예제 #12
0
        // Hàm Xóa Người Dùng.
        public void Delete(int ID)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();

            new ModifyBooking().Delete(ID);
            Customer cus = db.Customers.SingleOrDefault(x => x.idCus == ID);

            db.Customers.Remove(cus);
            db.SaveChanges();
        }
예제 #13
0
        // Hàm InsertDB
        public void InsertDB(string userName, string passWord, int position)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            TaiKhoan tk = new TaiKhoan();

            tk.username = userName;
            tk.password = passWord;
            tk.position = position;
            db.TaiKhoans.Add(tk);
            db.SaveChanges();
        }
예제 #14
0
        public void InsertDB(int idCus, int idRoom)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            BookingRoom             bR = new BookingRoom();

            bR.idBook = GetNextID();
            bR.idCus  = idCus;
            bR.idRoom = idRoom;
            bR.Status = 1;
            db.BookingRooms.Add(bR);
            db.SaveChanges();
        }
예제 #15
0
        public void InsertOGhep(int IDRoom, int IDcus)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            BookingRoom             bk = new BookingRoom();

            bk.idBook = GetNextID();
            bk.idCus  = IDcus;
            bk.idRoom = IDRoom;
            bk.Status = 4;
            db.BookingRooms.Add(bk);
            db.SaveChanges();
        }
예제 #16
0
        public int GetNextIDCustomer()
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();

            if (db.Customers.Count() == 0)
            {
                return(1);
            }
            else
            {
                List <Customer> list = db.Customers.OrderByDescending(x => x.idCus).Take(1).ToList();
                return(list[0].idCus + 1);
            }
        }
예제 #17
0
        public int GetNextID()
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();

            if (db.BookingRooms.Count() == 0)
            {
                return(1);
            }
            else
            {
                List <BookingRoom> list = db.BookingRooms.OrderByDescending(x => x.idBook).Take(1).ToList();
                return(list[0].idBook + 1);
            }
        }
예제 #18
0
        public void InsertDB(string name, string userName, string email, int phone, string address, string gender)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            Customer cus = new Customer();

            cus.idCus    = GetNextIDCustomer();
            cus.username = userName;
            cus.email    = email;
            cus.phone    = phone;
            cus.address  = address;
            cus.gender   = gender;
            cus.name     = name;
            db.Customers.Add(cus);
            db.SaveChanges();
        }
예제 #19
0
        public string Register(register model)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            TaiKhoan tk = db.TaiKhoans.SingleOrDefault(x => x.username == userName);

            if (tk == null)
            {
                ModifyAccount  modifyAccount  = new ModifyAccount();
                ModifyCustomer modifyCustomer = new ModifyCustomer();
                modifyAccount.InsertDB(model.userName, model.passWord, 2);
                modifyCustomer.InsertDB(model.name, model.userName, model.email, model.phone, model.address, model.gender);
                return("true");
            }
            else
            {
                return("false");
            }
        }
예제 #20
0
        public void Delete(int IDcus)
        {
            QuanLyPhongTroDBContext db   = new QuanLyPhongTroDBContext();
            List <BookingRoom>      list = db.BookingRooms.Where(x => x.idCus == IDcus).ToList();

            if (list.Count() == 0)
            {
                //
            }
            else
            {
                for (int i = 0; i < list.Count(); i++)
                {
                    db.BookingRooms.Remove(list[i]);
                    db.SaveChanges();
                }
            }
        }
예제 #21
0
        //
        public void Insert(ListRoomModel model)
        {
            QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext();
            Room r = new Room();

            r.idRoom   = GetNextID();
            r.nameroom = model.tenPhong;
            r.price    = model.gia;
            r.address  = model.diaChi;
            r.location = model.viTri;
            if (model.hinhAnh != null)
            {
                r.image = model.hinhAnh;
            }
            r.status = "empty";
            r.phone  = model.soDienThoai;
            db.Rooms.Add(r);
            db.SaveChanges();
        }
예제 #22
0
        //
        public int GetNextID()
        {
            List <Room> list = new QuanLyPhongTroDBContext().Rooms.OrderByDescending(x => x.idRoom).Take(1).ToList();

            return(list[0].idRoom + 1);
        }