温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:大学生调查投票系统源码
当前文件:
StudentVote/Add.aspx.cs,打开代码结构图
StudentVote/Add.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Data.SqlClient; 12
13
public partial class Vote : System.Web.UI.Page 14
{ 15
protected void Page_Load(object sender, EventArgs e) 16
{ 17
18
} 19
protected void btnAdd_Click(object sender, EventArgs e) 20
{ 21
string StrContent = this.TextBox2.Text.Trim().Replace("\n", "|"); 22
string[] StrEvery = StrContent.Split('|'); 23
foreach (string str in StrEvery) 24
{ 25
if (str.Split(',').Length > 0) 26
{ 27
if (str.IndexOf(',') <= 0) 28
{ 29
Response.Write("<script language=javascript>alert('格式错误!');location='javascript:history.go(-1)'</script>"); 30
return; 31
} 32
} 33
} 34
string Com = "Insert into tb_Vote(Title,Content) values('" + this.TextBox1.Text + "','" + StrContent + "')"; 35
SqlData da = new SqlData(); 36
bool add = da.ExceSQL(Com); 37
if (add == true) 38
{ 39
Response.Write("<script language=javascript>alert('添加成功!');location='Index.aspx'</script>"); 40
} 41
else 42
{ 43
Response.Write("<script language=javascript>alert('添加失败!');location='javascript:history.go(-1)'</script>"); 44
} 45
46
} 47
protected void btnCancle_Click(object sender, EventArgs e) 48
{ 49
this.TextBox1.Text = ""; 50
this.TextBox2.Text = ""; 51
} 52
} 53





}
}