示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(book_shop.Model.SearchDetailsModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SearchDetails set ");
            strSql.Append("KeyWords=@KeyWords,");
            strSql.Append("SearchDateTime=@SearchDateTime");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@KeyWords",       SqlDbType.NVarChar,         255),
                new SqlParameter("@SearchDateTime", SqlDbType.DateTime),
                new SqlParameter("@Id",             SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = model.KeyWords;
            parameters[1].Value = model.SearchDateTime;
            parameters[2].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(book_shop.Model.SearchDetailsModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SearchDetails(");
            strSql.Append("Id,KeyWords,SearchDateTime)");
            strSql.Append(" values (");
            strSql.Append("@Id,@KeyWords,@SearchDateTime)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",             SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@KeyWords",       SqlDbType.NVarChar,         255),
                new SqlParameter("@SearchDateTime", SqlDbType.DateTime)
            };
            parameters[0].Value = Guid.NewGuid();
            parameters[1].Value = model.KeyWords;
            parameters[2].Value = model.SearchDateTime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public book_shop.Model.SearchDetailsModel DataRowToModel(DataRow row)
 {
     book_shop.Model.SearchDetailsModel model = new book_shop.Model.SearchDetailsModel();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = new Guid(row["Id"].ToString());
         }
         if (row["KeyWords"] != null)
         {
             model.KeyWords = row["KeyWords"].ToString();
         }
         if (row["SearchDateTime"] != null && row["SearchDateTime"].ToString() != "")
         {
             model.SearchDateTime = DateTime.Parse(row["SearchDateTime"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public book_shop.Model.SearchDetailsModel GetModel(Guid Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,KeyWords,SearchDateTime from SearchDetails ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = Id;

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

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