Beispiel #1
0
        protected void b1_Click(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            HOTEL h = new HOTEL();

            h.hotel_email      = hotel_email.Text;
            Session["h_email"] = hotel_email.Text;

            h.HOTEL_NAME = name.Text;
            h.STREET     = street.Text;
            h.CITY       = city.Text;
            h.STATE      = state.SelectedValue.ToString();
            // if (pwd.Text == pwd2.Text)
            {
                h.password = pwd.Text;
            }
            //     else {


            //      }

            h.PHONE1    = Convert.ToInt32(no1.Text);
            h.PHONE2    = Convert.ToInt32(no2.Text);
            h.ROOM_COST = Convert.ToInt32(cost.Text);

            HttpPostedFile postedfile = fu1.PostedFile;

            postedfile.SaveAs(Server.MapPath("~/Hotel_pics/") + Path.GetFileName(postedfile.FileName));
            h.pic = "~/Hotel_pics/" + postedfile.FileName;

            db.HOTELs.InsertOnSubmit(h);
            db.SubmitChanges();
            Response.Redirect("HotelProfile.aspx");
        }
        public ActionResult DeleteConfirmed(int id)
        {
            HOTEL hOTEL = db.HOTELs.Find(id);

            db.HOTELs.Remove(hOTEL);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "HotelId,HotelName,HotelDesc,HotelLocation,IdealPrice")] HOTEL hOTEL)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hOTEL).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hOTEL));
 }
Beispiel #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var   db = new DataClasses1DataContext();
            HOTEL h  = new HOTEL();

            Session["h_id"] = Request.QueryString["hotel_id"];
            h = db.HOTELs.SingleOrDefault(i => i.hotel_id == Convert.ToInt32(Session["h_id"]));
            Session["h_price"] = h.ROOM_COST;
            Response.Redirect("HotelBooking.aspx");
        }
Beispiel #5
0
        public ActionResult EditHotel(HOTEL hotel, HttpPostedFileBase fileUpload)
        {
            //var temp = db.SANPHAMs.SingleOrDefault(p => p.MaSP == sanpham.MaSP);
            //ViewBag.MaDM = new SelectList(db.DANHMUCs.ToList().OrderBy(n => n.TenDM), "MaDM", "TenDM", sanpham.MaDM);
            //if (fileUpload == null)
            //{
            //    TempData["msg"] = "<script>alert('Sửa thành công!');</script>";
            //    temp.Ngaycapnhat = DateTime.Now;
            //    UpdateModel(temp);
            //    db.SubmitChanges();
            //    return RedirectToAction("Sanpham");
            //}
            ////Them vao CSDL
            //else
            //{
            //    if (ModelState.IsValid)
            //    {
            //        //Luu ten file, luu y bo sung thu vien using System.IO;
            //        var fileName = Path.GetFileName(fileUpload.FileName);
            //        //Luu duong dan cua file
            //        var path = Path.Combine(Server.MapPath("~/images"), fileName);
            //        //Kiem tra hinh anh ton tai chua
            //        if (System.IO.File.Exists(path))
            //        {
            //            ViewBag.Thongbao = "Hình ảnh đã tồn tại";
            //        }
            //        else
            //        {
            //            //Luu hinh anh vao duong dan
            //            fileUpload.SaveAs(path);
            //        }
            //        temp.Hinhanh = fileName;
            //        temp.Ngaycapnhat = DateTime.Now;
            //        //Luu vao CSDL
            //        UpdateModel(temp);
            //        db.SubmitChanges();
            //        TempData["msg"] = "<script>alert('Sửa thành công!');</script>";
            //    }
            if (ModelState.IsValid)
            {
                try
                {
                    HOTEL model = db.HOTELs.Single(x => x.ID_HOTEL == hotel.ID_HOTEL);
                    model.NAME_HOTEL = hotel.NAME_HOTEL; //ve them cac field con lai
                    //model = hotel;
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Error", new { msg = ex.Message }));
                }
            }

            return(RedirectToAction("Hotel"));
        }
        public ActionResult Create([Bind(Include = "HotelId,HotelName,HotelDesc,HotelLocation,IdealPrice")] HOTEL hOTEL)
        {
            if (ModelState.IsValid)
            {
                db.HOTELs.Add(hOTEL);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hOTEL));
        }
Beispiel #7
0
 public ActionResult Edit([Bind(Include = "HotelId,CiudadId,NomHotel")] HOTEL hOTEL)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hOTEL).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CiudadId = new SelectList(db.Ciudades, "CiudadId", "Nombre", hOTEL.CiudadId);
     return(View(hOTEL));
 }
Beispiel #8
0
        public ActionResult EditHotel(int id)
        {
            //Lay doi tuong sanpham theo ma
            HOTEL hotel = db.HOTELs.SingleOrDefault(n => n.ID_HOTEL == id);

            if (hotel == null)
            {
                Response.StatusCode = 404;
                return(null);
            }
            return(View(hotel));
        }
Beispiel #9
0
        public ActionResult Create([Bind(Include = "HotelId,CiudadId,NomHotel")] HOTEL hOTEL)
        {
            if (ModelState.IsValid)
            {
                db.Hoteles.Add(hOTEL);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CiudadId = new SelectList(db.Ciudades, "CiudadId", "Nombre", hOTEL.CiudadId);
            return(View(hOTEL));
        }
        // GET: HOTELs/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HOTEL hOTEL = db.HOTELs.Find(id);

            if (hOTEL == null)
            {
                return(HttpNotFound());
            }
            return(View(hOTEL));
        }
Beispiel #11
0
        // GET: HOTELs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HOTEL hOTEL = db.Hoteles.Find(id);

            if (hOTEL == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CiudadId = new SelectList(db.Ciudades, "CiudadId", "Nombre", hOTEL.CiudadId);
            return(View(hOTEL));
        }
        protected void Book_Click(object sender, EventArgs e)
        {
            var           db = new DataClasses1DataContext();
            HOTEL         h  = new HOTEL();
            UserInfo      u  = new UserInfo();
            HOTEL_BOOKING hb = new HOTEL_BOOKING();

            h             = db.HOTELs.SingleOrDefault(i => i.hotel_id == Convert.ToInt32(Session["h_id"]));
            u             = db.UserInfos.SingleOrDefault(i => i.Email == Session["email"].ToString());
            hb.user_email = u.Email;
            hb.hotel_id   = h.hotel_id;
            hb.PERSONS    = Convert.ToInt32(no_of_person.SelectedValue);
            hb.Total_Cost = Convert.ToInt32(no_of_person.SelectedValue) * Convert.ToInt32(Session["h_price"]);
            db.HOTEL_BOOKINGs.InsertOnSubmit(hb);
            db.SubmitChanges();
            Response.Redirect("myHotels.aspx");
        }
Beispiel #13
0
        public ActionResult CreateHotel(HOTEL hotel, HttpPostedFileBase fileUpload)
        {
            if (db.HOTELs.Any(x => x.ID_HOTEL == hotel.ID_HOTEL))
            {
                hotel.ID_HOTEL = db.HOTELs.Max(x => x.ID_HOTEL) + 1;
            }
            if (fileUpload == null)
            {
                return(View());
            }

            if (ModelState.IsValid)
            {
                var fileName = Path.GetFileName(fileUpload.FileName);
                //Luu duong dan cua file
                var path = Path.Combine(Server.MapPath("~/Images"), fileName);
                //Kiem tra hinh anh ton tai chua
                if (System.IO.File.Exists(path))
                {
                    ViewBag.Message = "Image was existed ! Please choose another image.";
                    return(View());
                }
                else
                {
                    //Luu hinh anh vao duong dan
                    fileUpload.SaveAs(path);
                    hotel.IMAGE_HOTEL = path;
                }

                try
                {
                    db.HOTELs.Add(hotel);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("Error", new { msg = ex.Message }));
                }
            }
            else
            {
                return(View());
            }
            return(RedirectToAction("Hotel"));
        }
        public string getAccreditStatus(string accommoId)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    HOTEL updateAccred = (from accommo in db.HOTELs
                                          where accommo.HOTEL_ID.Equals(Convert.ToInt32(accommoId))
                                          select accommo).Single();

                    return(updateAccred.ACCRED_STATUS);
                }
            }
            catch (Exception)
            {
                return("Failed to get status");
            }
        }
Beispiel #15
0
 public ActionResult DeleteHotel(int id, int?aaa)
 {
     try
     {
         HOTEL hotel = db.HOTELs.SingleOrDefault(n => n.ID_HOTEL == id);
         if (hotel == null)
         {
             Response.StatusCode = 404;
             return(null);
         }
         db.HOTELs.Remove(hotel);
         db.SaveChanges();
         return(RedirectToAction("Hotel"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Error", new { msg = ex.Message }));
     }
     //return View();
 }
        public string cancelAccredit(string accommoId)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    HOTEL updateAccred = new HOTEL();
                    updateAccred = (from accommo in db.HOTELs
                                    where accommo.HOTEL_ID.Equals(Convert.ToInt32(accommoId))
                                    select accommo).Single();
                    updateAccred.ACCRED_STATUS = "CANCELLED";
                    db.SubmitChanges();

                    return("Success Cancellation made");
                }
            }
            catch (Exception)
            {
                return("Failed to perform cancellation");
            }
        }
        public string accreditAccommo(string accommoId)
        {
            try
            {
                using (HotelManagementServerDataContext db = new HotelManagementServerDataContext())
                {
                    HOTEL updateAccred = (from accommo in db.HOTELs
                                          where accommo.HOTEL_ID.Equals(Convert.ToInt32(accommoId))
                                          select accommo).Single();
                    updateAccred.ACCRED_STATUS      = "ACCREDITED";
                    updateAccred.ACCRED_START_DATE  = Convert.ToDateTime(DateTime.Now.AddYears(1).Year.ToString() + "-01-01");
                    updateAccred.ACCRED_EXPIRY_DATE = Convert.ToDateTime(AccreditationDuration.computeDuration());
                    db.SubmitChanges();

                    return("Success Accreditation made");
                }
            }
            catch (Exception)
            {
                return("Failed to perform accreditation");
            }
        }
Beispiel #18
0
        public ActionResult CreateHotel()
        {
            HOTEL model = new HOTEL();

            return(View(model));
        }