public static Room GetRoomForDB(string roomid, string rateplanid) { string str = "select top 1 a.*,b.zaocan,b.PayType,b.warrantCount,b.warrantTime,b.guarantee_type,b.guarantee_start_time from HotelRoom a left join HotelRatePlan b on a.id=b.RoomID where a.id=@roomid and b.id=@rateplanid and b.Enabled=1"; System.Data.DataTable dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(str, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "roomid", new HotelCloud.SqlServer.DBParam { ParamValue = roomid } }, { "rateplanid", new HotelCloud.SqlServer.DBParam { ParamValue = rateplanid } } }); Room room = new Room(); List <RatePlan> rateplans = new List <RatePlan>(); RatePlan rateplan = new RatePlan(); foreach (System.Data.DataRow dr in dt.Rows) { room.Area = dr["Area"].ToString(); room.BedArea = dr["BedArea"].ToString(); room.BedType = dr["BedType"].ToString(); room.Floor = dr["Floor"].ToString(); room.ID = WeiXinPublic.ConvertHelper.ToInt(dr["ID"]); room.NetType = dr["NetType"].ToString(); room.RoomName = dr["RoomName"].ToString(); room.Window = dr["WindowType"].ToString(); room.AddBed = dr["AddBed"].ToString(); room.IsChildRoom = WeiXinPublic.ConvertHelper.ToInt(dr["IsChildRoom"]); rateplan.ZaoCan = dr["zaocan"].ToString(); rateplan.PayType = dr["PayType"].ToString(); rateplan.WarrantCount = dr["WarrantCount"].ToString(); rateplan.WarrantTime = dr["WarrantTime"].ToString(); rateplan.guarantee_type = WeiXinPublic.ConvertHelper.ToInt(dr["guarantee_type"]); rateplan.guarantee_start_time = dr["guarantee_start_time"].ToString(); rateplans.Add(rateplan); room.RatePlans = rateplans; room.CouponsID = WeiXinPublic.ConvertHelper.ToString(dr["Conpons"]); string rid = room.ID.ToString(); if (WeiXinPublic.ConvertHelper.ToInt(dr["IsChildRoom"]) == 1) { rid = WeiXinPublic.ConvertHelper.ToString(dr["RoomTypeId"]); } List <string> imgs = new List <string>(); foreach (DataRow item in GetRoomTypeImgs(dr["hotelID"].ToString(), rid).Rows) { imgs.Add(item["url"].ToString()); } room.RoomTypeImgs = imgs; } return(room); }
public static List <Room> GetRoomsForDB(int hotelID) { string sql = @"select roomName,BedArea,Area,Floor,NetType,r.BedType,r.RoomTypeId,r.IsChildRoom,Remark,p.RoomID,e.RatePlanID, p.RatePlanName,p.ishourRoom,p.BedType as RatePlanBedType, p.NetInfo,p.zaocan,p.Discount,e.price,e.dates,e.Available,p.PayType from HotelRoom r with(nolock) inner join HotelRatePlan p with(nolock) on r.id=p.RoomID inner join HotelRate e with(nolock) on e.RatePlanID=p.id where r.hotelID=@hotelID and r.Enabled=1 and p.Enabled=1 order by r.id,p.id,dates"; var dt = HotelCloud.SqlServer.SQLHelper.Get_DataTable(sql, HotelCloud.SqlServer.SQLHelper.GetCon(), new Dictionary <string, HotelCloud.SqlServer.DBParam> { { "hotelID", new HotelCloud.SqlServer.DBParam { ParamValue = hotelID.ToString() } } }); List <Room> rooms = new List <Room>(); Room room = new Room(); List <RatePlan> RatePlans = new List <RatePlan>(); RatePlan rateplan = new RatePlan(); List <Rate> Rates = new List <Rate>(); string croomID = ""; string cRatePlanID = ""; foreach (System.Data.DataRow dr in dt.Rows) { if (!cRatePlanID.Equals(dr["RatePlanID"].ToString())) { if (!cRatePlanID.Equals("")) { rateplan.Rates = Rates; RatePlans.Add(rateplan); } cRatePlanID = dr["RatePlanID"].ToString(); rateplan = new RatePlan(); rateplan.BedType = dr["rateplanbedtype"].ToString(); rateplan.NetInfo = dr["netinfo"].ToString(); rateplan.ID = WeiXinPublic.ConvertHelper.ToInt(dr["rateplanid"]); rateplan.RatePlanName = dr["rateplanname"].ToString(); rateplan.ZaoCan = dr["zaocan"].ToString(); rateplan.IsHourRoom = WeiXinPublic.ConvertHelper.ToInt(dr["isHourRoom"]); rateplan.Discount = WeiXinPublic.ConvertHelper.ToDouble(dr["Discount"]); rateplan.PayType = Convert.ToString(dr["paytype"]); Rates = new List <Rate>(); } if ((!croomID.Equals(dr["RoomID"].ToString()))) { if (!croomID.Equals("")) { room.RatePlans = RatePlans; rooms.Add(room); } croomID = dr["RoomID"].ToString(); room = new Room(); room.Area = dr["area"].ToString(); room.BedArea = dr["bedarea"].ToString(); room.BedType = dr["bedtype"].ToString(); room.Floor = dr["floor"].ToString(); room.ID = Convert.ToInt32(dr["roomID"].ToString()); room.NetType = dr["nettype"].ToString(); room.Remark = dr["Remark"].ToString(); room.RoomName = dr["RoomName"].ToString(); room.IsChildRoom = WeiXinPublic.ConvertHelper.ToInt(dr["IsChildRoom"]); room.RoomTypeId = WeiXinPublic.ConvertHelper.ToInt(dr["RoomTypeId"]); RatePlans = new List <RatePlan>(); } Rate r = new Rate(); r.Available = Convert.ToInt32(dr["Available"].ToString()); r.Dates = Convert.ToDateTime(dr["dates"].ToString()); r.Price = Convert.ToInt32(dr["Price"].ToString()); Rates.Add(r); } if (dt.Rows.Count > 0) { rateplan.Rates = Rates; RatePlans.Add(rateplan); room.RatePlans = RatePlans; rooms.Add(room); } return(rooms); }