温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:达达ASP.NET简单新闻发布源码
当前文件路径:DaDaNews/Admin/AddClass.aspx.cs

1using System; 2
using System.Collections; 3
using System.Configuration; 4
using System.Data; 5
using System.Data.SqlClient; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.HtmlControls; 10
using System.Web.UI.WebControls; 11
using System.Web.UI.WebControls.WebParts; 12
13
public partial class Admin_AddClass : System.Web.UI.Page 14
{ 15
Db pn163 = new Db(); 16
protected void Button1_Click(object sender, EventArgs e) 17
{ 18
if (Session["Admin"] == null) 19
{ 20
Response.Redirect("./Default.Aspx"); 21
} 22
23
SqlConnection Conn = new SqlConnection(pn163.strConn); 24
25
string ClassName = TextBox1.Text.Trim(); 26
27
string St = TextBox2.Text.Trim(); 28
29
Conn.Open(); 30
31
SqlCommand Cmd = new SqlCommand("insert into NewClass(Class,St,Cls1_id)" + "values('" + ClassName + "','" + St + "')", Conn); 32
33
if (TextBox1.Text == "" && TextBox2.Text == "") 34
{ 35
Response.Write("<script>alert('不能提交空值!');history.go(-1);</script>"); 36
} 37
else 38
{ 39
Cmd.ExecuteNonQuery(); 40
Response.Redirect("./Class.Aspx"); 41
} 42
Conn.Close(); 43
} 44
} 45




Db pn163 
}
}