您目前尚未登陆,请选择【登陆】或【注册
首页->投票调查->大学生调查投票系统源码>>Edit.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:大学生调查投票系统源码
当前文件:文件类型 StudentVote/Edit.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.SqlClient; 12 13public partial class Edit : System.Web.UI.Page 14{ 15 protected void Page_Load(object sender, EventArgs e) 16 { 17 string StrID = Request["ID"]; 18 string Com = "select * from tb_Vote where ID='"+StrID+"'"; 19 SqlConnection Sqlcon = new SqlConnection(ConfigurationManager.AppSettings["ConStr"]); 20 Sqlcon.Open(); 21 SqlCommand SqlCom = new SqlCommand(Com, Sqlcon); 22 SqlDataReader dr = SqlCom.ExecuteReader(); 23 dr.Read(); 24 if (!IsPostBack) 25 { 26 this.txtSubject.Text = dr["Title"].ToString(); 27 this.txtContent.Text = dr["Content"].ToString().Replace("|", "\n"); 28 } 29 dr.Close(); 30 } 31 32 protected void btnUpdate_Click(object sender, EventArgs e) 33 { 34 string StrContent = this.txtContent.Text.Trim().Replace("\n", "|"); 35 string[] StrEvery = StrContent.Split('|'); 36 foreach (string str in StrEvery) 37 { 38 if (str.Split(',').Length > 0) 39 { 40 if (str.IndexOf(',') <= 0) 41 { 42 Response.Write("<script language=javascript>alert('格式错误!');location='javascript:history.go(-1)'</script>"); 43 return; 44 } 45 } 46 } 47 string Com = "Update tb_Vote Set Title='" + this.txtSubject.Text + "',Content='" + StrContent + "' where ID=" + Request["ID"] + ""; 48 SqlData da = new SqlData(); 49 bool update = da.ExceSQL(Com); 50 if (update == true) 51 { 52 Response.Write("<script language=javascript>alert('修改成功!');location='Index.aspx'</script>"); 53 } 54 else 55 { 56 Response.Write("<script language=javascript>alert('修改失败!');location='javascript:history.go(-1)'</script>"); 57 } 58 } 59 protected void btnDelete_Click(object sender, EventArgs e) 60 { 61 string Com = "delete from tb_Vote where ID="+Request["ID"]+""; 62 SqlData da = new SqlData(); 63 bool delete = da.ExceSQL(Com); 64 if (delete) 65 { 66 Response.Write("<script language=javascript>alert('删除成功!');location='Index.aspx'</script>"); 67 } 68 else 69 { 70 Response.Write("<script language=javascript>alert('删除失败!');location='javascript:history.go(-1)'</script>"); 71 } 72 } 73} 74
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:大学生调查投票系统源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号