Example #1
0
        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 Edit([Bind(Include = "RequestTypeID,RequestTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] RequestType requestType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(requestType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Manage-51", "Manage"));
     }
     return(View(requestType));
 }
 public ActionResult Edit([Bind(Include = "RoomTypeID,RoomTypeName,RoomTypePrices,RoomTypeDescription,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify,IsPay,IsShowHomePage,IsShow,RoomTypeImage")] RoomType roomType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roomType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Manage-51", "Manage"));
     }
     return(View(roomType));
 }
 public ActionResult Edit([Bind(Include = "ServicesTypeID,ServicesTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] ServicesType servicesType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicesType).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Manage-51", "Manage");
     }
     return View(servicesType);
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "AccountTypeID,AccountTypeName,Disabled")] AccountType accountType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(accountType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Manage-51", "Manage"));
     }
     return(View(accountType));
 }
Example #6
0
 public ActionResult Edit([Bind(Include = "PromotionID,PromotionName,PercentDiscount,PromotionContent,CreatedUserID,ModifyUserID,DateCreated,DateModify")] Promotion promotion)
 {
     if (ModelState.IsValid)
     {
         db.Entry(promotion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Manage-55", "Manage"));
     }
     ViewBag.CreatedUserID = new SelectList(db.Accounts, "AccountID", "UserName", promotion.CreatedUserID);
     return(View(promotion));
 }
Example #7
0
 public ActionResult Edit([Bind(Include = "EquipmentTypeID,EquipmentTypeName,Disabled,CreatedUserID,ModifyUserID,DateCreated,DateModify")] EquipmentType equipmentType)
 {
     if (ModelState.IsValid)
     {
         var account = ManageBLL.Instance.GetUserByUserName(User.Identity.Name);
         equipmentType.ModifyUserID    = account.AccountID;
         db.Entry(equipmentType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Manage-51", "Manage"));
     }
     return(View(equipmentType));
 }
 public ActionResult Edit([Bind(Include = "EquipmentID,EquipmentName,EquipPrices,DateBuy,EquipStatus,EquipmentTypeID,RoomID,CreatedUserID,ModifyUserID,DateCreated,DateModify,Image")] Equipment equipment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(equipment).State = EntityState.Modified;
         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));
 }
Example #9
0
 public ActionResult Edit([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.ModifyUserID    = user.AccountID;
         db.Entry(roomType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Manage-51", "Manage"));
     }
     return(View(roomType));
 }
        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"));
            }
        }
Example #11
0
        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());
            }
        }