// 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); }
public int getUserIDOffer(int IDRoom) { QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext(); BookingRoom bk = db.BookingRooms.SingleOrDefault(x => x.idRoom == IDRoom && x.Status == 4); return(bk.idCus); }
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); }
public TaiKhoan selectTaiKhoan(string userName) { QuanLyPhongTroDBContext db = new QuanLyPhongTroDBContext(); TaiKhoan tk = db.TaiKhoans.SingleOrDefault(x => x.username == userName); return(tk); }
// 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(); }
// 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()); }
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(); }
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(); }
// 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(); }
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(); }
// 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(); }
// 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(); }
// 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(); }
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(); }
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(); }
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); } }
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); } }
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(); }
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"); } }
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(); } } }
// 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(); }
// public int GetNextID() { List <Room> list = new QuanLyPhongTroDBContext().Rooms.OrderByDescending(x => x.idRoom).Take(1).ToList(); return(list[0].idRoom + 1); }