public ActionResult BookRoomChose(Room room) { using (var db = new QLKSWEBEntities()) { int bookingid = (int)Session["BookingID"]; Room choseroom = ManageRoomBLL.Instance.GetRoomByID(room.RoomID); choseroom.RoomStatus = "BOOKING"; db.Entry(choseroom).State = EntityState.Modified; if (db.SaveChanges() > 0) { Booking bookingvoucher = BookingRoomBLL.Instance.GetBookingbyID(bookingid); bookingvoucher.BookingStatus = "BOOKING"; db.Entry(bookingvoucher).State = EntityState.Modified; if (db.SaveChanges() > 0) { BookingRoom booking = new BookingRoom() { RoomID = room.RoomID, BookingID = bookingid, IsBooking = 1 }; db.BookingRooms.Add(booking); if (db.SaveChanges() > 0) { TempData["ChoseRoomStatus"] = "BOOKSUCCES"; return(RedirectToAction("Manage-35")); } } } TempData["ChoseRoomStatus"] = "BOOKFAIL"; return(RedirectToAction("Manage-35")); } }
public ActionResult RentRoom(int billid, int roomid) { var bookinginfo = BookingRoomBLL.Instance.GetBookingbyID(billid); using (var db = new QLKSWEBEntities()) { Bill bill = new Bill() { CheckinDate = DateTime.Now, BillStatus = "OPEN", }; db.Bills.Add(bill); if (db.SaveChanges() > 0) { foreach (var item in bookinginfo.BookingServices) { BillDetail billDetail = new BillDetail() { BillID = bill.BillID, ServicesID = item.ServicesID, RoomID = roomid, }; db.BillDetails.Add(billDetail); db.SaveChanges(); } } } return(View()); }
public ActionResult Create([Bind(Include = "ServicesTypeID,ServicesTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] ServicesType servicesType) { if (ModelState.IsValid) { db.ServicesTypes.Add(servicesType); db.SaveChanges(); return RedirectToAction("Manage-51", "Manage"); } return View(servicesType); }
public ActionResult Create([Bind(Include = "RoomTypeID,RoomTypeName,RoomTypePrices,RoomTypeDescription,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify,IsPay,IsShowHomePage,IsShow,RoomTypeImage")] RoomType roomType) { if (ModelState.IsValid) { db.RoomTypes.Add(roomType); db.SaveChanges(); return(RedirectToAction("Manage-51", "Manage")); } return(View(roomType)); }
public ActionResult Create([Bind(Include = "RequestTypeID,RequestTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] RequestType requestType) { if (ModelState.IsValid) { db.RequestTypes.Add(requestType); db.SaveChanges(); return(RedirectToAction("Manage-51", "Manage")); } return(View(requestType)); }
public ActionResult Create([Bind(Include = "AccountTypeID,AccountTypeName,Disabled")] AccountType accountType) { if (ModelState.IsValid) { db.AccountTypes.Add(accountType); db.SaveChanges(); return(RedirectToAction("Manage-51", "Manage")); } return(View(accountType)); }
public ActionResult Create([Bind(Include = "PromotionID,PromotionName,PercentDiscount,PromotionContent,CreatedUserID,ModifyUserID,DateCreated,DateModify")] Promotion promotion) { if (ModelState.IsValid) { db.Promotions.Add(promotion); db.SaveChanges(); return(RedirectToAction("Manage-55", "Manage")); } ViewBag.CreatedUserID = new SelectList(db.Accounts, "AccountID", "UserName", promotion.CreatedUserID); return(View(promotion)); }
public ActionResult Create([Bind(Include = "RoomTypeID,RoomTypeName,RoomTypePrices,RoomTypeDescription,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify,IsPay,IsShowHomePage,IsShow,RoomTypeImage")] RoomType roomType) { if (ModelState.IsValid) { var user = ManageBLL.Instance.GetUserByUserName(User.Identity.Name); roomType.CreatedUserID = user.AccountID; db.RoomTypes.Add(roomType); db.SaveChanges(); return(RedirectToAction("Manage-51", "Manage")); } return(View(roomType)); }
public ActionResult Create([Bind(Include = "EquipmentID,EquipmentName,EquipPrices,DateBuy,EquipStatus,EquipmentTypeID,RoomID,CreatedUserID,ModifyUserID,DateCreated,DateModify,Image")] Equipment equipment) { if (ModelState.IsValid) { db.Equipments.Add(equipment); db.SaveChanges(); return(RedirectToAction("Manage-43", "Manage")); } ViewBag.EquipmentTypeID = new SelectList(db.EquipmentTypes, "EquipmentTypeID", "EquipmentTypeName", equipment.EquipmentTypeID); ViewBag.RoomID = new SelectList(db.Rooms, "RoomID", "RoomName", equipment.RoomID); return(View(equipment)); }
public ActionResult Create([Bind(Include = "EquipmentTypeID,EquipmentTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] EquipmentType equipmentType) { if (ModelState.IsValid) { var account = ManageBLL.Instance.GetUserByUserName(User.Identity.Name); equipmentType.CreatedUserID = account.AccountID; db.EquipmentTypes.Add(equipmentType); db.SaveChanges(); return(RedirectToAction("Manage-51", "Manage")); } return(View(equipmentType)); }
public ActionResult CancelBooking(int bookingid) { using (var db = new QLKSWEBEntities()) { var booking = BookingRoomBLL.Instance.GetBookingbyID(bookingid); booking.BookingStatus = "CANCEL"; db.SaveChanges(); var roomid = ManageRoomBLL.Instance.GetRoomIDByBookingID(bookingid); var room = ManageRoomBLL.Instance.GetRoomByID(roomid); room.RoomStatus = "OPEN"; db.SaveChanges(); } return(View("Manage-19")); }
public ActionResult Paid(Bill model) { var account = ManageBLL.Instance.GetUserByUserName(User.Identity.Name); using (var db = new QLKSWEBEntities()) { var details = db.BillDetails.Where(x => x.BillID == model.BillID).FirstOrDefault(); var room = db.Rooms.Where(x => x.RoomID == details.RoomID).FirstOrDefault(); room.RoomStatus = "OPEN"; db.SaveChanges(); Bill bill = db.Bills.Where(x => x.BillID == model.BillID).FirstOrDefault(); bill.BillStatus = "PAID"; bill.Total = model.Total; bill.CheckoutDate = DateTime.Now; bill.DateModify = DateTime.Now; db.SaveChanges(); } return(RedirectToAction("Manage-23")); }
public ActionResult RentRoom(int bookingid, int roomid) { var bookinginfo = BookingRoomBLL.Instance.GetBookingbyID(bookingid); var user = ManageBLL.Instance.GetUserByUserName(User.Identity.Name); using (var db = new QLKSWEBEntities()) { Bill bill = new Bill() { CheckinDate = DateTime.Now, BillStatus = "OPEN", CreatedUserID = user.AccountID, DateCreated = DateTime.Now }; db.Bills.Add(bill); if (db.SaveChanges() > 0) { var room = db.Rooms.Find(roomid); room.RoomStatus = "RENTED"; db.SaveChanges(); var booking = db.Bookings.Find(bookingid); booking.BookingStatus = "DONE"; db.SaveChanges(); foreach (var item in bookinginfo.BookingServices) { BillDetail billDetail = new BillDetail() { BillID = bill.BillID, ServicesID = item.ServicesID, RoomID = roomid, Quantity = 1, TotalSerivcesPrices = item.Service.ServicesPrices }; db.BillDetails.Add(billDetail); db.SaveChanges(); } return(RedirectToAction("Manage-19")); } return(RedirectToAction("Manage-19")); } }
public ActionResult BookRoomChose(Room room) { using (var db = new QLKSWEBEntities()) { int bookingid = (int)Session["BookingID"]; Room choseroom = ManageRoomBLL.Instance.GetRoomByID(room.RoomID); choseroom.RoomStatus = "BOOKING"; db.Entry(choseroom).State = EntityState.Modified; // ở cái đoạn này viết vậy là nó chỉ update đúng 1 bảng Room thôi đúng không? // đúng rồi, nó chỉ affect Room thôi // nhưng sao tui bị lỗi này nhỉ, tui demo ông xem if (db.SaveChanges() > 0) { //Booking bookingvoucher = BookingRoomBLL.Instance.GetBookingbyID(bookingid); Booking bookingvoucher = db.Bookings.Find(bookingid); bookingvoucher.BookingStatus = "BOOKING"; db.Entry(bookingvoucher).State = EntityState.Modified; if (db.SaveChanges() > 0) { BookingRoom booking = new BookingRoom() { RoomID = room.RoomID, BookingID = bookingid, IsBooking = 1 }; db.BookingRooms.Add(booking); if (db.SaveChanges() > 0) { TempData["ChoseRoomStatus"] = "BOOKSUCCES"; return(RedirectToAction("Manage-35")); } } } TempData["ChoseRoomStatus"] = "BOOKFAIL"; return(RedirectToAction("Manage-35")); } }
public ActionResult CreateRoom(Room model) { var user = ManageBLL.Instance.GetUserByUserName(User.Identity.Name); using (var db = new QLKSWEBEntities()) { Room room = new Room() { RoomName = model.RoomName, RoomStatus = "OPEN", MinQuantity = model.MinQuantity, MaxQuantity = model.MaxQuantity, RoomTypeID = model.RoomTypeID, DateCreated = DateTime.Now, CreatedUserID = user.AccountID }; db.Rooms.Add(room); db.SaveChanges(); } return(RedirectToAction("Manage-19")); }
public ActionResult ApproveRequest(int RequestID, int mode) { var room = ManageRoomBLL.Instance.GetRoomByRequestID(RequestID); using (var db = new QLKSWEBEntities()) { var request = db.Requests.Find(RequestID); var result = RequestBLL.Instance.ApproveRequest(RequestID); if (result != null) { var equip = db.Equipments.Find(request.EquipmentID); equip.EquipStatus = 1; if (mode == 1) // Bảo trì phòng cùng thiết bị { room.RoomStatus = "MAINTENANCE"; } db.SaveChanges(); return(RedirectToAction("Manage-47")); } return(RedirectToAction("Manage-47")); } }
public ActionResult AddServtoBill(BillDetail detail) { using (var db = new QLKSWEBEntities()) { var prices = db.Services.Where(x => x.ServicesID == detail.ServicesID).FirstOrDefault(); var room = db.BillDetails.Where(x => x.BillID == detail.BillID).FirstOrDefault(); BillDetail billDetail = new BillDetail() { ServicesID = detail.ServicesID, BillID = detail.BillID, Quantity = detail.Quantity, RoomID = room.RoomID, TotalSerivcesPrices = detail.Quantity * prices.ServicesPrices }; db.BillDetails.Add(billDetail); if (db.SaveChanges() > 0) { return(RedirectToAction("InvoiceDetail", new { id = detail.BillID })); } } TempData["AddServToBillResult"] = "FAIL"; return(RedirectToAction("InvoiceDetail", new { id = detail.BillID })); }
public ActionResult BookingRoom(Customer customer) { var checkcustomer = BookingRoomBLL.Instance.CheckCustomerInfo(customer.Passport); if (checkcustomer == -1) { using (var db = new QLKSWEBEntities()) { Customer cus = new Customer() { CustomerName = customer.CustomerName, Email = customer.Email, Phone = customer.Phone, Passport = customer.Passport, BirthDay = customer.BirthDay, CardType = customer.CardType, CardNo = customer.CardNo, NameOnCard = customer.NameOnCard, ExpirationDate = customer.ExpirationDate, }; db.Customers.Add(cus); if (db.SaveChanges() < 0) { TempData["BookingResult"] = "FAIL"; return(View()); } } } else if (checkcustomer == 1) { Customer oldcus = BookingRoomBLL.Instance.GetCustomerByPassport(customer.Passport); using (var db = new QLKSWEBEntities()) { oldcus.CustomerName = customer.CustomerName; oldcus.CustomerName = customer.CustomerName; oldcus.Email = customer.Email; oldcus.Phone = customer.Phone; oldcus.BirthDay = customer.BirthDay; oldcus.CardType = customer.CardType; oldcus.CardNo = customer.CardNo; oldcus.NameOnCard = customer.NameOnCard; oldcus.ExpirationDate = customer.ExpirationDate; db.Entry(oldcus).State = EntityState.Modified; if (db.SaveChanges() < 0) { TempData["BookingResult"] = "FAIL"; return(View()); } } } var roomtypeid = Session["RoomTypeID"]; var bookinfo = (CheckAvailableRooms)Session["BookingInfo"]; var listServ = (List <Service>)Session["AddServ"]; Customer cusinfo = BookingRoomBLL.Instance.GetCustomerByPassport(customer.Passport); using (var db = new QLKSWEBEntities()) { Booking booking = new Booking() { BookDate = DateTime.Now, CheckinDate = bookinfo.CheckinDate, CheckoutDate = bookinfo.CheckoutDate, BookingType = "ROOM", BookingStatus = "OPEN", RoomTypeID = (int)roomtypeid, CustomerID = cusinfo.CustomerID, DateCreated = DateTime.Now, }; db.Booking.Add(booking); if (db.SaveChanges() > 0) { foreach (var item in listServ) { BookingService bookserv = new BookingService() { BookingID = booking.BookingID, ServicesID = item.ServicesID, }; db.BookingServices.Add(bookserv); if (db.SaveChanges() < 0) { TempData["BookingResult"] = "FAIL"; return(View()); } } Session.Clear(); TempData["BookingResult"] = "SUCCESS"; return(View()); } TempData["BookingResult"] = "FAIL"; return(View()); } }