Messages.cs
资源名称:moban.rar [点击查看]
上传用户:szraylite
上传日期:2018-06-06
资源大小:11546k
文件大小:5k
源码类别:
软件测试
开发平台:
Java
- /**********************************************************
- * 说明:留言类Messages
- * 作者:
- * 创建日期:
- *********************************************************/
- using System;
- using System.Collections;
- using System.Data;
- using ENTERPRISE.DataAccessLayer;
- using ENTERPRISE.DataAccessHelper;
- namespace ENTERPRISE.BusinessLogicLayer
- {
- public class Messages
- {
- #region 私有成员
- private int _id; //留言ID
- private string _guest_name;//留言人名称
- private string _sex; //性别
- private string _email; //email
- private string _phone; //电话
- private string _city; //城市
- private string _content; //留言内容
- private DateTime _booktime;//留言时间
- private string _reply; //回复内容
- #endregion 私有成员
- #region 属性
- public int id
- {
- set
- {
- this._id = value;
- }
- get
- {
- return this._id;
- }
- }
- public string guest_name
- {
- set
- {
- this._guest_name = value;
- }
- get
- {
- return this._guest_name;
- }
- }
- public string sex
- {
- set
- {
- this._sex = value;
- }
- get
- {
- return this._sex;
- }
- }
- public string email
- {
- set
- {
- this._email = value;
- }
- get
- {
- return this._email;
- }
- }
- public string phone
- {
- set
- {
- this._phone = value;
- }
- get
- {
- return this._phone;
- }
- }
- public string city
- {
- set
- {
- this._city = value;
- }
- get
- {
- return this._city;
- }
- }
- public string content
- {
- set
- {
- this._content = value;
- }
- get
- {
- return this._content;
- }
- }
- public DateTime booktime
- {
- set
- {
- this._booktime = value;
- }
- get
- {
- return this._booktime;
- }
- }
- public string reply
- {
- set
- {
- this._reply = value;
- }
- get
- {
- return this._reply;
- }
- }
- #endregion 属性
- #region 方法
- /// <summary>
- /// 向数据库添加一个用户
- /// </summary>
- /// <param name="message">用户信息哈希表</param>
- public void Add(NoSortHashtable messageInfo)
- {
- Database db = new Database(); //实例化一个Database类
- db.Insert("[guestbook]", messageInfo);
- }
- /// <summary>
- /// 修改留言内容
- /// </summary>
- /// <param name="newTopicInfo"></param>
- public void Update(Hashtable newTopicInfo,int id)
- {
- Database db = new Database();
- string strCond = "Where id = " + id;
- db.Update("[guestbook]", newTopicInfo, strCond);
- }
- /// <summary>
- /// 删除留言
- /// </summary>
- public void Delete()
- {
- ArrayList sqls = new ArrayList();
- string sql = "";
- sql = "Delete from [guestbook] where id = " + this._id;
- sqls.Add(sql);
- Database db = new Database();
- db.ExecuteSQL(sqls);
- }
- /// <summary>
- /// 按时间降序,读取所有留言
- /// </summary>
- /// <returns></returns>
- public static DataSet QueryMessages()
- {
- string sql = "";
- sql = "Select * from [guestbook] order by booktime 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 [guestbook] where id = " + id;
- DataRow dr = db.GetDataRow(sql); //利用Database类的GetDataRow方法查询用户数据
- //根据查询得到的数据,对成员赋值
- if (dr != null)
- {
- this._guest_name = GetSafeData.ValidateDataRow_S(dr, "guest_name");
- this._id= GetSafeData.ValidateDataRow_N(dr, "id");
- this._booktime = GetSafeData.ValidateDataRow_T(dr, "booktime");
- this._content = GetSafeData.ValidateDataRow_S(dr, "Content");
- this._reply = GetSafeData.ValidateDataRow_S(dr, "reply");
- }
- }
- #endregion 方法
- }
- }