public hotel_info getData(string Id, string startDate, string EndDate) { string uId = "test1"; int hotel_id = 0; int.TryParse(Id, out hotel_id); if (string.IsNullOrEmpty(startDate)) { start = DateTime.Now.Date; end = start.AddDays(14); } else { DateTime.TryParse(startDate, out start); end = start.AddDays(14); } hotel_info hotel = new hotel_info(); var hotels = new HotelInfoHelp().getHotlList(""); hotel.HotelList = hotels; if (string.IsNullOrEmpty(Id) && hotels.Count > 0) hotel_id = hotels[0].hotel_id; hotel.Room.RoomList = HotelInfoHelp.getRooms(hotel_id); var f = (from p in db.roomStatuss where p.r_s_time >= start && p.r_s_time <= end && p.hotel_id == hotel_id select p).ToList(); hotel.Room.RoomStatus.RoomStatusList = f; ViewBag.startDate = start.ToString("yyyy-MM-dd"); ViewData["dates"] = HotelInfoHelp.getDate(start, end); ViewBag.Id = Convert.ToInt32(hotel_id); return hotel; }
public ActionResult Hotel(hotel_info hotel_info) { try { hotel_info.decorateTime = hotel_info.decorateTime == Convert.ToDateTime("0001/1/1 0:00:00") || hotel_info.decorateTime == null ? Convert.ToDateTime("1900-01") : hotel_info.decorateTime; hotel_info.IntroEditor = hotel_info.IntroEditor.Trim(); hotel_info.source_id = Convert.ToInt32(help.StringHelper.appSettings("source_id")); hotel_info.h_id = ""; hotel_info.h_utime = DateTime.Now; var errors = ModelState.Values.SelectMany(v => v.Errors); //if (ModelState.IsValid) //{ db.Entry(hotel_info).State = EntityState.Modified; result = db.SaveChanges() > 0 ? 0 : 1; //} } catch (Exception e) { DBhelp.log("修改公寓失败"+e.ToString()); result = 1; } HelperData(); ViewBag.HotelId = hotel_info.hotel_id; ViewBag.sign = result; return View(hotel_info); }
//////////////////////////////新建公寓开始 #region public ActionResult Index(string hotelId) { hotel_info hotel = new hotel_info(); //khotel_theme_infoDBContent db = new khotel_theme_infoDBContent(); // var themes = db..ToList(); var list =hotel_theme_info.AllTheme(); var Categorylist = Hotel_theme_type_info.allCategory(); //IEnumerable<hotel_theme_info> accessIDs = list; if (hotelId != null) { int id = Convert.ToInt32(hotelId); if (id > 0) { hotel = (from h in db.hotel where h.hotel_id == id select h).SingleOrDefault(); } } ViewData["Themes"] = DBhelp.GetSelectDataByTable("hotel_theme_info"); //Theme ViewData["Category"] = DBhelp.GetSelectDataByTable("Hotel_theme_type_info"); ;//Category ViewData["facilities"] = DBhelp.GetSelectDataByTable("Facilities_info");//facilities ViewData["services"] = DBhelp.GetSelectDataByTable("GeneralAmenities_info");//services ViewData["provice"] = DBhelp.GetSelectDataByTable("province_info");//provice //hotel_info.AllTheme(); return View(hotel); }
private void HelperData() { ViewData["DTime"] = new hotel_info().getDecorationTime(); //Theme ViewData["Themes"] = DBhelp.GetSelectDataByTable("hotel_theme_info"); //Theme ViewData["Category"] = DBhelp.GetSelectDataByTable("Hotel_theme_type_info"); ;//Category ViewData["facilities"] = DBhelp.GetSelectDataByTable("Facilities_info");//facilities ViewData["services"] = DBhelp.GetSelectDataByTable("GeneralAmenities_info");//services ViewData["provice"] = DBhelp.GetSelectDataByTable("province_info");//provice }
public ActionResult Create(string hotelId) { // ViewBag.username = "******"; help.DBhelp.log("add hotel Create"); int hotel_id = 0; hotel_info hotel = new hotel_info(); //if (hotelId != null) //{ int.TryParse(hotelId, out hotel_id); if (hotel_id > 0) ViewBag.sign = 1; hotel = (from h in db.hotel where h.hotel_id == hotel_id select h).SingleOrDefault(); // } getHelpData(); if (hotel == null) return View("create", new hotel_info()); else return View("create", hotel); return View("Create",new hotel_info()); }
public ActionResult Create(hotel_info hotel_info) { if (ModelState.IsValid) { db.hotel.Add(hotel_info); db.SaveChanges(); return RedirectToAction("Index"); } return View(hotel_info); }
public ActionResult CreateHotel(hotel_info hotel_info) { try { //hotel_info.u_id = new HotelInfoHelp().getUId(); hotel_info.source_id = Convert.ToInt32(help.StringHelper.appSettings("source_id")); ; hotel_info.h_id = Guid.NewGuid().ToString(); hotel_info.h_state = true; hotel_info.h_utime = DateTime.Now; hotel_info.CheckState = 2; hotel_info.h_ctime = DateTime.Now; hotel_info.decorateTime = hotel_info.decorateTime == Convert.ToDateTime("0001/1/1 0:00:00") || hotel_info.decorateTime ==null? Convert.ToDateTime("1900-01") : hotel_info.decorateTime; hotel_info.h_opening_time = hotel_info.h_opening_time == Convert.ToDateTime("0001/1/1 0:00:00") ? Convert.ToDateTime("1900-01") : hotel_info.h_opening_time; //hotel_info.h_room_count = hotel_info.h_room_count == 0 ? 1 : hotel_info.h_room_count; hotel_info.u_id = hotel_info.h_mobile_phone; using(db=new HotelDBContent()) { if (hotel_info.hotel_id > 0) { db.Entry(hotel_info).State = EntityState.Modified; } else { var errors = ModelState.Values.SelectMany(v => v.Errors); //if (ModelState.IsValid) //{ db.hotel.Add(hotel_info); // result = db.SaveChanges() > 0 ? 1 : 0; var f = (from h in db.hotel where h.h_name_cn == hotel_info.h_name_cn && h.source_id == 4 select h).FirstOrDefault(); if (f != null) f.h_state = false; //把对应艺龙的酒店干掉 // return RedirectToAction("Room/Create/"+ddh.hotel_id); //} } result = db.SaveChanges() > 0 ? 1 : 0; if (result > 0) { var ddh = db.hotel.Select(h => new { h.hotel_id, h.h_id }).Single(h => h.h_id == hotel_info.h_id); return RedirectToAction("room", "AddHotel", new { hotelId = ddh.hotel_id }); } } } catch (Exception e) { throw e; help.DBhelp.log("新建公寓基本信息"+e.ToString()); } ViewBag.sign = result; getHelpData(); return View("Create", hotel_info); }