예제 #1
0
        /// <summary>
        /// 数据转查询实体
        /// </summary>
        public static UserQueryInfo DataToModel(SqlDataReader rdr)
        {
            UserQueryInfo query = new UserQueryInfo();
            if (!rdr.IsDBNull(0)) query.UserQueryID = rdr.GetInt32(0);
            if (!rdr.IsDBNull(1)) query.UserQueryName = rdr.GetString(1);
            if (!rdr.IsDBNull(2)) query.UserQueryURL = rdr.GetString(2);
            if (!rdr.IsDBNull(3)) query.UserQueryValue = rdr.GetString(3);
            if (!rdr.IsDBNull(4)) query.UserQueryLive = rdr.GetByte(4);
            if (!rdr.IsDBNull(5)) query.UserID = rdr.GetInt32(5);
            if (!rdr.IsDBNull(6)) query.ModifyDate = rdr.GetDateTime(6);

            return query;
        }
예제 #2
0
        /// <summary>
        /// 根据ID取查询,返回实体
        /// </summary>
        public UserQueryInfo GetUserQueryById(int userId, int queryId)
        {
            UserQueryInfo query = new UserQueryInfo();

            SqlParameter[] parms = {
                   new SqlParameter(PARM_USER_ID, SqlDbType.Int),
                   new SqlParameter(PARM_QUERY_ID, SqlDbType.Int)
            };
            parms[0].Value = userId;
            parms[1].Value = queryId;

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, SQL_SELECT_USER_QUERY_BY_ID, parms))
            {
                while (rdr.Read())
                {
                    query = DataToModel(rdr);
                }
            }

            return query;
        }
예제 #3
0
        /// <summary>
        /// 查询实体转参数
        /// </summary>
        public static SqlParameter[] ModelToParms(UserQueryInfo query)
        {
            SqlParameter[] parms = {
                    new SqlParameter("@UserQueryID", SqlDbType.Int),
                    new SqlParameter("@UserQueryName", SqlDbType.NVarChar, 20),
                    new SqlParameter("@UserQueryURL", SqlDbType.NVarChar, 200),
                    new SqlParameter("@UserQueryValue", SqlDbType.NVarChar, 200),
                    new SqlParameter("@UserQueryLive", SqlDbType.TinyInt),
                    new SqlParameter("@UserID", SqlDbType.Int),
                    new SqlParameter("@ModifyDate", SqlDbType.DateTime)
            };
            parms[0].Value = query.UserQueryID;
            parms[1].Value = query.UserQueryName;
            parms[2].Value = query.UserQueryURL;
            parms[3].Value = query.UserQueryValue;
            parms[4].Value = query.UserQueryLive;
            parms[5].Value = query.UserID;
            parms[6].Value = query.ModifyDate;

            return parms;
        }
예제 #4
0
 /// <summary>
 /// 修改专题
 /// </summary>
 public bool UpdateUserQuery(UserQueryInfo query)
 {
     return dal.UpdateUserQuery(query);
 }
예제 #5
0
 /// <summary>
 /// 插入专题
 /// </summary>
 public bool InsertUserQuery(UserQueryInfo query)
 {
     return dal.InsertUserQuery(query);
 }
예제 #6
0
        /// <summary>
        /// 修改查询
        /// </summary>
        public bool UpdateUserQuery(UserQueryInfo query)
        {
            SqlParameter[] parms = ModelToParms(query);

            int result = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, SQL_UPDATE_USER_QUERY, parms);

            return result > 0;
        }