温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:Asp.Net许愿墙系统源码
当前文件路径:XuYuanQiang/admin.aspx.cs

1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Data.OleDb; 6
using System.Drawing; 7
using System.Web; 8
using System.Web.SessionState; 9
using System.Web.Security; 10
using System.Web.UI; 11
using System.Web.UI.WebControls; 12
using System.Web.UI.HtmlControls; 13
14
namespace pizi 15
{ 16
/// <summary> 17
/// Summary description for Test. 18
/// </summary> 19
public partial class Test : System.Web.UI.Page 20
{ 21
protected string md5s = null; 22
23
protected void Page_Load(object sender, System.EventArgs e) 24
{ 25
if(Session["user"]==null) 26
{ 27
Response.Write("您没有权限 所以你不能登陆!"); 28
Server.Transfer("index.aspx"); 29
} 30
if(Session["link"]!=null) 31
{ 32
msgbox.Text = Session["link"].ToString(); 33
} 34
this.DataBinder(); 35
36
37
} 38
39
Web Form Designer generated code 58
59
public void DataBinder() 60
{ 61
string Constr ="Provider=Microsoft.Jet.OLeDb.4.0;Data source=" + Server.MapPath("Love_Dai.mdb"); 62
string Querystring ="Select cdate,cauthor,md5id,sendname from ccc_love order by cdate "; 63
OleDbConnection oleconnection = new OleDbConnection(Constr); 64
//OleDbCommand olecommand = new OleDbCommand(Querystring,oleconnection); 65
//oleconnection.Open(); 66
//olecommand.Connection.Close(); 67
OleDbDataAdapter oleda = new OleDbDataAdapter(Querystring,oleconnection); 68
DataSet ds = new DataSet(); 69
oleda.Fill(ds); 70
oleconnection.Close(); 71
DataGrid1.DataSource = ds.Tables[0].DefaultView; 72
DataGrid1.DataBind(); 73
} 74
75
protected void Button1_Click(object sender, System.EventArgs e) 76
{ 77
if(Name.Text.Length !=0 && Name.Text !=null ) 78
{ 79
md5s = FormsAuthentication.HashPasswordForStoringInConfigFile(Name.Text,"md5"); 80
string Constr ="Provider=Microsoft.Jet.OLeDb.4.0;Data source=" + Server.MapPath("Love_Dai.mdb"); 81
string Querystring ="Insert Into ccc_love(md5id,sendname) values ( @md5id,@sendname)"; 82
OleDbConnection oleconnection = new OleDbConnection(Constr); 83
OleDbCommand cmd = new OleDbCommand(Querystring,oleconnection); 84
cmd.Parameters.Add("@md5id",OleDbType.VarChar,250); 85
cmd.Parameters.Add("@sendname",OleDbType.VarChar,250); 86
cmd.Parameters["@md5id"].Value = md5s ; 87
cmd.Parameters["@sendname"].Value =Name.Text; 88
try 89
{ 90
oleconnection.Open(); 91
cmd.ExecuteNonQuery(); 92
93
} 94
catch(Exception ex) 95
{ 96
msgbox.Text = "错误是:" + ex.ToString(); 97
} 98
finally 99
{ 100
oleconnection.Close(); 101
cmd.Dispose(); 102
} 103
msgbox.Text = "根据'"+ Name.Text +"'已经建立了一个激活连接:" + "http://您的地址/BlessPost.aspx?Upsotname=" +md5s; 104
Session["link"] = msgbox.Text; 105
} 106
else 107
{ 108
msgbox.Text = "忘记输入了!"; 109
} 110
Response.Redirect("admin.aspx"); 111
112
} 113
} 114
} 115





}