📄 newtopic.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 System.Data.OleDb;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using SampleForum.SetData;
using BusObjectForum;
namespace SampleForum.Forum
{
/// <summary>
/// newTopic 的摘要说明。
/// </summary>
public class newTopic : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label labCaption;
protected System.Web.UI.WebControls.Label labDesc;
protected System.Web.UI.WebControls.Button btnOK;
protected System.Web.UI.WebControls.TextBox txtCaption;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtDesc;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator2;
protected System.Web.UI.WebControls.Button btnCancel;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
public static string CONNSTRING
{
get
{
connect_strings oConn = new connect_strings();
return oConn.SqlConnectionString;
}
}
//增加新主题
public void addNewTopic(object sender, System.EventArgs e)
{
//基于连接的insert
string sql = "insert into T_Topic (fchrTopicID,fchrTopicCaption,fchrTopicDetail,fchrOperatorID,fdtmDate,fbitIsTOP,fbitIsGood,fbitNoUsed,fchrFunctionID)"+
" values(@fchrTopicID,@fchrTopicCaption,@fchrTopicDetail,@fchrOperatorID,@fdtmDate,@fbitIsTOP,@fbitIsGood,@fbitNoUsed,@fchrFunctionID)";
SqlConnection oConn = new SqlConnection(CONNSTRING);
SqlCommand oCommand = new SqlCommand(sql,oConn);
oCommand.Parameters.Add(new SqlParameter("@fchrTopicID",SqlDbType.UniqueIdentifier,16));
oCommand.Parameters.Add(new SqlParameter("@fchrOperatorID",SqlDbType.VarChar,50));
oCommand.Parameters.Add(new SqlParameter("@fchrFunctionID",SqlDbType.VarChar,50));
oCommand.Parameters.Add(new SqlParameter("@fchrTopicCaption",SqlDbType.VarChar,50));
oCommand.Parameters.Add(new SqlParameter("@fchrTopicDetail",SqlDbType.VarChar,1000));
oCommand.Parameters.Add(new SqlParameter("@fdtmDate",SqlDbType.DateTime,8));
oCommand.Parameters.Add(new SqlParameter("@fbitIsTop",SqlDbType.Bit ,1));
oCommand.Parameters.Add(new SqlParameter("@fbitIsGood",SqlDbType.Bit ,1));
oCommand.Parameters.Add(new SqlParameter("@fbitNoUsed",SqlDbType.Bit ,1));
string strUID="";
string strFunctionID="";
strUID = Request.QueryString["UID"];
strFunctionID = Request.QueryString["id"];
InnerFunction oFunction = new BusObjectForum.InnerFunction();
oCommand.Parameters["@fchrTopicID"].Value = oFunction.getNewID();
oCommand.Parameters["@fchrOperatorID"].Value= "{" + strUID + "}";
oCommand.Parameters["@fchrFunctionID"].Value= "{" + strFunctionID + "}";
oCommand.Parameters["@fchrTopicCaption"].Value=txtCaption.Text;
oCommand.Parameters["@fchrTopicDetail"].Value=txtDesc.Text;
oCommand.Parameters["@fdtmDate"].Value=System.DateTime.Now;
oCommand.Parameters["@fbitIsTop"].Value=false;
oCommand.Parameters["@fbitIsGood"].Value=false;
oCommand.Parameters["@fbitNoUsed"].Value=false;
oConn.Open();
try
{
oCommand.ExecuteNonQuery();
//运行一段客户端代码,用于关闭窗口
String sScript = "<script language=JavaScript> " ;
sScript += "window.close();";
sScript += "</script>";
if(!this.IsClientScriptBlockRegistered("MyScript"))
{
this.RegisterClientScriptBlock("MyScript", sScript);
}
}
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 + -