日期:2014-05-17 浏览次数:20545 次
protected void BT_SubTz_Click(object sender, EventArgs e)
{
string title = TB_Title.Text.Trim();
string words = TB_Words.Text.Trim();
string companyname;
string SQLstr;
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["strConnection"].ConnectionString);
int type = Convert.ToInt32(DDL_Type.SelectedValue.ToString());
if (type != 1)
{
TB_CompanyName.Visible = false;
companyname = "指导员";
}
else
{
companyname = TB_CompanyName.Text.Trim();
}
SQLstr = "insert into tb_Content(subject,words,UserName,CreateTime,LastAnswerTime,HitCount,Type,CompanyName)"
+ "values('" + title + "','"
+ words + "',"
+ "'" + Session["UserName"].ToString() + "',"
+ DateTime.Now +","
+ DateTime.Now +","
+ "0," + type + ","
+ "'" + companyname + "')";
SqlCommand myCmd = new SqlCommand(SQLstr, conn);
try
{
conn.Open();
myCmd.ExecuteNonQuery();
}
catch
{
throw new Exception("连接服务器出错");
}
finally
{
m