notepage
namespace notpage
{
using System;
using System
using System
using System
////////////////////////////////////////////////////////////////////
//
// Class Name : 留言板
//
// Description: 構造一個留言板對象
//
// date:
//
// 作者
/// ////////////////////////////////////////////////////////////////
///
/// Summary description for notepage
///
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
this
this
this
this
}
///
///
/// 取得留言的內容
///
///
///
public notepage GetTopic(int a_intID)
{
//
// TODO: Add Constructor Logic here
//
//讀取數據庫
myconn myConn = new myconn()
SQLCommand myCommand = new SQLCommand() ;
myCommand
myCommand
myCommand
myCommand
myCommand
notepage objNp = new notepage()
try
{
myConn
SQLDataReader myReader ;
myCommand
if (myReader
{
objNp
objNp
objNp
objNp
objNp
}
//清場
myReader
myConn
}
catch(Exception e)
{
throw(new Exception(
}
return objNp;
}
///
///
/// 目的
///
/// 利用構造函數來傳遞信息
///
///
///
public bool AddTopic(notepage n_Topic)
{
//
// TODO: Add Constructor Logic here
//
//讀取數據庫
myconn myConn = new myconn()
SQLCommand myCommand = new SQLCommand() ;
myCommand
myCommand
myCommand
myCommand
myCommand
myCommand
myCommand
myCommand
myCommand
try
{
myConn
myCommand
//清場
myConn
}
catch(Exception e)
{
throw(new Exception(
}
return true;
}
///
/// 取的貼子列表
///
///
/// 返回一個Topic數組
///
public ArrayList GetTopicList()
{
//定義一個forum數組做為返回值
ArrayList arrForumList =new ArrayList() ;
//從數據庫中讀取留言列表
myconn myConn = new myconn()
SQLCommand myCommand = new SQLCommand() ;
myCommand
myCommand
myCommand
try
{
myConn
SQLDataReader myReader ;
myCommand
for (int i =
{
notepage objItem = new notepage() ;
objItem
objItem
objItem
objItem
objItem
arrForumList
}
//清場
myReader
myConn
}
catch(SQLException e)
{
throw(new Exception(
//return null ;
}
return arrForumList ;
}
}
}
myconn
namespace notpage
{
using System;
using System
///
/// Summary description for myconn
///
public class myconn:System
{
private void InitializeComponent ()
{
}
public myconn()
{
//
// TODO: Add Constructor Logic here
//
this
this
this
this
}
}
}
添加留言addTopic
<%@ Page language=
<html><head>
<meta content=
<meta content=C# name=CODE_LANGUAGE></head>
<body>
<form method=post runat=
<table cellSpacing=
<tr>
<td>留言主題
<td><asp:textbox id=txtTitle runat=
<tr>
<td>姓名
<td><asp:textbox id=txtAuthor runat=
<tr>
<td>留言內容</TD>
<td><asp:textbox id=txtContent runat=
id=btnSubmit runat=
text=
</body></html></P><P>對應的cs
namespace notpage
{
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
///
/// Summary description for AddTopic
///
public class AddTopic : System
{
protected System
protected System
protected System
protected System
public AddTopic()
{
Page
}
protected void Page_Load(object sender
{
if (!IsPostBack)
{
//
// Evals true first time browser hits the page
//
}
}
protected void Page_Init(object sender
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer
//
InitializeComponent()
}
///
/// Required method for Designer support
/// the contents of this method with the code editor
///
private void InitializeComponent()
{
btnSubmit
this
}
public void OnSubmit(Object sender
{
if (Page
{
//數據入庫
try
{
notepage objNp = new notepage()
objNp
objNp
objNp
objNp
notepage objNp
if(objNp
{
Response
成功留言
}
}
catch(Exception exp)
{
#if DEBUG
Response
return ;
#endif//DEBUG
}
}
}
}
}
顯示列表list
<%@ Page language=
<html><head>
<meta name=
<meta name=
<body>
<form method=
<TABLE WIDTH=
<TR>
<TD>主題</TD>
<TD>留言人</TD>
<TD>留言時間</TD>
</TR>
<asp:label id=
</TABLE></P><P> </body></html>
namespace notpage
{
using System;
using System
using System
using System
using System
using System
using System
using System
using System
using System
///
/// Summary description for list
///
public class list : System
{
protected System
public list()
{
Page
}
protected void Page_Load(object sender
{
if (!IsPostBack)
{
//
// Evals true first time browser hits the page
//
}
}
protected void Page_Init(object sender
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer
//
InitializeComponent()
Init_tdtitle()
}
///
/// Required method for Designer support
/// the contents of this method with the code editor
///
private void InitializeComponent()
{
this
}
protected void Init_tdtitle()
{
InitializeComponent()
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer
//
try
{
notepage np = new notepage()
ArrayList arrTopic = np
for ( int i =
{
notepage objTopic = (notepage)arrTopic[i] ;
string str =
str = str +
str = str +
n_tdtitle
}
}
catch(Exception e)
{
throw(new Exception(
}
}
}
}
查看留言內容showtopic
<%@ Page language=
<html><head>
<meta content=
<meta content=C# name=CODE_LANGUAGE></head>
<body>
<form method=post runat=
<p align=center><font color=red><b>察看留言</b></font></p><br>
<p align=left><font color=blue>留言主題
<br>留言時間
<asp:label
id=n_tdAuthor runat=
runat=
</body></html>
對應的cs
namespace notpage
{
using System;
using System
using System
using System
using System
using System
using System
using System
&nbs
From:http://tw.wingwit.com/Article/program/net/201311/13886.html