关闭

利用C#制作简单的留言板

发表于:2009-12-10 10:46

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:未知    来源:51Testing软件测试网采编

#
DotNet

  留言板分三个模块:列出留言列表、显示详细内容、发表留言

  notepage.cs
  namespace  notpage
  {
  using  System;
  using  System.Data.SQL  ;
  using  System.Data  ;
  using  System.Collections  ;
  public  class  notepage
  {
  //私有变量
  private  int  n_intID  ;  //ID编号
  private  string  n_strTitle  ;  //主题
  private  string  n_strAuthor  ;  //留言人
  private  string  n_strContent  ;  //留言内容
  private  DateTime  n_dateTime  ;  //留言时间
  //属性
  public  int  ID
  {
  get
  {
  return  n_intID  ;
  }
  set
  {
  n_intID  =  value;
  }
  }
  public  string  Title
  {
  get
  {
  return  n_strTitle  ;
  }
  set
  {
  n_strTitle  =  value;
  }
  }
  public  string  Author
  {
  get
  {
  return  n_strAuthor  ;
  }
  set
  {
  n_strAuthor  =  value  ;
  }
  }
  public  string  Content
  {
  get
  {
  return  n_strContent  ;
  }
  set
  {
  n_strContent  =  value  ;
  }
  }
  public  DateTime  adddate
  {
  get
  {
  return  n_dateTime;
  }
  set
  {
  n_dateTime  =  value;
  }
  }
  //构造函数
  public  notepage()
  {
  //
  //  TODO:  Add  Constructor  Logic  here
  //
  this.n_intID  =  0  ;
  this.n_strTitle  =  ""  ;
  this.n_strAuthor  =  ""  ;
  this.n_strContent  =  ""  ;
  this.n_dateTime  =  System.DateTime.Now;
  }
  ///  <summary>
  ///
  ///  取得留言的内容
  ///
  ///  </summary>
  ///  <param  name="a_intID">  </param>
  public  notepage  GetTopic(int  a_intID)
  {
  //
  //  TODO:  Add  Constructor  Logic  here
  //
  //读取数据库
  myconn  myConn  =  new  myconn();
  SQLCommand  myCommand  =  new  SQLCommand()  ;
  myCommand.ActiveConnection  =  myConn  ;
  myCommand.CommandText  =  "n_GetTopicInfo"  ;  //调用存储过程
  myCommand.CommandType  =  CommandType.StoredProcedure  ;
  myCommand.Parameters.Add(new  SQLParameter("@a_intTopicID"  ,  SQLDataType.Int))  ;
  myCommand.Parameters["@a_intTopicID"].Value  =  a_intID  ;
  notepage  objNp  =  new  notepage();
  try
  {
  myConn.Open()  ;
  SQLDataReader  myReader  ;
  myCommand.Execute(out  myReader)  ;
  if  (myReader.Read())
  {
  objNp.ID  =  (int)myReader["ID"]  ;
  objNp.Title  =  (string)myReader["Title"]  ;
  objNp.Author  =  (string)myReader["Author"]  ;
  objNp.Content  =  (string)myReader["Content"];
  objNp.adddate  =  (DateTime)myReader["adddate"];
  }

51/512345>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号