?? mabh.aspx.cs
字號(hào):
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Web.Mail;
namespace gllbysj
{
/// <summary>
/// mabh 的摘要說(shuō)明。
/// </summary>
public class mabh : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Panel Panel2;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.LinkButton LinkButton4;
protected System.Web.UI.WebControls.LinkButton LinkButton2;
protected System.Web.UI.WebControls.LinkButton LinkButton3;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.LinkButton LinkButton1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Panel Panel1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁(yè)面
if(!this.IsPostBack)
{
this.rod();
}
}
public void rod()
{
string[]source={"0","1","2","3","4","5","6","7","8","9",
"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
"O","P","Q","R","S","T","U","V","W","X","Y","Z"};
string code="";
Random rd=new Random();
for(int i=0;i<5;i++)
{
code+=source[rd.Next(0,source.Length)];
}
this.Label2.Text=code;
Session["code"]=code;
}
#region Web 窗體設(shè)計(jì)器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click);
this.LinkButton3.Click += new System.EventHandler(this.LinkButton3_Click);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.LinkButton4.Click += new System.EventHandler(this.LinkButton4_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void LinkButton1_Click(object sender, System.EventArgs e)
{
string str="select * from user1 where name='"+this.TextBox1.Text+"'";
SqlConnection cn=db.createcon();
cn.Open();
SqlCommand cmm=new SqlCommand(str,cn);
SqlDataReader sdr=cmm.ExecuteReader();
if(sdr.Read())
{
//Response.Write(sdr["quest"].ToString());
if(sdr["quest"].ToString()!="")
{
//Response.Write("不為空");
this.Label1.Text=sdr["quest"].ToString();
this.Panel1.Visible=false;
this.Panel2.Visible=true;
}
else
{
Response.Write("<script langeage=javascript>alert('您還沒(méi)有申請(qǐng)保護(hù)!')</script>");
this.HyperLink1.Visible=true;
//Response.Write("空");
}
}
else
{
Response.Write("<script language=javascript>alert('用戶不存在')</script>");
}
cn.Close();
}
private void LinkButton3_Click(object sender, System.EventArgs e)
{
this.rod();
}
private void LinkButton2_Click(object sender, System.EventArgs e)
{
if(this.TextBox3.Text==Session["code"].ToString())
{
string str="select * from user1 where name='"+this.TextBox1.Text+"'";
SqlConnection cn=db.createcon();
cn.Open();
SqlCommand cmm=new SqlCommand(str,cn);
SqlDataReader sdr=cmm.ExecuteReader();
sdr.Read();
if(sdr["answer"].ToString()==this.TextBox2.Text)
{
//this.Label3.Text="當(dāng)前密碼為:"+sdr["password"].ToString();
// me.From="adb@163.com";
//string s="您的密碼為:"+sdr["password"].ToString();
// string s="密碼已發(fā)送到您的郵件地址,請(qǐng)查收!";
/* MailMessage msg=new MailMessage();
msg.To=sdr["mail"].ToString();
//msg.To="ybbuuuuss521@163.com";
msg.From="ybbuuuuss521@163.com";
msg.Subject="密碼找回";
//msg.Body="您的當(dāng)前密碼為:['"+sdr["password"].ToString()+"']建議您盡快此網(wǎng)站修改您的密碼:http://localhost/gllbysj/baohu.aspx";
msg.Body="";
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","ybbuuuuss521@163.com");
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","tkggipgmy");
//try
// {
SmtpMail.SmtpServer="smtp.163.com";
SmtpMail.Send( msg );*/
MailMessage mail = new MailMessage();
//mail.To = "ybbuuuuss521@163.com";
mail.To=sdr["mail"].ToString().Trim();
mail.From = "ybbuuuuss521@163.com";
mail.Subject = "密碼找回";
mail.Body = "您的當(dāng)前密碼為:["+sdr["password"].ToString()+"]建議您盡快此網(wǎng)站修改您的密碼:http://localhost/gllbysj/baohu.aspx";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "ybbuuuuss521@163.com");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "tkggipgmy");
SmtpMail.SmtpServer = "smtp.163.com";
SmtpMail.Send( mail );
Response.Write("<script language=javascript>alert('密碼已發(fā)送到您的郵件地址,請(qǐng)查收!');location='mabh.aspx'</script>");
//}
//catch
//{
// Response.Write("<script language=javascript>alert('數(shù)據(jù)庫(kù)錯(cuò)誤!')</script>");
// }
// me.To==sdr["mail"].ToString();
//me.Body=sdr["password"].ToString();
//Response.Redirect("mabh.aspx");
}
else
{
Response.Write("<script language=javascript>alert('您的回答不正確!')</script>");
}
cn.Close();
}
else
{
Response.Write("<script language=javascript>alert('驗(yàn)證碼不正確!')</script>");
//Response.Write(Session["code"].ToString());
}
}
private void LinkButton4_Click(object sender, System.EventArgs e)
{
Response.Redirect("mabh.aspx");
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -