Article.cs
上传用户:szraylite
上传日期:2018-06-06
资源大小:11546k
文件大小:5k
源码类别:

软件测试

开发平台:

Java

  1. /**********************************************************
  2.  * 说明:文章类Article
  3.  * 作者:
  4.  * 创建日期:
  5.  *********************************************************/
  6. using System;
  7. using System.Collections;
  8. using System.Data;
  9. using ENTERPRISE.DataAccessLayer;
  10. using ENTERPRISE.DataAccessHelper;
  11. namespace ENTERPRISE.BusinessLogicLayer
  12. {
  13.  
  14.     /// <summary>
  15.     /// Article 的摘要说明
  16.     /// </summary>
  17.     public class Article
  18.     {
  19.         private int _id;
  20.         private string _title;
  21.         private string _content;
  22.         private string _reporter;
  23.         private DateTime _time;
  24.         private string _belong_column;
  25.         public int id
  26.         {
  27.             set
  28.             {
  29.                 this._id = value;
  30.             }
  31.             get
  32.             {
  33.                 return this._id;
  34.             }
  35.         }
  36.         public string title
  37.         {
  38.             set
  39.             {
  40.                 this._title = value;
  41.             }
  42.             get
  43.             {
  44.                 return this._title;
  45.             }
  46.         }
  47.         public string content
  48.         {
  49.             set
  50.             {
  51.                 this._content = value;
  52.             }
  53.             get
  54.             {
  55.                 return this._content;
  56.             }
  57.         }
  58.         public string reporter
  59.         {
  60.             set
  61.             {
  62.                 this._reporter = value;
  63.             }
  64.             get
  65.             {
  66.                 return this._reporter;
  67.             }
  68.         }
  69.         public DateTime time
  70.         {
  71.             set
  72.             {
  73.                 this._time = value;
  74.             }
  75.             get
  76.             {
  77.                 return this._time;
  78.             }
  79.         }
  80.         private string belong_column
  81.         {
  82.             set
  83.             {
  84.                 this._belong_column = value;
  85.             }
  86.             get
  87.             {
  88.                 return this._belong_column;
  89.             }
  90.         }
  91.         public Article()
  92.         {
  93.             //
  94.             // TODO: 在此处添加构造函数逻辑
  95.             //
  96.         }
  97.         #region 方法
  98.         /// <summary>
  99.         /// 向数据库添加一个用户
  100.         /// </summary>
  101.         /// <param name="message">用户信息哈希表</param>
  102.         public void Add(NoSortHashtable articleinfo)
  103.         {
  104.             Database db = new Database(); //实例化一个Database类
  105.             db.Insert("[article_info]", articleinfo);
  106.         }
  107.         /// <summary>
  108.         /// 修改留言内容
  109.         /// </summary>
  110.         /// <param name="newTopicInfo"></param>
  111.         public void Update(Hashtable articleinfo, int id)
  112.         {
  113.             Database db = new Database();
  114.             string strCond = "Where id = " + id;
  115.             db.Update("[article_info]", articleinfo, strCond);
  116.         }
  117.         /// <summary>
  118.         /// 删除留言
  119.         /// </summary>
  120.         public void Delete()
  121.         {
  122.             ArrayList sqls = new ArrayList();
  123.             string sql = "";
  124.             sql = "Delete from [article_info] where id = " + this._id;
  125.             sqls.Add(sql);
  126.             Database db = new Database();
  127.             db.ExecuteSQL(sqls);
  128.         }
  129.         /// <summary>
  130.         /// 按时间降序,读取所有留言
  131.         /// </summary>
  132.         /// <returns></returns>
  133.         public static DataSet QueryArticles()
  134.         {
  135.             string sql = "";
  136.             sql = "Select * from [article_info] order by notetime desc";
  137.             Database db = new Database();
  138.             return db.GetDataSet(sql);
  139.         }
  140.         /// <summary>
  141.         /// 根据参数topicID,获取帖子细信息
  142.         /// </summary>
  143.         /// <param name="topicID">帖子ID</param>
  144.         public void LoadData(int id)
  145.         {
  146.             Database db = new Database(); //实例化一个Database类
  147.             string sql = "";
  148.             sql = "Select * from [article_info] where id = " + id;
  149.             DataRow dr = db.GetDataRow(sql); //利用Database类的GetDataRow方法查询用户数据
  150.             //根据查询得到的数据,对成员赋值
  151.             if (dr != null)
  152.             {
  153.                 this._title = GetSafeData.ValidateDataRow_S(dr, "title");
  154.                 this._id = GetSafeData.ValidateDataRow_N(dr, "id");
  155.                 this._time = GetSafeData.ValidateDataRow_T(dr, "notetime");
  156.                 this._content = GetSafeData.ValidateDataRow_S(dr, "content");
  157.                 this._reporter = GetSafeData.ValidateDataRow_S(dr, "reporter");
  158.                 this._belong_column = GetSafeData.ValidateDataRow_S(dr, "belong_column");
  159.             }
  160.         }
  161.         #endregion 方法
  162.     }
  163. }