Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public DTcms.Model.dt_download_attach DataRowToModel(DataRow row)
 {
     DTcms.Model.dt_download_attach model = new DTcms.Model.dt_download_attach();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["article_id"] != null && row["article_id"].ToString() != "")
         {
             model.article_id = int.Parse(row["article_id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["file_path"] != null)
         {
             model.file_path = row["file_path"].ToString();
         }
         if (row["file_ext"] != null)
         {
             model.file_ext = row["file_ext"].ToString();
         }
         if (row["file_size"] != null && row["file_size"].ToString() != "")
         {
             model.file_size = int.Parse(row["file_size"].ToString());
         }
         if (row["down_num"] != null && row["down_num"].ToString() != "")
         {
             model.down_num = int.Parse(row["down_num"].ToString());
         }
         if (row["point"] != null && row["point"].ToString() != "")
         {
             model.point = int.Parse(row["point"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.dt_download_attach GetModelDown(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,article_id,title,file_path,file_ext,file_size,down_num,point from dt_download_attach ");
            strSql.Append(" where article_id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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