📄 forumlist.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using BusObjectForum;
using SampleForum.SetData;
using System.Data.SqlClient;
namespace SampleForum.Forum
{
/// <summary>
/// ForumList 的摘要说明。
/// </summary>
public class ForumList : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label labFormCaption;
protected System.Web.UI.WebControls.Label labForumDesc;
protected System.Web.UI.WebControls.Button btnCancel;
protected System.Web.UI.WebControls.Button btnOK;
protected System.Web.UI.WebControls.TextBox txtCaption;
protected System.Web.UI.WebControls.TextBox txtDetail;
protected System.Web.UI.WebControls.Repeater repForum;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
InitList();
}
public static string CONNSTRING
{
get
{
connect_strings oConn = new connect_strings();
return oConn.OLEDBConnectionString;
}
}
public static string SQLCONNSTRING
{
get
{
connect_strings oConn = new connect_strings();
return oConn.SqlConnectionString;
}
}
public void InitList()
{
string strTopicID = Request.QueryString["id"];
string ErrDesc= "";
ForumC oForum = new ForumC();
DataSet oDataSet = oForum.getForumByTopic(CONNSTRING,strTopicID,false,out ErrDesc);
if(ErrDesc=="")
{
repForum.DataSource = oDataSet.Tables[0].DefaultView;
repForum.DataBind();
}
else
{
Response.Write("错误:"+ErrDesc);
}
}
//新增回复
public void AddNewForum(object sender, System.EventArgs e)
{
//基于连接的insert
string sql = "insert into T_Forum " +
"(fchrForumID,fchrForumCaption,fchrFatherID,fchrForumDetail,fchrOperatorID,fdtmDate,fbitNoUsed)" +
"values (@fchrForumID,@fchrForumCaption,@fchrFatherID,@fchrForumDetail,@fchrOperatorID,@fdtmDate,@fbitNoUsed)";
SqlConnection oConn = new SqlConnection(SQLCONNSTRING);
SqlCommand oCommand = new SqlCommand(sql,oConn);
oCommand.Parameters.Add(new SqlParameter("@fchrForumID",SqlDbType.UniqueIdentifier,16));
oCommand.Parameters.Add(new SqlParameter("@fchrForumCaption",SqlDbType.VarChar,50));
oCommand.Parameters.Add(new SqlParameter("@fchrFatherID",SqlDbType.VarChar,50));
oCommand.Parameters.Add(new SqlParameter("@fchrForumDetail",SqlDbType.VarChar,1000));
oCommand.Parameters.Add(new SqlParameter("@fchrOperatorID",SqlDbType.VarChar,50));
oCommand.Parameters.Add(new SqlParameter("@fdtmDate",SqlDbType.DateTime,8));
oCommand.Parameters.Add(new SqlParameter("@fbitNoUsed",SqlDbType.Bit ,1));
string strUID="";
string strFatherID="";
strUID = Request.QueryString["UID"];
strFatherID = Request.QueryString["id"];
InnerFunction oFunction = new BusObjectForum.InnerFunction();
oCommand.Parameters["@fchrForumID"].Value = oFunction.getNewID();
oCommand.Parameters["@fchrForumCaption"].Value= this.txtCaption.Text;
oCommand.Parameters["@fchrFatherID"].Value= "{" + strFatherID + "}";
oCommand.Parameters["@fchrForumDetail"].Value=this.txtDetail.Text;
oCommand.Parameters["@fchrOperatorID"].Value = "{" + strUID + "}";
oCommand.Parameters["@fdtmDate"].Value=System.DateTime.Now;
oCommand.Parameters["@fbitNoUsed"].Value=false;
oConn.Open();
try
{
oCommand.ExecuteNonQuery();
Response.Redirect ("ForumList.aspx?id="+ strFatherID +"&UID="+ strUID );
}
catch(Exception exp)
{
Response.Write(exp.Message);
}
oConn.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -