/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.HotelPriceViewModel GetModel(int id) { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from HotelPriceView "); strSql.Append(" where id=" + id.ToString()); SqlParameter[] parameters = { }; Maticsoft.Model.HotelPriceViewModel model = new Maticsoft.Model.HotelPriceViewModel(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.HotelPriceViewModel DataRowToModel(DataRow row) { Maticsoft.Model.HotelPriceViewModel model = new Maticsoft.Model.HotelPriceViewModel(); if (row != null) { if (row["HotelName"] != null) { model.HotelName = row["HotelName"].ToString(); } if (row["Price"] != null && row["Price"].ToString() != "") { model.Price = decimal.Parse(row["Price"].ToString()); } if (row["HotelID"] != null && row["HotelID"].ToString() != "") { model.HotelID = int.Parse(row["HotelID"].ToString()); } if (row["PlatID"] != null && row["PlatID"].ToString() != "") { model.PlatID = int.Parse(row["PlatID"].ToString()); } if (row["RoomID"] != null) { model.RoomID = row["RoomID"].ToString(); } if (row["RoomName"] != null) { model.RoomName = row["RoomName"].ToString(); } if (row["InDate"] != null && row["InDate"].ToString() != "") { model.InDate = DateTime.Parse(row["InDate"].ToString()); } if (row["OutDate"] != null && row["OutDate"].ToString() != "") { model.OutDate = DateTime.Parse(row["OutDate"].ToString()); } if (row["HotelPlatID"] != null) { model.HotelPlatID = row["HotelPlatID"].ToString(); } if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["BedType"] != null) { model.BedType = row["BedType"].ToString(); } if (row["BreakfirstType"] != null && row["BreakfirstType"].ToString() != "") { model.BreakfirstType = int.Parse(row["BreakfirstType"].ToString()); } if (row["BaseRoomID"] != null) { model.BaseRoomID = row["BaseRoomID"].ToString(); } if (row["IsAgentPrivate"] != null && row["IsAgentPrivate"].ToString() != "") { if ((row["IsAgentPrivate"].ToString() == "1") || (row["IsAgentPrivate"].ToString().ToLower() == "true")) { model.IsAgentPrivate = true; } else { model.IsAgentPrivate = false; } } if (row["SaleTitle"] != null) { model.SaleTitle = row["SaleTitle"].ToString(); } if (row["RoomCount"] != null) { model.RoomCount = row["RoomCount"].ToString(); } if (row["Tag"] != null) { model.Tag = row["Tag"].ToString(); } if (row["City"] != null) { model.City = row["City"].ToString(); } if (row["CreateDate"] != null && row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["UpdateDate"] != null && row["UpdateDate"].ToString() != "") { model.UpdateDate = DateTime.Parse(row["UpdateDate"].ToString()); } if (row["PlatName"] != null) { model.PlatName = row["PlatName"].ToString(); } if (row["Area"] != null) { model.Area = row["Area"].ToString(); } } return(model); }