示例#1
0
        internal static int insertCompletePayment(Order order)
        {
            using (SmartRentalSystemEntities db = new SmartRentalSystemEntities())
            {
                var orders = db.Order.Where(t => t.OutTradeNo == order.OutTradeNo).ToList().FirstOrDefault();
                orders.Ordertime       = order.Ordertime;
                orders.ActualPrice     = order.ActualPrice;
                orders.OrderNumber     = order.OrderNumber;
                orders.OrderState      = "已支付";
                db.Entry(orders).State = EntityState.Modified;
                db.SaveChanges();

                var Room = db.RoomMessage.Where(t => t.RoomID == orders.RoomID).ToList().FirstOrDefault();
                Room.RoomCount       = Room.RoomCount - orders.Ordercount;
                db.Entry(Room).State = EntityState.Modified;
                return(db.SaveChanges());
            }
        }
示例#2
0
 internal static object Updata(UserMessage user)
 {
     using (SmartRentalSystemEntities db = new SmartRentalSystemEntities())
     {
         var aa = db.UserMessage.Where(t => t.UserID == user.UserID).ToList().FirstOrDefault();
         aa.UserName        = user.UserName;
         aa.Birthday        = user.Birthday;
         aa.sex             = user.sex;
         db.Entry(aa).State = EntityState.Modified;
         return(db.SaveChanges());
     }
 }
 public IHttpActionResult message(dynamic data)
 {
     using (SmartRentalSystemEntities db = new SmartRentalSystemEntities())
     {
         var Url  = "/images/" + data.data.imgURL;
         var id   = data.data.id;
         var user = db.UserMessage.Find(id.Value);
         user.HeadPhoto       = Url;
         db.Entry(user).State = EntityState.Modified;
         return(Ok(db.SaveChanges() > 0));
     }
 }
示例#4
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"));
     }
 }
示例#5
0
        public ActionResult EditRoom(RoomMessage roomMessage, string[] RoomFacility)
        {
            string fi = "";

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

                fi = fi + "+" + item.ToString();//这样写方便调时看
            }
            roomMessage.RoomFacility = fi;

            System.Web.HttpFileCollection file = System.Web.HttpContext.Current.Request.Files;
            var photocount = file.Count;

            string[] imgname = new string[photocount];
            if (photocount > 0 && file[0].FileName != "")
            {
                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/Roomphoto/" + guid + file[i].FileName;
                        file[i].SaveAs(Server.MapPath(path));//必须得是相对路径
                        imgname[i] = "/images/Roomphoto/" + guid + file[i].FileName;
                    }
                }
            }
            RoomPhoto roomph = new RoomPhoto();

            using (SmartRentalSystemEntities db = new SmartRentalSystemEntities())
            { var hotmana = db.RoomMessage.Find(roomMessage.RoomID);
              if (roomMessage.RoomRemain >= (hotmana.RoomRemain - hotmana.RoomCount))
              {
                  if (imgname[0] != "" && imgname[0] != null)
                  {
                      for (int i = 0; i < photocount; i++)
                      {
                          if (i == 0)
                          {
                              roomph.PhotoName1 = imgname[i].ToString();
                          }
                          if (i == 1)
                          {
                              roomph.PhotoName2 = imgname[i].ToString();
                          }
                          if (i == 2)
                          {
                              roomph.PhotoName3 = imgname[i].ToString();
                          }
                          if (i == 3)
                          {
                              roomph.PhotoName4 = imgname[i].ToString();
                          }
                          if (i == 4)
                          {
                              roomph.PhotoName5 = imgname[i].ToString();
                          }
                          if (i == 5)
                          {
                              roomph.PhotoName6 = imgname[i].ToString();
                          }
                          if (i == 6)
                          {
                              roomph.PhotoName7 = imgname[i].ToString();
                          }
                      }

                      for (int s = photocount; s < 7; s++)
                      {
                          if (s == 0)
                          {
                              roomph.PhotoName1 = null;
                          }
                          if (s == 1)
                          {
                              roomph.PhotoName2 = null;
                          }
                          if (s == 2)
                          {
                              roomph.PhotoName3 = null;
                          }
                          if (s == 3)
                          {
                              roomph.PhotoName4 = null;
                          }
                          if (s == 4)
                          {
                              roomph.PhotoName5 = null;
                          }
                          if (s == 5)
                          {
                              roomph.PhotoName6 = null;
                          }
                          if (s == 6)
                          {
                              roomph.PhotoName7 = null;
                          }
                      }
                      roomph.RoomPhotoID     = (int)roomMessage.RoomPhotoID;
                      db.Entry(roomph).State = EntityState.Modified;
                      db.SaveChanges();
                  }

                  hotmana.MattresID    = roomMessage.MattresID;
                  hotmana.RoomTypeID   = roomMessage.RoomTypeID;
                  hotmana.RoomName     = roomMessage.RoomName;
                  hotmana.RoomLayout   = roomMessage.RoomLayout;
                  hotmana.RoomFacility = roomMessage.RoomFacility;
                  hotmana.RoomCount    = roomMessage.RoomRemain - (hotmana.RoomRemain - hotmana.RoomCount);
                  hotmana.RoomRemain   = roomMessage.RoomRemain;
                  hotmana.PrimeCost    = roomMessage.PrimeCost;
                  hotmana.RoomPrice    = roomMessage.RoomPrice;
                  var htole = db.HotelManag.Find(hotmana.HotelID);
                  if (htole.HotelDiscount > hotmana.RoomPrice)
                  {
                      htole.HotelDiscount = hotmana.RoomPrice;
                  }
                  hotmana.Boolbreakfast = roomMessage.Boolbreakfast;

                  //db.Entry(manag).State = EntityState.Modified;
                  db.SaveChanges();
                  return(Content("<script>alert('修改成功');location.href = '/GHotelHome/RoomIndex';</script>"));
              }
              else
              {
                  return(Content("<script>alert('修改失败,房间数量小于该房间已出售数量');location.href = '/GHotelHome/EditRoom?id=" + roomMessage.RoomID + "';</script>"));
              } }
        }
示例#6
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>"));
        }
示例#7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="user"></param>
 internal static bool Updata(UserMessage user)
 {
     db.Entry(user).State = EntityState.Modified;
     return(db.SaveChanges() > 0);
 }