using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Globalization; using System.Threading; public partial class QfindPwd : System.Web.UI.Page { static string question; static string Username; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString.ToString()); protected void Page_Load(object sender, EventArgs e) { if (Session["Lang"] != null) { if (Session["Lang"] == "zh-cn") { ImageButton1.ImageUrl = "images/xyb.jpg"; ibtnfi0.ImageUrl = "images/xyb.jpg"; ibtnfi.ImageUrl = "images/wancheng.jpg"; RequiredFieldValidator1.ErrorMessage = "密码不能为空!"; CompareValidator1.ErrorMessage = "两次输入的密码不一样,请重新输入"; RequiredFieldValidator2.ErrorMessage = "密码不能为空!"; } else if (Session["Lang"] == "en-us") { ImageButton1.ImageUrl = "images/next1.jpg"; ibtnfi0.ImageUrl = "images/next1.jpg"; ibtnfi.ImageUrl = "images/complete.jpg"; RequiredFieldValidator1.ErrorMessage = "The password can not be empty!"; CompareValidator1.ErrorMessage = "The two passwords are not the same, please re-enter"; RequiredFieldValidator2.ErrorMessage = "The password can not be empty!"; } } if (!IsPostBack) { this.div1.Visible = true; this.all.Visible = false; } } protected void ibtnfi0_Click(object sender, ImageClickEventArgs e) { string sqlstr = "select * from Membertab where nickname ='" + Username + "' and QS = '" + this.txtq.Text + "' and Ans ='" + this.txta.Text + "'"; bool b = new common().ExecuteScalar(sqlstr, null); if (b) { this.divbottom.Visible = true; this.divtop.Visible = false; } else { Methods1.Methods1.Alert(this, "您输入的回答错误,请重新输入!"); } } protected void ibtnfi_Click(object sender, ImageClickEventArgs e) { string pwd = Methods1.Methods1.Md5(txtpwd.Text, 32); string UpdatePwd = " update Membertab set passwd ='" + pwd + "' where nickname = '" + Username + "'"; bool b = new common().ExcuteNoneQuery(UpdatePwd, null); if (b) { Methods1.Methods1.MsgBox("修改成功", "default.aspx"); } else { Methods1.Methods1.Alert(this, "修改失败"); } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string sqlstr = "select * from Membertab where nickname = '" + this.txtUsername.Text + "' or Cinowo_id ='" + this.txtUsername.Text + "'"; DataTable dt = new common().ExcuteReader(sqlstr).Tables[0]; if (dt.Rows.Count != 0) { div1.Visible = false; all.Visible = true; divbottom.Visible = false; question = dt.Rows[0]["QS"].ToString(); Username = dt.Rows[0]["nickname"].ToString(); this.txtq.Text = question; } else { Methods1.Methods1.Alert(this, "对不起,用户名输入错误或不存在"); } } protected override void InitializeCulture() { if (Session["lang"] != null) { string lang = Session["lang"].ToString(); if (!String.IsNullOrEmpty(lang)) { //UICulture - 决定了采用哪一种本地化资源,也就是使用哪种语言 //Culture - 决定各种数据类型是如何组织,如数字与日期 Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang); base.InitializeCulture(); } } } protected void LinkButton2_Click(object sender, EventArgs e) { Session["Lang"] = "en-us"; Response.Redirect(Request.Url.ToString()); } protected void LinkButton1_Click(object sender, EventArgs e) { Session["Lang"] = "zh-cn"; Response.Redirect(Request.Url.ToString()); } }