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

软件测试

开发平台:

Java

  1. /**********************************************************
  2.  * 说明:留言类Messages
  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.     public class Messages
  14.     {
  15.         #region 私有成员
  16.         private int _id;           //留言ID
  17.         private string _guest_name;//留言人名称
  18.         private string _sex;       //性别
  19.         private string _email;     //email
  20.         private string _phone;     //电话
  21.         private string _city;      //城市
  22.         private string _content;   //留言内容
  23.         private DateTime _booktime;//留言时间
  24.         private string _reply;   //回复内容
  25.         #endregion 私有成员
  26.         #region 属性
  27.         public int id
  28.         {
  29.             set
  30.             {
  31.                 this._id = value;
  32.             }
  33.             get
  34.             {
  35.                 return this._id;
  36.             }
  37.         }
  38.         public string guest_name
  39.         {
  40.             set
  41.             {
  42.                 this._guest_name = value;
  43.             }
  44.             get
  45.             {
  46.                 return this._guest_name;
  47.             }
  48.         }
  49.         public string sex
  50.         {
  51.             set
  52.             {
  53.                 this._sex = value;
  54.             }
  55.             get
  56.             {
  57.                 return this._sex;
  58.             }
  59.         }
  60.         public string email
  61.         {
  62.             set
  63.             {
  64.                 this._email = value;
  65.             }
  66.             get
  67.             {
  68.                 return this._email;
  69.             }
  70.         }
  71.         public string phone
  72.         {
  73.             set
  74.             {
  75.                 this._phone = value;
  76.             }
  77.             get
  78.             {
  79.                 return this._phone;
  80.             }
  81.         }
  82.         public string city
  83.         {
  84.             set
  85.             {
  86.                 this._city = value;
  87.             }
  88.             get
  89.             {
  90.                 return this._city;
  91.             }
  92.         }
  93.         public string content
  94.         {
  95.             set
  96.             {
  97.                 this._content = value;
  98.             }
  99.             get
  100.             {
  101.                 return this._content;
  102.             }
  103.         }
  104.         public DateTime booktime
  105.         {
  106.             set
  107.             {
  108.                 this._booktime = value;
  109.             }
  110.             get
  111.             {
  112.                 return this._booktime;
  113.             }
  114.         }
  115.         public string reply
  116.         {
  117.             set
  118.             {
  119.                 this._reply = value;
  120.             }
  121.             get
  122.             {
  123.                 return this._reply;
  124.             }
  125.         }
  126.         #endregion 属性
  127.         #region 方法
  128.         /// <summary>
  129.         /// 向数据库添加一个用户
  130.         /// </summary>
  131.         /// <param name="message">用户信息哈希表</param>
  132.         public void Add(NoSortHashtable messageInfo)
  133.         {
  134.             Database db = new Database(); //实例化一个Database类
  135.             db.Insert("[guestbook]", messageInfo);
  136.         }
  137.         /// <summary>
  138.         /// 修改留言内容
  139.         /// </summary>
  140.         /// <param name="newTopicInfo"></param>
  141.         public void Update(Hashtable newTopicInfo,int id)
  142.         {
  143.             Database db = new Database();
  144.             string strCond = "Where id = " + id;
  145.             db.Update("[guestbook]", newTopicInfo, strCond);
  146.         }
  147.         /// <summary>
  148.         /// 删除留言
  149.         /// </summary>
  150.         public void Delete()
  151.         {
  152.             ArrayList sqls = new ArrayList();
  153.             string sql = "";
  154.             sql = "Delete from [guestbook] where id = " + this._id;
  155.             sqls.Add(sql);
  156.             Database db = new Database();
  157.             db.ExecuteSQL(sqls);
  158.         }
  159.         /// <summary>
  160.         /// 按时间降序,读取所有留言
  161.         /// </summary>
  162.         /// <returns></returns>
  163.         public static DataSet QueryMessages()
  164.         {
  165.             string sql = "";
  166.             sql = "Select * from [guestbook] order by booktime desc";
  167.             Database db = new Database();
  168.             return db.GetDataSet(sql);
  169.         }
  170.         /// <summary>
  171.         /// 根据参数topicID,获取帖子细信息
  172.         /// </summary>
  173.         /// <param name="topicID">帖子ID</param>
  174.         public void LoadData(int id)
  175.         {
  176.             Database db = new Database(); //实例化一个Database类
  177.             string sql = "";
  178.             sql = "Select * from [guestbook] where id = " + id;
  179.             DataRow dr = db.GetDataRow(sql); //利用Database类的GetDataRow方法查询用户数据
  180.             //根据查询得到的数据,对成员赋值
  181.             if (dr != null)
  182.             {
  183.                 this._guest_name = GetSafeData.ValidateDataRow_S(dr, "guest_name");
  184.                 this._id= GetSafeData.ValidateDataRow_N(dr, "id");
  185.                 this._booktime = GetSafeData.ValidateDataRow_T(dr, "booktime");
  186.                 this._content = GetSafeData.ValidateDataRow_S(dr, "Content");
  187.                 this._reply = GetSafeData.ValidateDataRow_S(dr, "reply");
  188.             }
  189.         }
  190.         #endregion 方法
  191.     }
  192. }