Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(iRan.Model.RoomTypeInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update RoomTypeInfo set ");
            strSql.Append("Syno=@Syno");
            strSql.Append(" where RoomType=@RoomType and BedType=@BedType ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Syno",     SqlDbType.VarChar, 512),
                new SqlParameter("@RoomType", SqlDbType.Int,       4),
                new SqlParameter("@BedType",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Syno;
            parameters[1].Value = model.RoomType;
            parameters[2].Value = model.BedType;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(iRan.Model.RoomTypeInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into RoomTypeInfo(");
            strSql.Append("RoomType,BedType,Syno)");
            strSql.Append(" values (");
            strSql.Append("@RoomType,@BedType,@Syno)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoomType", SqlDbType.Int,     4),
                new SqlParameter("@BedType",  SqlDbType.Int,     4),
                new SqlParameter("@Syno",     SqlDbType.VarChar, 512)
            };
            parameters[0].Value = model.RoomType;
            parameters[1].Value = model.BedType;
            parameters[2].Value = model.Syno;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public iRan.Model.RoomTypeInfo GetModel(int RoomType, int BedType)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RoomType,BedType,Syno from RoomTypeInfo ");
            strSql.Append(" where RoomType=@RoomType and BedType=@BedType ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoomType", SqlDbType.Int, 4),
                new SqlParameter("@BedType",  SqlDbType.Int, 4)
            };
            parameters[0].Value = RoomType;
            parameters[1].Value = BedType;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public iRan.Model.RoomTypeInfo DataRowToModel(DataRow row)
 {
     iRan.Model.RoomTypeInfo model = new iRan.Model.RoomTypeInfo();
     if (row != null)
     {
         if (row["RoomType"] != null && row["RoomType"].ToString() != "")
         {
             model.RoomType = int.Parse(row["RoomType"].ToString());
         }
         if (row["BedType"] != null && row["BedType"].ToString() != "")
         {
             model.BedType = int.Parse(row["BedType"].ToString());
         }
         if (row["Syno"] != null)
         {
             model.Syno = row["Syno"].ToString();
         }
     }
     return(model);
 }