本文主要是介绍从房态图里查询房态,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
首先查出所有客房的数据,再根据你要查的房态的ID进行查询,如图
点击空净房的时候,查询的都是空净房
点击住房,查询的都是住房
在控制器这边把房态图的数据查出来
// 查询房态图
public ActionResult KeFangRoomtu(){var Rnotices = (from tbRoom in myModel.S_GuestRoomjoin tbR in myModel.S_RoomCategory on tbRoom.RoomCategoryID equals tbR.RoomCategoryIDjoin tbF in myModel.S_RoomForm on tbRoom.RoomFormID equals tbF.RoomFormID orderby tbRoom.GuestRoomID descending//倒叙排序select new RoomDetail //构建实体类{GuestRoomID = tbRoom.GuestRoomID,//客房表RoomCategoryID = tbR.RoomCategoryID,//房类表RoomFormID = tbF.RoomFormID,//房态表 RoomNumber = tbRoom.RoomNumber,//房号 Abbreviation = tbR.Abbreviation,//简称 DisperseGuestPrice = tbR.DisperseGuestPrice,//散客价 RoomFormType = tbF.RoomFormType,//房态类型 Status = tbRoom.Status,//状态 }).ToList();return Json(Rnotices, JsonRequestBehavior.AllowGet);}再到视图这边根据要查的房态ID把数据筛选出来//空净房查询
$("#Kjingf").click(function () {$("#Rooms div").remove();$.post("/KfFroom/FangTaitu/KeFangRoomtu", function (data) {$.each(data, function (i) {if (data[i].RoomFormID == 1) {//空净房//追加出房态与样式$("#Rooms").append("<div id='GuestRoomID' onclik='room(" + data[i].GuestRoomID + ")' class='rounded' style='float:left; cursor:pointer;background-color: rgba(217,218,230,0.4);width:150px; height:150px; margin-left:7px; margin-top:5px;font-size:27px;text-align:center; color:#ffffff;'><p style='padding-top:40px;'>"+ data[i].RoomNumber + "</p><p>"+ data[i].Abbreviation + "</p></div>");}});});});//住房查询
$("#ZFang").click(function () {$("#Rooms div").remove();$.post("/KfFroom/FangTaitu/KeFangRoomtu", function (data) {$.each(data, function (i) {if (data[i].RoomFormID == 9) {//住房//追加出房态与样式$("#Rooms").append("<div id='GuestRoomID' onclik='room(" + data[i].GuestRoomID + ")' class='rounded' style='float:left; cursor:pointer; background:#1b3af5;width:150px; height:150px; margin-left:7px; margin-top:5px;font-size:27px;text-align:center; color:#ffffff;'><p style='padding-top:40px;'>"+ data[i].RoomNumber + "</p><p>"+ data[i].Abbreviation + "</p></div>");}});});});
这篇关于从房态图里查询房态的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!