示例#1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.HotelRoomViewModel DataRowToModel(DataRow row)
 {
     Maticsoft.Model.HotelRoomViewModel model = new Maticsoft.Model.HotelRoomViewModel();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["BaseRoomID"] != null)
         {
             model.BaseRoomID = row["BaseRoomID"].ToString();
         }
         if (row["PlatID"] != null && row["PlatID"].ToString() != "")
         {
             model.PlatID = int.Parse(row["PlatID"].ToString());
         }
         if (row["HotelID"] != null && row["HotelID"].ToString() != "")
         {
             model.HotelID = int.Parse(row["HotelID"].ToString());
         }
         if (row["RoomName"] != null)
         {
             model.RoomName = row["RoomName"].ToString();
         }
         if (row["CreateDate"] != null && row["CreateDate"].ToString() != "")
         {
             model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
         }
         if (row["HotelPlatID"] != null)
         {
             model.HotelPlatID = row["HotelPlatID"].ToString();
         }
         if (row["RoomID"] != null)
         {
             model.RoomID = row["RoomID"].ToString();
         }
         if (row["PlatName"] != null)
         {
             model.PlatName = row["PlatName"].ToString();
         }
         if (row["HotelName"] != null)
         {
             model.HotelName = row["HotelName"].ToString();
         }
     }
     return(model);
 }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.HotelRoomViewModel GetModel(int ID, string BaseRoomID, int PlatID, int HotelID, string RoomName, DateTime CreateDate, string HotelPlatID, string RoomID, string PlatName, string HotelName)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,BaseRoomID,PlatID,HotelID,RoomName,CreateDate,HotelPlatID,RoomID,PlatName,HotelName from HotelRoomView ");
            strSql.Append(" where ID=@ID and BaseRoomID=@BaseRoomID and PlatID=@PlatID and HotelID=@HotelID and RoomName=@RoomName and CreateDate=@CreateDate and HotelPlatID=@HotelPlatID and RoomID=@RoomID and PlatName=@PlatName and HotelName=@HotelName ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",          SqlDbType.Int,         4),
                new SqlParameter("@BaseRoomID",  SqlDbType.NVarChar,  100),
                new SqlParameter("@PlatID",      SqlDbType.Int,         4),
                new SqlParameter("@HotelID",     SqlDbType.Int,         4),
                new SqlParameter("@RoomName",    SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateDate",  SqlDbType.DateTime),
                new SqlParameter("@HotelPlatID", SqlDbType.VarChar,    50),
                new SqlParameter("@RoomID",      SqlDbType.NVarChar,  100),
                new SqlParameter("@PlatName",    SqlDbType.NVarChar,   20),
                new SqlParameter("@HotelName",   SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = ID;
            parameters[1].Value = BaseRoomID;
            parameters[2].Value = PlatID;
            parameters[3].Value = HotelID;
            parameters[4].Value = RoomName;
            parameters[5].Value = CreateDate;
            parameters[6].Value = HotelPlatID;
            parameters[7].Value = RoomID;
            parameters[8].Value = PlatName;
            parameters[9].Value = HotelName;

            Maticsoft.Model.HotelRoomViewModel model = new Maticsoft.Model.HotelRoomViewModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }