Exemple #1
0
        public static bool UpdataAudit(HotelManag hotel)
        {
            var re = db.HotelManag.Find(hotel.HotelID);

            re.HotelRatify = hotel.HotelRatify;
            if (re.HotelRatify == true)
            {
                var userurel = db.UserMessage.Where(s => s.HotelID == hotel.HotelID).FirstOrDefault();
                var usme     = db.UserMessage.Find(userurel.UserID);
                usme.UserGrade = "管理员";
                user_roles user_Roles = new user_roles();
                user_Roles.UserPhone   = usme.UserPhone;
                user_Roles.user_roles1 = usme.UserGrade;
                db.user_roles.Add(user_Roles);
            }
            else
            {
                var userurel = db.UserMessage.Where(s => s.HotelID == hotel.HotelID).FirstOrDefault();
                var usme     = db.UserMessage.Find(userurel.UserID);
                usme.UserGrade = "用户";
                var usrolfirst = db.user_roles.Where(s => s.UserPhone == usme.UserPhone).FirstOrDefault();
                var usrol      = db.user_roles.Find(usrolfirst.user_rolesID);
                db.user_roles.Remove(usrol);
            }
            return(db.SaveChanges() > 0);
        }
        public ActionResult Index(string HotelID, string Ratify, string hotelname)
        {
            if (hotelname != null && hotelname != "")
            {
                var hotelmes = HotelService.SelectHotel(hotelname);
                return(View(hotelmes));
            }
            else
            {
                HotelManag manag1 = new HotelManag();
                manag1.HotelID     = int.Parse(HotelID);
                manag1.HotelRatify = bool.Parse(Ratify);
                if (HotelService.SetHotel(manag1))
                {
                    //return Json ( new { Code = "200",success = "成功" },JsonRequestBehavior.AllowGet );
                    var hotel = HotelService.Hotel();
                    return(View(hotel));
                }

                else
                {
                    return(Json(new { Code = "404", success = "失败" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Exemple #3
0
 internal static bool SetHotel(HotelManag ratify)
 {
     if (HotelMapper.UpdataAudit(ratify))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public static int AddHotelManager(HotelManag manager, string[] photo, UserMessage usms)
        {
            using (SmartRentalSystemEntities db = new SmartRentalSystemEntities())
            {
                HotelPhoto hotel = new HotelPhoto();
                for (int i = 0; i < photo.Length; i++)
                {
                    if (i == 0)
                    {
                        hotel.Hotelphoto1 = photo[i].ToString();
                    }
                    if (i == 1)
                    {
                        hotel.Hotelphoto2 = photo[i].ToString();
                    }
                    if (i == 2)
                    {
                        hotel.Hotelphoto3 = photo[i].ToString();
                    }
                    if (i == 3)
                    {
                        hotel.Hotelphoto4 = photo[i].ToString();
                    }
                    if (i == 4)
                    {
                        hotel.Hotelphoto5 = photo[i].ToString();
                    }
                    if (i == 5)
                    {
                        hotel.Hotelphoto6 = photo[i].ToString();
                    }
                    if (i == 6)
                    {
                        hotel.Hotelphoto7 = photo[i].ToString();
                    }
                }
                var bb = db.HotelPhoto.Add(hotel);
                db.SaveChanges();
                int photoID = bb.HotelPhotoID;
                manager.HotelPhotoID  = photoID;
                manager.Hotelrecommen = 10000;
                db.SaveChanges();
                var hh       = db.HotelManag.Add(manager);
                var usermess = db.UserMessage.Find(usms.UserID);
                usermess.HotelID = hh.HotelID;

                return(db.SaveChanges());
            }
        }
Exemple #5
0
 public ActionResult RecommendAlter(int?Hotelrecommen, int?OldHotelrecommen, int?HotelID, string HotelName, string HotelNames)
 {
     //Hotelrecommen,OldHotelrecommen需要更新的图像字段,HotelID酒店选择的id,HotelName,HotelNames所选择的酒店名
     if (Hotelrecommen == null && HotelID == null)
     {
         ViewBag.hh = OldHotelrecommen;
         ViewBag.kk = HotelNames;
         var hotels = db.HotelManag.Include("HotelPhoto").Where(t => t.HotelName.Contains(HotelName)).ToList();
         return(View(hotels));
     }
     else
     {
         HotelManag hotelManag = db.HotelManag.Where(t => t.Hotelrecommen == OldHotelrecommen).FirstOrDefault();
         hotelManag.Hotelrecommen   = Hotelrecommen;
         db.Entry(hotelManag).State = EntityState.Modified;//标注
         HotelManag hotelManag1 = db.HotelManag.Where(t => t.HotelID == HotelID).FirstOrDefault();
         hotelManag1.Hotelrecommen   = OldHotelrecommen;
         db.Entry(hotelManag1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Recommend"));
     }
 }
Exemple #6
0
        public ActionResult Main(HotelManag manag, string city, string province, string[] HotelFacility, string userphone)
        {
            SmartRentalSystemEntities db = new SmartRentalSystemEntities();
            var usrmph = db.UserMessage.Where(u => u.UserPhone == userphone).FirstOrDefault();

            if (usrmph != null)
            {
                UserMessage usms = new UserMessage();
                usms.UserID = usrmph.UserID;
                if (city.Substring(0, 1) == "市" || city.Substring(0, 1) == "县")
                {
                    manag.HotelCity = province;
                }
                else
                {
                    manag.HotelCity = city;
                }
                var    b  = province.Substring(0, 1);
                string fi = "";

                foreach (var item in HotelFacility)
                {
                    //可以自己写Insert语句(添加数据)

                    fi = fi + "+" + item.ToString();//这样写方便调试看
                }
                manag.HotelFacility = fi;

                manag.Hoteltration_time = DateTime.Now.ToLocalTime();

                manag.HotelGrade    = 10;
                manag.HotelDiscount = 99999;
                System.Web.HttpFileCollection file = System.Web.HttpContext.Current.Request.Files;
                var      photocount = file.Count;
                string[] imgname    = new string[photocount];
                if (photocount > 0)
                {
                    for (int i = 0; i < photocount; i++)
                    {
                        if (file[i].FileName == "" || file[i].FileName == null)
                        {
                            imgname[i] = "";
                        }
                        else
                        {
                            string guid = Guid.NewGuid().ToString();
                            string path = "~/images/HotelPhoto/" + guid + file[i].FileName;
                            file[i].SaveAs(Server.MapPath(path));//必须得是相对路径
                            imgname[i] = "/images/HotelPhoto/" + guid + file[i].FileName;
                        }
                    }
                }

                if (BLL.ServiceAdmin.GHotelManageService.AddHotelManager(manag, imgname, usms))
                {
                    return(Content("<script>alert('提交成功');location.href = '/Login/Index';</script>"));
                }
                return(Content("<script>alert('提交失败');location.href = '/Login/Index';</script>"));
            }
            else
            {
                return(Content("<script>alert('提交账号不存在');location.href = '/GHotelHome/Main';</script>"));
            }
        }
Exemple #7
0
        public ActionResult MainEdit(HotelManag manag, string city, string province, string[] HotelFacility)
        {
            if (city.Substring(0, 1) == "市" || city.Substring(0, 1) == "县")
            {
                manag.HotelCity = province;
            }
            else
            {
                manag.HotelCity = city;
            }
            string fi = "";

            foreach (var item in HotelFacility)
            {
                //可以自己写Insert语句(添加数据)

                fi = fi + "+" + item.ToString();//这样写方便调时看
            }
            manag.HotelFacility = fi;
            System.Web.HttpFileCollection file = System.Web.HttpContext.Current.Request.Files;
            var photocount = file.Count;

            string[] imgname = new string[photocount];
            if (photocount > 0)
            {
                for (int i = 0; i < photocount; i++)
                {
                    if (file[i].FileName == "" || file[i].FileName == null)
                    {
                        imgname[i] = "";
                    }
                    else
                    {
                        string guid = Guid.NewGuid().ToString();
                        string path = "~/images/HotelPhoto/" + guid + file[i].FileName;
                        file[i].SaveAs(Server.MapPath(path));//必须得是相对路径
                        imgname[i] = "/images/HotelPhoto/" + guid + file[i].FileName;
                    }
                }
            }

            using (SmartRentalSystemEntities db = new SmartRentalSystemEntities())
            {
                if (imgname[0] != "" && imgname[0] != null)
                {
                    HotelPhoto roomph = new HotelPhoto();
                    for (int i = 0; i < photocount; i++)
                    {
                        if (i == 0)
                        {
                            roomph.Hotelphoto1 = imgname[i].ToString();
                        }
                        if (i == 1)
                        {
                            roomph.Hotelphoto2 = imgname[i].ToString();
                        }
                        if (i == 2)
                        {
                            roomph.Hotelphoto3 = imgname[i].ToString();
                        }
                        if (i == 3)
                        {
                            roomph.Hotelphoto4 = imgname[i].ToString();
                        }
                        if (i == 4)
                        {
                            roomph.Hotelphoto5 = imgname[i].ToString();
                        }
                        if (i == 5)
                        {
                            roomph.Hotelphoto6 = imgname[i].ToString();
                        }
                        if (i == 6)
                        {
                            roomph.Hotelphoto7 = imgname[i].ToString();
                        }
                    }
                    for (int s = photocount; s < 7; s++)
                    {
                        if (s == 0)
                        {
                            roomph.Hotelphoto1 = null;
                        }
                        if (s == 1)
                        {
                            roomph.Hotelphoto2 = null;
                        }
                        if (s == 2)
                        {
                            roomph.Hotelphoto3 = null;
                        }
                        if (s == 3)
                        {
                            roomph.Hotelphoto4 = null;
                        }
                        if (s == 4)
                        {
                            roomph.Hotelphoto5 = null;
                        }
                        if (s == 5)
                        {
                            roomph.Hotelphoto6 = null;
                        }
                        if (s == 6)
                        {
                            roomph.Hotelphoto7 = null;
                        }
                    }
                    roomph.HotelPhotoID    = (int)manag.HotelPhotoID;
                    db.Entry(roomph).State = EntityState.Modified;
                    db.SaveChanges();
                }

                var hotmana = db.HotelManag.Find(manag.HotelID);
                hotmana.HotelName      = manag.HotelName;
                hotmana.HotelCity      = manag.HotelCity;
                hotmana.AddressDetails = manag.AddressDetails;
                hotmana.HotelType      = manag.HotelType;
                hotmana.HotelIntro     = manag.HotelIntro;
                hotmana.HotelBoss      = manag.HotelBoss;
                hotmana.HotelRule      = manag.HotelRule;
                hotmana.HotelFacility  = manag.HotelFacility;
                hotmana.HotelPhone     = manag.HotelPhone;
                hotmana.HotelOpentime  = manag.HotelOpentime;
                //db.Entry(manag).State = EntityState.Modified;
                db.SaveChanges();
            }


            return(Content("<script>alert('修改成功');location.href = '/GHotelHome/MainIndex';</script>"));
        }
 public static bool AddHotelManager(HotelManag manag, string[] photo)
 {
     return(DAL.MapperAdmin.GHotelManagerMan.AddHotelManager(manag, photo) > 0);
 }