Article.cs
资源名称:moban.rar [点击查看]
上传用户:szraylite
上传日期:2018-06-06
资源大小:11546k
文件大小:5k
源码类别:
软件测试
开发平台:
Java
- /**********************************************************
- * 说明:文章类Article
- * 作者:
- * 创建日期:
- *********************************************************/
- using System;
- using System.Collections;
- using System.Data;
- using ENTERPRISE.DataAccessLayer;
- using ENTERPRISE.DataAccessHelper;
- namespace ENTERPRISE.BusinessLogicLayer
- {
- /// <summary>
- /// Article 的摘要说明
- /// </summary>
- public class Article
- {
- private int _id;
- private string _title;
- private string _content;
- private string _reporter;
- private DateTime _time;
- private string _belong_column;
- public int id
- {
- set
- {
- this._id = value;
- }
- get
- {
- return this._id;
- }
- }
- public string title
- {
- set
- {
- this._title = value;
- }
- get
- {
- return this._title;
- }
- }
- public string content
- {
- set
- {
- this._content = value;
- }
- get
- {
- return this._content;
- }
- }
- public string reporter
- {
- set
- {
- this._reporter = value;
- }
- get
- {
- return this._reporter;
- }
- }
- public DateTime time
- {
- set
- {
- this._time = value;
- }
- get
- {
- return this._time;
- }
- }
- private string belong_column
- {
- set
- {
- this._belong_column = value;
- }
- get
- {
- return this._belong_column;
- }
- }
- public Article()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- #region 方法
- /// <summary>
- /// 向数据库添加一个用户
- /// </summary>
- /// <param name="message">用户信息哈希表</param>
- public void Add(NoSortHashtable articleinfo)
- {
- Database db = new Database(); //实例化一个Database类
- db.Insert("[article_info]", articleinfo);
- }
- /// <summary>
- /// 修改留言内容
- /// </summary>
- /// <param name="newTopicInfo"></param>
- public void Update(Hashtable articleinfo, int id)
- {
- Database db = new Database();
- string strCond = "Where id = " + id;
- db.Update("[article_info]", articleinfo, strCond);
- }
- /// <summary>
- /// 删除留言
- /// </summary>
- public void Delete()
- {
- ArrayList sqls = new ArrayList();
- string sql = "";
- sql = "Delete from [article_info] where id = " + this._id;
- sqls.Add(sql);
- Database db = new Database();
- db.ExecuteSQL(sqls);
- }
- /// <summary>
- /// 按时间降序,读取所有留言
- /// </summary>
- /// <returns></returns>
- public static DataSet QueryArticles()
- {
- string sql = "";
- sql = "Select * from [article_info] order by notetime desc";
- Database db = new Database();
- return db.GetDataSet(sql);
- }
- /// <summary>
- /// 根据参数topicID,获取帖子细信息
- /// </summary>
- /// <param name="topicID">帖子ID</param>
- public void LoadData(int id)
- {
- Database db = new Database(); //实例化一个Database类
- string sql = "";
- sql = "Select * from [article_info] where id = " + id;
- DataRow dr = db.GetDataRow(sql); //利用Database类的GetDataRow方法查询用户数据
- //根据查询得到的数据,对成员赋值
- if (dr != null)
- {
- this._title = GetSafeData.ValidateDataRow_S(dr, "title");
- this._id = GetSafeData.ValidateDataRow_N(dr, "id");
- this._time = GetSafeData.ValidateDataRow_T(dr, "notetime");
- this._content = GetSafeData.ValidateDataRow_S(dr, "content");
- this._reporter = GetSafeData.ValidateDataRow_S(dr, "reporter");
- this._belong_column = GetSafeData.ValidateDataRow_S(dr, "belong_column");
- }
- }
- #endregion 方法
- }
- }