public ViewResult RoomDetail(int ID_Room) { ROOM_NAME_DETAIL Room = db.ROOM_NAME_DETAIL.SingleOrDefault(n => n.ID_Room == ID_Room); ROOM_IMAGE RoomImg = db.ROOM_IMAGE.SingleOrDefault(n => n.ID_Room == ID_Room); USER_NAME_DETAIL und = db.USER_NAME_DETAIL.SingleOrDefault(n => n.ID_User == Room.ID_User); USER_NAME un = db.USER_NAME.SingleOrDefault(n => n.ID_User == Room.ID_User); Session["UND"] = und; Session["UN"] = un; Session["DiaChi"] = Room.DiaChi; Session["LoaiPhong"] = Room.LoaiPhong; Session["Gia"] = Room.GiaPhong; Session["ID_Room"] = Room.ID_Room; Session["Image1"] = RoomImg.Image1; Session["Image2"] = RoomImg.Image2; Session["Image3"] = RoomImg.Image3; Session["Image4"] = RoomImg.Image4; Session["Image5"] = RoomImg.Image5; Session["Image6"] = RoomImg.Image6; Session["Image7"] = RoomImg.Image7; Session["Image8"] = RoomImg.Image8; Session["Image9"] = RoomImg.Image9; if (Room == null || RoomImg == null) { Response.StatusCode = 404; return(null); } return(View(Room)); }
public PartialViewResult SimilarRoomPartial(int ID_Room) { ROOM_NAME_DETAIL Room = db.ROOM_NAME_DETAIL.SingleOrDefault(n => n.ID_Room == ID_Room); var list = (from p in db.ROOM_NAME_DETAIL where p.LoaiPhong == Room.LoaiPhong.ToString() orderby p.ID_Room descending select p).Take(5).ToList(); return(PartialView(list)); }
public ActionResult Edit(ROOM_NAME_DETAIL rnd) { db.Entry(rnd).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Notcheck")); }
public ActionResult UploadRoom(ROOM_NAME_DETAIL rnd, HttpPostedFileBase RoomImage, HttpPostedFileBase Image1, HttpPostedFileBase Image2, HttpPostedFileBase Image3, HttpPostedFileBase Image4, HttpPostedFileBase Image5, HttpPostedFileBase Image6, HttpPostedFileBase Image7, HttpPostedFileBase Image8, HttpPostedFileBase Image9, ROOM_NAME u, ROOM_IMAGE ri) { if (RoomImage != null) { rnd.AnhDaiDien = new byte[RoomImage.ContentLength]; RoomImage.InputStream.Read(rnd.AnhDaiDien, 0, RoomImage.ContentLength); } if (Image1 != null) { rnd.Image1 = new byte[Image1.ContentLength]; Image1.InputStream.Read(rnd.Image1, 0, Image1.ContentLength); ri.Image1 = rnd.Image1; } if (Image2 != null) { rnd.Image2 = new byte[Image2.ContentLength]; Image2.InputStream.Read(rnd.Image2, 0, Image2.ContentLength); ri.Image2 = rnd.Image2; } if (Image3 != null) { rnd.Image3 = new byte[Image3.ContentLength]; Image3.InputStream.Read(rnd.Image3, 0, Image3.ContentLength); ri.Image3 = rnd.Image3; } if (Image4 != null) { rnd.Image4 = new byte[Image4.ContentLength]; Image4.InputStream.Read(rnd.Image4, 0, Image4.ContentLength); ri.Image4 = rnd.Image4; } if (Image5 != null) { rnd.Image5 = new byte[Image5.ContentLength]; Image5.InputStream.Read(rnd.Image5, 0, Image5.ContentLength); ri.Image5 = rnd.Image5; } if (Image6 != null) { rnd.Image6 = new byte[Image6.ContentLength]; Image6.InputStream.Read(rnd.Image6, 0, Image6.ContentLength); ri.Image6 = rnd.Image6; } if (Image7 != null) { rnd.Image7 = new byte[Image7.ContentLength]; Image7.InputStream.Read(rnd.Image7, 0, Image7.ContentLength); ri.Image7 = rnd.Image7; } if (Image8 != null) { rnd.Image8 = new byte[Image8.ContentLength]; Image8.InputStream.Read(rnd.Image8, 0, Image8.ContentLength); ri.Image8 = rnd.Image8; } if (Image9 != null) { rnd.Image9 = new byte[Image9.ContentLength]; Image9.InputStream.Read(rnd.Image9, 0, Image9.ContentLength); ri.Image9 = rnd.Image9; } u.ID_Room = rnd.ID_Room; u.ID_User = rnd.ID_User; ri.ID_Room = rnd.ID_Room; dc.ROOM_NAME_DETAIL.Add(rnd); dc.ROOM_NAME.Add(u); dc.ROOM_IMAGE.Add(ri); dc.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult BookingConfirmation(int ID_Room = 0, int ID_User = 0) { ROOM_NAME_DETAIL rnd = db.ROOM_NAME_DETAIL.SingleOrDefault(n => n.ID_Room == ID_Room); USER_NAME un = db.USER_NAME.SingleOrDefault(n => n.ID_User == ID_User); USER_NAME_DETAIL und = db.USER_NAME_DETAIL.SingleOrDefault(n => n.ID_User == ID_User); ROOM_NAME rn = db.ROOM_NAME.SingleOrDefault(n => n.ID_Room == ID_Room); ROOM_NAME rnb = db.ROOM_NAME.SingleOrDefault(n => n.ID_Room == ID_Room); var mails = (from p in db.ROOM_NAME_DETAIL join o in db.USER_NAME on p.ID_User equals o.ID_User where p.ID_Room == ID_Room select new { o.Email }).First(); var Emails = mails.Email; rnb.ID_Room = rn.ID_Room; rnb.ID_User = rn.ID_User; rnb.TrangThai = "Đặt"; db.Entry(rnb).State = EntityState.Modified; db.SaveChanges(); //Lưu book var checkdate = Session["Checkdate"] as Ngubui_Project.Models.ROOM_NAME_DETAIL; BOOK_ROOM br = new BOOK_ROOM(); br.ID_User = un.ID_User; br.ID_Room = rnb.ID_Room; br.NgayDatPhong = checkdate.Checkin; br.NgayNhanPhong = checkdate.Checkout; br.TrangThai = rnb.TrangThai; db.BOOK_ROOM.Add(br); db.SaveChanges(); //gửi mail //Send key code //lấy dữ liệu mới nhất từ database StringBuilder Body = new StringBuilder(); Body.Append("<p>Chào chủ phòng! " + "!<br/>Bạn vừa nhận được một đơn đặt phòng từ: " + "<strong>" + un.Ho + " " + un.Ten + "</strong>" + "</p>"); Body.Append("<h4>Chi tiết đặt phòng</h4>"); Body.Append("<p>Ngày nhận phòng: " + checkdate.Checkin + "</p>"); Body.Append("<p>Ngày trả phòng: " + checkdate.Checkout + "</p>"); Body.Append("<p>Số khách: " + checkdate.SoKhach + "</p>"); Body.Append("<h4>Liên hệ để xác nhận</h4>"); Body.Append("<p>Số điện thoại: " + und.SoDienThoai + "</p>"); Body.Append("<p>Địa chỉ Email: " + un.Email + "</p>"); MailMessage mail = new MailMessage(); mail.To.Add(Emails); mail.From = new MailAddress("*****@*****.**"); mail.Subject = "Chào mừng bạn đã đến với Ngubui"; mail.Body = Body.ToString();// phần thân của mail ở trên mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = true; smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "01644545169Luc");// tài khoản Gmail smtp.EnableSsl = true; try { smtp.Send(mail); } //phòng trường hợp không có mạng catch { ViewBag.succes = "Đăng ký không thành công!"; } return(RedirectToAction("Index")); }
public ActionResult CheckDate(ROOM_NAME_DETAIL rnd) { Session["Checkdate"] = rnd; return(RedirectToAction("Book")); }